03-08-2022 11:13 AM - edited 03-08-2022 11:15 AM
Hello, i'm trying to read/write with the modbus library with 9 different serial ports. I have 3 cRIO controllers and every controller has a NI 9871 module with 4 serial ports. I need to make a VI that is able to communicate with all the 9 serial ports (4 + 4 + 1) simultaneously.
If i connect the VI (Gestione.vi) directly under the controller it works fine.
The problem is that in this way i can only connect 4 serial ports and i need to connect all of them. So i switched the VI under my computer and in this way i can read all the serial ports (each controller has a different IP).
But modbus doesn't work, i'm not able to read/write anything. Can somebody help?
03-08-2022 11:36 AM
Do you get an error number or message?
Are you sure that the cRIOs are set up to accept connections, on the default port, from your PC's IP address?
03-09-2022 07:11 AM
Mhh no.. the VI runs fine but modbus read doesn't show me anything, i have "0" for every address i read.
I'm not sure about the second and i don't know how to do that, maybe that's the key
03-09-2022 11:43 AM
I don't have a cRIO so I am not 100% sure how they work, but I do know that with NI-MAX you can set up NI-RIO to allow other systems to access VISA devices over the network (by going to the "Tools -> NI-RIO Settings" menu selection) and that by default it is off. I would imagine that in the settings for a cRIO somewhere there has to be a similar set of controls, I just don't know if they default to being off as well. Can you check the right-click menu on the cRIOs you have in MAX to see what shows up?
Also, instead of using the MODBUS VIs, where you can't really look inside, try just opening a regular VISA connection using one of the serial ports without using MODBUS... just standard VISA Open, VISA Write, etc. and see if you get errors on those when trying to access one of the serial connections on the cRIOs over the network.
03-09-2022 11:47 AM - edited 03-09-2022 12:12 PM
I'll try tomorrow, maybe the first thing you said is the answer, because the VI works perfectly if i place it under the controller.
These are the options i get with the device disconnected.
03-09-2022 12:22 PM
Why do you need 9 MODBUS masters? How many Slave devices are there? You know you can address several slave devices from one master right?
03-09-2022 12:26 PM
Yes, but i don't know how to do that on the VI, so i just created a master for each slave ( i have 9 slaves, 1 on each serial port)
03-09-2022 01:59 PM - edited 03-09-2022 02:07 PM
@wingSs wrote:
Yes, but i don't know how to do that on the VI, so i just created a master for each slave ( i have 9 slaves, 1 on each serial port)
You do that in HARDWARE by properly wiring your slave devices and assigning them unique addresses.
Seriously, you spent thousands of dollars to add 8 unnecessary modbus masters to save you from Googling MODBUS and reading a tutorial? (Don't tell your NEXT boss)
03-09-2022 02:13 PM
You're right, i'm doing this for a friend tough (only the software part, the hardware was already cabled this way), didn't pay for the hardware :d
03-09-2022 02:21 PM
@wingSs wrote:
You're right, i'm doing this for a friend tough (only the software part, the hardware was already cabled this way), didn't pay for the hardware :d
A good friend would mention the silly mistake and show the right way to do it.