Hi
I currently have a MSComm control (piezoComm1) which I use to send commands to a device attached to COM1.
I am using the Output property to send commands to the device, eg. MOV A25 which will move the device to 25 microns. This is working fine as I have tested the device's position using Hyper Terminal. However, I would like to test the position of the device within my VB project and display the results in a label on the form. Heres my code:
VB Code:
Private Sub cmdGo_Click() frmMain.piezoComm1.Settings = "115200, N, 8, 1" 'set baud rate, parity, data bits and stop bits frmMain.piezoComm1.CommPort = 1 'set PC COMM port frmMain.piezoComm1.InputLen = 0 'retrieve all of the input buffer frmMain.piezoComm1.InputMode = comInputModeText 'input buffer to receive text - not binary frmMain.piezoComm1.PortOpen = True 'open port frmMain.piezoComm1.Handshaking = comRTS 'request to send handshaking frmMain.piezoComm1.Output = frmMain.Text1 + Chr$(13) + Chr$(10) 'send command in text box frmMain.lblResult1.Caption = frmMain.piezoComm1.Input 'put contents of input buffer into label frmMain.piezoComm1.PortOpen = False 'close port End Sub
When I type the query position command "POS? A" in the text box and click the button the designated label disappears, as if its caption value is set to blank/nothing. I am confident that this command works as I have used it in Hyper Terminal.
Can anybody shed some light on this problem?
Thank you in advance
Wallace




Reply With Quote