Home > Software engineering >  VB serial port communication problems
VB serial port communication problems

Time:10-07

Recently I am writing about the serial communication program, as follows: I want to program control NewFoucs by PZT piezoelectric ceramic drive, the drive through the RS - 232 serial port and industrial connection, before using this drive, can use a manual operating handle, the handle Enter REL on 1 1000 G, and then click the Enter key on the handle, and then drive can produce 1000 pulse displacement, now I really want to in the program control, no longer use the handle, can you tell me how to do? I am now in a program using the MSComm control, and the initialization (including MSComm1. Settings="19200, n, 8, 1"), to the control after the initialization, I produced by wrote a statement on a function, as follows:
Private Sub GenerateCommand (Command As a String, the Paramater As String)
'note:
'when this function is called, pass REL to Command parameters, the same pass "1 1000 G" Paramater parameters used to generate the Command REL 1 1000 G, the back of the str1 str2 as the Enter key, is don't have to manually press Enter, but in the program implementation)

Dim str1, str2 As String
Str1=Asc (13) 'linefeed ASCII is 13
Str2 enter=Asc (10) 'ASCII is 10
Sendstring=Command + "" + Paramater + str1 + str2
End Sub
At present, the MSComm control has been initialized, the need to communicate to drive command has also written sendstring (variable), the question is how to send this command in the program, let drive start work?????? Consult everybody! Thank you first!

CodePudding user response:

The Enter key that consists of the following code:
Dim str1, str2 As String
Str1=CRH (13) 'linefeed ASCII is 13
Str2=CRH (10) 'enter ASCII is 10
Send command characters use MsComm controls the Output properties, such as sending the Enter key, the code is:

MSComm1. The Output=str1 + str2

CodePudding user response:

MSComm1. The Output=sendstring
  • Related