01-14-2021 11:14 AM
Hi, everyone!
I'm trying to acquire distance data from a laser sensor using RS232&MODBUS ASCII on NI myRIO. I attached my VI.
I first connected the rs232 port of the laser control unit with my PC using an RS232 to USB converter. It showed up in Device Manager as a COM port. I run my VI, and I got my distance data. The VI works as follows: First, open a VISA resource and configure it according to the laser sensor manual. Then send a MODBUS ASCII command "M0" to ask for the control unit to send distance data. And read the VISA resource to acquire the data, which has a format of "M0,distance 1,distance2".
However, when I connected the control unit with NI myRIO, my VI stop working. The device showed up in NI MAX under myRIO. But after sending the "M0" command, the VISA resource has ZERO bytes on the port, meaning I didn't get any data (see the highlighted execution).
I thought that the I/O settings of the myRIO port might be wrong. Then I showed all the serial settings of both the PC COM port and the myRIO port (seen below). There were three differences between them: Line CTS State, Line DCD State, and Line DSR State. But I couldn't change these settings using the property node because they're read-only.
I finally tried to change the I/O settings using NI MAX. I found that the only setting differences between them are Hardware Control under Flow Control Settings (seen below). The differences are CTS and DSR under Input State. But they're grayed out.
I exhaust the debugging means I can think of.
Any suggestions?
Solved! Go to Solution.
01-14-2021 11:30 AM
I have a digital scale that uses RS485&MODBUS-RTU. It works perfectly on myRIO.
01-14-2021 12:48 PM
@PurpleWINDD wrote:
Hi, everyone!
I'm trying to acquire distance data from a laser sensor using RS232&MODBUS ASCII on NI myRIO. I attached my VI.
l. Then send a MODBUS ASCII command "M0" to ask for the control unit to send distance data. And read the VISA resource to acquire the data, which has a format of "M0,distance 1,distance2".
A lot going on within this message. But one thing needs to be cleared up.
M0 is NOT a Modbus command. Modbus is a very specific protocol with the data that is sent and received well defined. Sending "M0" or the response you received is not Modbus.
01-14-2021 01:09 PM
CTS and DSR come from the device so that is why they are read-only.
No idea what the laser controller wants, but keep in mind that the EOL constant is different on your PC (\r\n) than it is on the myRIO (\n).
01-14-2021 11:09 PM
Thanks for clarifying! Then they're the manufacturer-specific commands.
But these commands seem not to be an issue because I can run my VI successfully on PC.
01-14-2021 11:16 PM
Thanks!
I'm using the same converter on PC and myRIO. I'll try changing the EOL in my VI.
01-19-2021 03:24 AM
I finally got it working!
Because my project needs several USB devices connected to myRIO, I was using a USB extender. When I removed the extender and connected the RS232-USB converter directly to myRIO, I could get my data! Then I plug the extender back and connected the converter to the extender. My VI was still working ok!
I don't know why.