10-28-2022 11:55 AM
Hello,
I have been attempting to adapt a Visual basic code to a LabVIEW program where I am reading from a serial device (Heidenhain VRZ 460). The VI that I have built only writes to the device STX (which is the ASCII string to read start of text) then tries to read the data from the device. I have seen on this forum examples of this being done and have followed them but the same error keeps appearing where the read times out with no response. I believed that this was a coding issue but I tried to use the VISA resource panel to communicate with the device and it has the same error. The visual basic code works and can talk to the device but the NI MAX VISA resource panel and LabVIEW cannot communicate with the device. The port settings for this device are Baud rate:9600, even pairty, 7 data bits and 2 stop bits and none flow control. Has anyone seen NI MAX and Labview not work with a device while other code works correctly?
Thanks,
MM
10-28-2022 12:46 PM - edited 10-28-2022 12:48 PM
Yes I have seen that and it was always a PEBKAC problem or a complete misunderstanding of how they thought their other software was talking to the device.
Visual Basic code would hint at rather old examples too, Microsoft doesn’t sell it for a long time already and tries to marginalize VBA for quite some time too.
So what functions does your Visual Basic program use to establish communication? How do you format the string that you try fo send to the device? What string does your VB program send?
10-28-2022 12:59 PM
The Full VB code is :
Form1.MSComm1.PortOpen = True
From1.MSComm1.Output = Chr$(2)
Start = Timer
While Timer - Start < 1
Wend
A$ = From1.MSComm1.Input
Print A$
From1.MSComm1.PortOpen = False
The read command is the "From1.MSComm1.Output = Chr$(2)" where it talks the the device using VB's ASCII specific term which is Chr$(2).
10-28-2022 02:36 PM
Is your VB application:
If the answer to either is no then neither NI-Max nor LabVIEW will be able to access the com port.
10-28-2022 02:41 PM
The VB application was built to show that the issue was only with NI MAX and labview. The VB application was shut off when testing labview or the VISA resource panel each time and if it wasn't there was an error message about the port conflicting.
10-28-2022 03:09 PM
Can you upload your code? My magic 8 ball says you're not sending the control character that you think you are, but we can't be sure without seeing some code.
10-28-2022 09:29 PM
@BertMcMahan wrote:
Can you upload your code? My magic 8 ball says you're not sending the control character that you think you are, but we can't be sure without seeing some code.
You mean, like writing a literal "STX" to the serial port, or maybe "02" string?
10-31-2022 10:45 AM
@billko wrote:
@BertMcMahan wrote:
Can you upload your code? My magic 8 ball says you're not sending the control character that you think you are, but we can't be sure without seeing some code.
You mean, like writing a literal "STX" to the serial port, or maybe "02" string?
Ah, I see we shop at the same magic 8 ball store 🙂