Hi all, first of all sorry for my bad english. This is my first big project with arduino mega. i'm collecting datas from D18B20 sensors with arduino and trying to send datas to my PLC (micrologix 1400). totally i have 45 sensors. and i use xbee to transfer datas from one place to other place. anyway, my question is ; how should i connect my arduino (or directly xbee) to my PLC? which is the easiest way? i searched about it, as i understand i should use RS232 to TTL as hardware and modbus library on arduino. with this way, i can send datas to plc. but how? anyone can help me?
If you want to use the Modbus Protocol, you need to set up your Arduino as a Slave device. Are your sensors digital or analogic? If you already have your sensor read by your Arduino, then you need to create some data structure, Modbus uses words, and set up this data to be in the modbus read/write area Let me know some more about your project/code
lmanuel thank you for your reply, my sensors are digital and i've already created words to send.. i just don't know how to send these datas to plc. i want to send this words to plc in every 1 or 5 minutes with rs232 or rs485. this is the only thing that i'll do. what should i use, how should i configure.. i don't have an idea about it. because i've never done it before..
The Mega would be a modbus slave device. The plc would have to poll the slave for data
What is your data format? Float or Int?
You need a data structure to store the data . Then you map this to modbus holding registers 4XXXX , Mega reads analog data. Scale it and moves it to the data structure to be read by the modbus master
I have used the mudbus lib on tcp and it works
my sensors are digital and i've already created words to send.. i just don't know how to send these datas to plc.
Modbus works in a different way. Your Arduino would be waiting for your plc to poll (ask for data) and reply to that poll. You just set up your modbus slave library to reply with the data on the words you have created to store your sensor values. It is in your PLC where, if possible, you could try to set up your poll time to 1 - 15 minutes..... or on the SCADA that polls from the PLC where you could also try to set up some specific polling time. Definetly not on the slave (arduino) The slave just sits and waits for the master (plc) to poll and then reply to that. Have a look at www.simplymodbus.ca and you will better understand the modbus protocol.
If I were you I would first look at using the DF1 protocol that is available on the Micrologix 1400. DF1 uses standard RS-232 electrical specification, and I think you may find that that will be an easier approach. You could also look into the ASCII protocol in your Micrologix 1400 too.
It sounds to me you are unsure of how any of these protocols work on the Micrologix range of PLCs. Might I suggest you use google to find a wealth of resources on the web. Here's one I just found http://sourceforge.net/projects/abdf1/
You did not say, but I am assuming you are using a computer with Microsoft windows, right? And you have RS-Logix500 programming software and also RS-Linx to help setup comms between your RS-Logix500 and Micrologix 1400 Here, this is another site with some useful info http://www.mrplc.com/kb/index.php?article=65
You'll need to become quite familar with the way in which Allen Bradley PLCs do thier serial comms first before you can start to connect up your Arduino.
You will need to understand the differences between the different electrical specifications such as RS-232 RS-485 and things like half or full duplex.
Once you undertsand the serial protocol, you will need to learn how to access the data areas in the Micrologix where you wish to store your data, such as what sort of file type, i.e. N for integer.
You will want to use RS485 not RS232 which is point to point and limited distance. I am assuming that you will have multiple ardunio each with a different modbus slave address The plc will have to poll each unit, this will take time . What will you do if a device is not online? Retry? This will slow things down