Pages: [1]   Go Down
Author Topic: communication PLC micrologix 1400 using modbus protocol for arduino mega  (Read 2586 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hello friends

i am communicating my PLC  with arduino MEGA using modbus protocol i am putting PLC as modbus rtu slave and wants arduino mega as modbus RTU  master
does anybody have code for modbus master which will communicate with PLC
or please send me the link
 please reply  i want that code for my project as soon as possible



Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Read this before posting a programming question
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17263
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well the arduino playground has this listing: http://arduino.cc/playground/Code/ModbusMaster

And I'm sure a google search for "arduino modbus" will bring up lots of other possibilities.

Lefty
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hello,

I am struggling with modbus rtu protocol as well.

read wikipedia, Nicks' tutorial, everything whats written in arduino website.

But can not understand how are the registers send.

For example, from http://arduino.cc/playground/Code/ModbusMaster

what does these do in the loop function? :

Code:
  static uint32_t i;
  uint8_t j, result;
  uint16_t data[6];

then we have the line :

Code:
// slave 1: write TX to (2) 16-bit registers starting at register 0
  result = node.WriteMultipleRegisters(0, 2);

I understand that the protocol should send two 16 bit info, but what does it send? any random bits? Because there is no info, saying what exactly it is beeing sent, and where is that info taken from.

Any help is much appreciated. 
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is what I got to work a while back.  Modbus over etherenet via an Uno and a ML1400 micrologix controller.  1766-l32awaa I think.  It has been a while.

* Modbus.rar (74.41 KB - downloaded 57 times.)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

dear arthur duhaime sir

thanks for your reply i have got ML-1400 SERIES A PLC and i want to be my arduino mega as a modbus master and PLC as a modbus slave  so that i can read the status of the input coil or write to the output coil using arduino and i want to communicate it via serially


will u suggest me what should i do i am using the library http://arduino.cc/playground/Code/ModbusMaster
but i am not geeting by using this how to read the status of my input or write the coil


please reply

thanking you
dhruvit


Logged

Staffordshire UK
Offline Offline
Full Member
***
Karma: 1
Posts: 132
Just a little bit out there ...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I cant comment on the library but if you are talking to an ML series PLC then you will be taking to blocks not functions or symbols.

You could talk to the 'I' & 'O' registers directly but it isn't recommended and the addressing looks strange to boot.
Your best solution to to map the IO in some ladder like this.

XIC (B3:0/0) ______ OTE (O:0/0)
XIC (I:0/0) _______ OTE (B3:1/0)

Now you have the simplified task of talking to the first two bytes of B3 ( something like B0003 in modus terms. )
I strongly recommend that you download a PC based mod-bus program to get the protocol working as you want, which may take a bit of fiddling.
Once you know 'exactly'  how to read or write a bit in B0003 you can start thinking about building this into an Arduino

hope this helps
Al
Logged

If I knew where the box was I would probably still want to think outside it!

Feel free to be blunt ... Its how I learn.

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

dear arthur duhaime sir

thankyou for your reply
i have a modscan 32 protocol through which i can easily read my status of the input and write the output coil  using
N12(WRITE O/P) N13 (READ I/P COIL) which is i have programmed in PLC
The same thing i want to do it using my arduino

i cant understed what you are trying to say by this sentence



you have the simplified task of talking to the first two bytes of B3 ( something like B0003 in modus terms. )

waiting for your reply




Logged

Staffordshire UK
Offline Offline
Full Member
***
Karma: 1
Posts: 132
Just a little bit out there ...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorruy 'modus' should have said modbus.

The point is the registers that you will define and interrogate, in the PLC, from your master, the Arduino will always be blocks, never wires or instructions.

Physical I/O can be directly mapped as an appropriately sized block will be defined when adding an IO module to the controller however these are dynamic so may not exist and it is better practice to manually define a block or blocks for your communication requirements and them map, or mirror, the data, symbols, from your ladder.

Theoretically a value could be changed mid scan by your coms which is not the way physical IO is implemented in the ML PLC.
What you probably want to achieve is to read and write all your coms registers once per program scan within the PLC ...

Hope that clarifies it for you.
Logged

If I knew where the box was I would probably still want to think outside it!

Feel free to be blunt ... Its how I learn.

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

dear arthur duhaime sir

thankyou for your keen interset in my queries
i am a student from india amd currently doing my M.E(ELECRONICS ENGINEERING)
 i have understood your answer
but how do i achive that in arduino?????
i know this is not a good question to ask but i am really stuck up  WITH  this problem for the last 1 months and unless i will get it solved i will not get  my degree???????


hope you understand my problem


waiting for your reply
Logged

Pages: [1]   Go Up
Jump to: