02-23-2023 11:36 AM
I can connect to a single Modbus RTU slave with no problem. However, how can I expand this to communicate with multiple slaves using the same COM port?
Solved! Go to Solution.
02-23-2023 11:43 AM
Change the addresses to be different. I cannot open your code as I don't have LV 2023. You may want to save for previous version code posted here. However, if you can talk to one slave device, the address is part of the communication for Modbus RTU. You will need a way to change it on your slave device. (I've had to connect one at a time and set the address before integrating into a bigger project).
02-23-2023 11:47 AM
How can I change the Unit ID on the fly so that I can address another unit and keep the information separate? What I have now does well for one unit and graphs the temperature every second.
02-23-2023 11:54 AM
To better see what I have so far, I am attaching a Word document with the VI.
02-23-2023 12:11 PM
Save for a previous version is the preferred method. Posting a png image also works. Using a proprietary Word document to insert an image is something I am not going to look at.
02-23-2023 12:26 PM
Didn't know what version to save as, so here is the png file. Sorry!
02-23-2023 12:57 PM
Ok. It looks like you are using NI's Modbus library, but honestly I am a little confused as to why they have a yellow border. Maybe a newer feature I am not familiar with.
At any rate, you want two Create Master functions. Both have the same com port and baud rate, but with different ID's. Use the two instance wires the same as how you have done with one. If they are the same type of device and you want the same data you can bundle the instance wires and use a for loop (see the picture).
02-23-2023 01:06 PM
Thank you! I will try that. The yellow borders are because I unchecked "View as Icon" as it is easier on my old eyes that way. Not sure if trying to create two instances using the same COM port will cause a conflict when trying to open the second one. With what I have now, in order to see the second unit, I have to stop it, change the ID, then start it again. I have to stop it as the COM port isn't released until the While Loop completes execution. Thanks again for the assistance!
02-23-2023 01:14 PM
I think I have used two devices on the same COM port. The NI Modbus Library should be smart enough to deal with it as multidrop is part of the Modbus specification (assuming it is 485 wiring, not 232). If you do have issues with it, there is another Modbus Library other people on the forums use called Plasmionique
https://www.vipm.io/package/mb_master/
02-23-2023 02:29 PM
You can just change the address with Set Unit ID.vi