Do not receive a response from the syringe pump through rs232 using MSComm1.Input

I am trying to connect to a syringe pump from a PC via rs232.

I want to send the string "02DC;50803" to the pump to establish communication, and the pump should answer "C" .

I use MSComm1.Output="02DC;50803" to send the command and Text1.Text=Text1.Text+MSComm1.Input to receive. When MSComm1.Output is MSComm1.Output , I can see that the LED is blinking on the target device, but there is no answer using MSComm1.input .

Please help me with this problem, and if I put this instruction under the control of MSComm() , it seems dead.

-1
source share
2 answers

There may be several problems.

For instance:

  • Your cable may be damaged.
  • your serial port may not work - I see that a lot
  • Your command is incorrect.
  • the pump simply does not expect a response to the command you are sending.

Those last 2 may be unlikely, the pump will probably answer everything you shoot at it - all I have is the right answer.

In fact, you need much more information to help you.

  • What does / model the pump?
  • A manual for the pump so that your commands can be checked.
  • Have you connected to the pump using your existing software package? - if there.

PS My software does not support your pump; I do not recognize these commands.

0
source

To continue the tone list:

  • Are you using the right speed?
  • What are the .RThreshold and .SThreshold settings?
  • Are other comport settings correct (usually N, 8.1, but there are exceptions)?
  • Have you tried to execute the command using the hyperterminal and get the expected response?
  • Where in your code do you read MSComm1.Input? in which event?
  • Does the device also have an LED that flashes when sending data? is he blinking
  • Does the end-char command need vbCrLf or vbCr anything else?

Please place the full function / auxiliary code where you send the command, and please write the full function / sub code where you read MSCOmm1.Input

Take a look at the following test project, in which I send the β€œAT” command to my modem, which is connected to commport 1 and with which I communicate at a transmission speed of 9600:

 '1 form with: ' 1 textbox control : name=Text1 ' 1 command button : name=Command1 ' 1 MSComm control : name=MSComm1 Option Explicit Private Sub Command1_Click() MSComm1.Output = "at" & vbCrLf End Sub Private Sub Form_Load() With MSComm1 If .PortOpen Then .PortOpen = False .Settings = "9600,n,8,1" .CommPort = 1 .RThreshold = 1 'read data per char .SThreshold = 0 'send all data at once .PortOpen = True End With 'MSComm1 End Sub Private Sub Form_Resize() Dim sngWidth As Single Dim sngCmdHeight As Single Dim sngTxtHeight As Single sngWidth = ScaleWidth sngCmdHeight = 315 sngTxtHeight = ScaleHeight - sngCmdHeight Text1.Move 0, 0, sngWidth, sngTxtHeight Command1.Move 0, sngTxtHeight, sngWidth, sngCmdHeight End Sub Private Sub MSComm1_OnComm() Dim strData As String With MSComm1 Select Case .CommEvent Case comEvReceive strData = .Input ShowData strData End Select End With 'MSComm1 End Sub Private Sub ShowData(strData As String) With Text1 .SelStart = Len(.Text) .SelText = strData End With 'Text1 End Sub 

When I click on Command1, it will send β€œAT” and vbCrLf, and the modem answers β€œOK”, which is displayed in Text1.

0
source

Source: https://habr.com/ru/post/1233660/


All Articles