I am trying to read data from 30 modbus slave devices (rs485) in M580, apart from Read Var and Write Var blocks, what would be the best efficient method of programming to get data quickly into PLC?
As the connection used is serial, the performance is not achieved by means of one block or another, as it is RS485, until a request is finished, the next cannot be started, so to perform a reading of the 30 devices, at least you will need 90 program cycles (3 cycles per device) assuming the devices respond in less time than the M580 program cycle.
I would recommend that you use different communication rings, which will allow you to launch as many requests in the same program cycle as there are communication rings.
Another option is to use Modbus TCP / IP - Modbus gateways, these can process requests waiting, which will increase the performance of the channel (you can reduce 1 cycle per device).
In addition to the Read_Var and Write_Var blocks, you can also use Data_Exch.
There are a few things to consider.
- you are reaching the limits on a RS485 network for number of connected devices (limit 31 before repeater is required). You would need to use a good RS485 master such as BMXNOM0200 or Link150 gateway. The M340 CPU RS485 port is not really up to this duty. Make sure that the wiring is of good standard with correct termination.
- what baud rate will the slave devices support?
- how much data are you trying to read?
- do any slave devices go offline?
If you are using a BMXNOM0200 then I'd suggest an indexed READ_VAR block and manage the timeouts so that the block runs as fast as possible. Biggest problem is a device that goes offline and you have to wait foe comms time out before moving onto the next device.
By indexed I mean that there is one READ_VAR block and you index the parameters and response from/ to arrays.
Start with one slave then go from there.
A good bench test tool is https://sourceforge.net/projects/modrssim2/
This allows you to set up your family of slave devices on your PC and read them using the PLC. You can enable/ disable individual devices.
Discuss challenges in energy and automation with 30,000+ experts and peers.
Find answers in 10,000+ support articles to help solve your product and business challenges.
Find peer based solutions to your questions. Provide answers for fellow community members!