LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Acquire data from sensor via cRIO 9040 port RS 485 MODBUS

Hello everyone,

I am trying to acquire flow rate data from a sensor via the serial port of my cRIO in Labview.

 

I am using:

  • Labview 2018 (including Real Time  and DSC 2018 modules)
  • RT cRIO 9040 - which includes a serial port RS 485 (http://www.ni.com/documentation/en/compactrio-controller/latest/specs-crio-9040/specs/)
  • Ultrasound flow meter which supports the MODBUS protocol. The interface operates in half duplex mode, 8 data bits, 1 start bit, parity even, 38400k Baud and device address default 001. I only want to read the first holding register 400001.

I read several posts online and I am trying to use a I/O server to do so (http://zone.ni.com/reference/en-XX/help/370622M-01/lvmve/create_mb_ioserv/)

 

I can see the RS 485 port as 2-wire connection on NIMAX, I added the modbus serial I/O server (master) from the RT target in my project and I  created the bound variable of interest (flow_data) in my "IO variables" library.

 

However, when i open the properties of my I/O server I can only pick the serial port in the range COM1 to COM32, which doesn't correspond with the name of my cRIO port I see on NIMAX.

 

How do I know which one is the correct port?

 

In my vi I only have the shared variable connected to an indicator.

When I try to run it using one COM port (which I am not sure is the correct one) I get the following error:

 

-1967353900

Shared Variable in Platform_master.vi<APPEND>
This error or warning occurred while reading the following Shared Variable:
\\.\IO_Variables\Flow_Data
\\.\IO_Variables\Flow_Data

 

I would really appreciate any suggestion to do so and solve my errors.

Thank you very much.

Gaia

0 Kudos
Message 1 of 3
(2,461 Views)

Hey Gaia,

 

I'll start by saying I'm not too familiar with MODBUS, but I imagine one way to get the COM address of the serial port would be to connect to your cRIO over ssh and list the contents of the /dev/ folder. This should have an entry for the built in serial port.

 

Can I ask whether you can post your project, or screenshots of it, as this may help troubleshoot this?

 

Cheers!

Mitch

0 Kudos
Message 2 of 3
(2,416 Views)

Hello Mitch,

thank you for your reply.

 

I attached four screen shots:

1 - NIMAX interface were I can see my cRIO serial ports and their names. the RS 485 is the one I named COM1

2 - My project master. Under IO_variables I have my server I/O "Modbus1" and its bounded variables. I am interested to read a sign integer (input register S300001 or holding register S400001). Here you can also see how I call the variable on my vi (red circle).

with this vi I now get error -1967353902

3 - Screenshot of the properties of my I/O server (you can see that the serial port is COM 1 but as a choice I have COM1-32 and I don't see the visa original name of the cRIO serial port)

4 - As an alternative to the I/O server, I tried to use the modbus library (Flowmeter test 2 vi attached)) . Here I am sure I am using teh correct port because I see its original name. This way I get error 56.

 

I hope this helps.

Please let me know if you have any suggestion.

 

Best,

Gaia

0 Kudos
Message 3 of 3
(2,400 Views)