LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Acquiring data using RS232&MODBUS ASCII on NI myRIO

Solved!
Go to solution

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".

RS232 to USB converterRS232 to USB converter

success data acquiring when connected to PCsuccess data acquiring when connected to PC

 

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).

When connected to myRIO, I got zero byte of dataWhen connected to myRIO, I got zero byte of data

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.

serial settings of PC COM portserial settings of PC COM port

 Serial settings of myRIO portSerial settings of myRIO port

 

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.

PC COM port's Hardware Control settingPC COM port's Hardware Control setting

 

myRIO port Hardware Control settingsmyRIO port Hardware Control settings

 

I exhaust the debugging means I can think of. 

 

Any suggestions?

 

0 Kudos
Message 1 of 7
(1,468 Views)

I have a digital scale that uses RS485&MODBUS-RTU. It works perfectly on myRIO.

0 Kudos
Message 2 of 7
(1,463 Views)

@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.

 

 

0 Kudos
Message 3 of 7
(1,433 Views)
Solution
Accepted by topic author PurpleWINDD

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).

0 Kudos
Message 4 of 7
(1,426 Views)

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. 

0 Kudos
Message 5 of 7
(1,409 Views)

Thanks!

 

I'm using the same converter on PC and myRIO. I'll try changing the EOL in my VI.

0 Kudos
Message 6 of 7
(1,407 Views)
Solution
Accepted by topic author PurpleWINDD

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. 

0 Kudos
Message 7 of 7
(1,377 Views)