S7 200 Modbus Slave Library Download
I have seen a few posts lately on MODBUS so I thought I might post what I use with arduino. The library I use is located here: I have multiple slaves running. I use the code posted below on ALL of them, all I change is the slave ID. I keep all the pins the same, that way when I upload this code onto ANY arduino, it works. You should not have to change ANYTHING ELSE!
I also have this running over Xbee's through a Digi Connectport X4, which converts it to TCP. I then use Mango M2M as my SCADA package. I can now get my Analog and digital data from anywhere in the world, or open and close my roller doors, anything. I can even write Analog values.
All my logic is done in Mango. You could probably do a mesh with a Xbee as a coordinator on a PC, transmitting to all the MODBUS slaves,(leave all destination addresses as zero's and set the slave Xbees to routers), but have not tried it because I have an X4 I DO NOT think you need to use RS485 for this. Just connect a PC straight up to your freshly programmed arduino, and run some sort of MODBUS master or test software, using the register number as listed in the code. Remember, in the SCADA software do not use the whole address number, for instance, to access pin 2, you would be reading a COIL on Slave 1 at address 2, not address 10002. Some SCADA packages use ZERO offsets, so subtract 1, so the address for pin 2 would be 1.
Avicii download sample letter. Read Digital Input Data From Modbus Slave S7 200 PLC.
Sorry for the belated reply. The code and library above is for Modbus RTU over RS485. It is just the Digi Connectport that converts the RTU to TCP. You should be able to use this code with ANY SCADA system or HARDWARE that supports STANDARD MODBUS RTU registers and addressing. Get an Arduino, ANY arduino. Load up the code as above.
Add a RS-485 shield, and add a button to pin 2. Get a PC, and load up SCADA/HMI software that supports MODBUS RTU. Connect a RS232 to 485 converter OR a USB to RS485 converter. Connect it to the Arduino shield. In the SCADA software, add a data source as Com port(USB-485), Baud rate(9600), Slave Number(As per arduino code) and a 'TAG' or 'point' as an 'Input status',address(try 1 or 2) 7.
Go live with the SCADA software and press the button. It should be read in the software.
Do the same with other arduino inputs, except for the data type. MODBUS DATA types: (Yea, I know there are others, but these are all we need) Input status = Read a arduino input (1 or 0) Coil status = Write a arduino output (1 or 0) Input register = Read adruino analog input (0 to 1023) Use 2 byte unsigned integer in TAG settings Holding register = Write arduino analog output (0 to 255) Use 2 byte unsigned integer in TAG settings Remember, get rid of the RS-485 if you only have one slave!, it is used because 485 supports multidrop, this is where the slave ID's come in. You can do SO MUCH with MODBUS and ARDUINO. I have soil moisture, voltage, lux, temperature, humidity values all coming in flawlessly.
I can open and close roller doors, lights on and off, set lights to a certain brightness.what next.imagine. As far as the Siemens PLC goes, you can't use arduino with it unless you use the arduino as a master, and I don't see the point. H PS If I have missed anything, I apologise. For anyone interested in an AWESOME SCADA package, I recommend MANGO M2M.
Google Mango M2M to get to the Mango webpage, where you will find details on installing and downloading. Use this link to download because the links on the page direct you to Mango Automation, which is the commercial version, easily the best value for money or those wishing a bit more.