Sign in to follow this  
Followers 0
jacintoanacleto

Using modbus through serial connections

7 posts in this topic

Hi there, so i've been having some issues in communicating from the pc to the plc with modbus, but cutting right to the chase my problem is: I have to develop a software, i think you can call it a SCADA, where it should be able to read registers, coils etc from a PLC, my plan is to do this task with modbus protocol. What i've done so far: - Used nModbus libraries, they are an implementation of the modbus protocol in c# - estabilished a serial (RTU) connection from the software to the simulator (Modbus PLC Simulator) modRS_sim and at this point i was trying to communicate from a pc to a PLC i have available (OMRON CJ1M) but with no success, since i was able to communicate with CX-Programmer using SYSMAC WAY i used the same settings (Baudrate, databits etc) on my c# software and still no success, it gives me a Connection Timeout. I ran a search in the forum and got to this page: http://forums.mrplc.com/index.php?app=downloads&showfile=867 It seems to have a ladder program in order to make the PLC respond to the modbus protocol, i've download it to the plc and tried again with no success, ok, so know i ask the real questions: - Is modbus protocol a good way to acquire data from a PLC, in general ?? For other manufacters as well ? - Does the plc need to have a ladder program in order to "talk" modbus ?? - Does the plc need a physical module to achieve the communication ?? At this point i'm confused, so i'm asking for your help, if you could please enlighten me i would appreciate very much the help.. and thanks in advance. *Omron PLC with I/O modules

Share this post


Link to post
Share on other sites
Add a serial card - SCU41 is 1 x RS232 and 1 x RS422/485 - SCU31 is 2 x RS422/485. Set the card up for full or half duplex - usually half - set the card to be a Modbus slave - set all comms parameters - set the slave numbver and you are away.

Share this post


Link to post
Share on other sites
Hi BobB, thanks for replying and thanks for your time, so as it seems i need a serial card in order to achieve this communication, but there's a few things i fail to understand, - do i need to write any ladder code to the plc besides from adding a serial card, set the duplex etc. in order to make this work ? - without trying to be disrespectful due to the dumbness of this question, i thought i could do this communication just using the rs232 cable i use from my pc to the CPU, aren't the registers, coils etc i want to access in this module ? What do these cards have different ? thanks for the help, Cheers.

Share this post


Link to post
Share on other sites
The way I suggested is by far the easiest way. The onboard serial port cannot be set up as a Modbus slave. There may be some software in the Omron download section here that would enable you to program the onboard serial port to be a Modbus slave - I do not bother but use the easy way - saves me a lot of time and time is money. The onboard serial port is only RS232 - I never use RS232 for this but always RS485 2 wire - half duplex. Far more reliable and greater distance than RS232. Withe the SCU card you just MOV data into the DM or CIO area you specify when setting up the card and then read from there. For example, if you specify D0000 your read would be holding register 0000 - it is that easy.

Share this post


Link to post
Share on other sites
Hm i see your point, one last thing, imagine i've created a ladder program and i have for example two coils as outputs in 1.00 and 1.01 addresses if i want to read these values with modbus do i read them in the address 100 and 101 ? does this makes sense ? again thanks for the help, cheers

Share this post


Link to post
Share on other sites
MOV them to your Modbus registers.

Share this post


Link to post
Share on other sites
Bob is spot on, as usual. If you are using Modbus holding registers, by default it is your DM addresses. ie Holding Register 0000 = Modbus 4000 = D0000 Holding Register 0101 = Modbus 4101 = D0101 It's that simple. If you're working with bits, like CIO 1.00 and 1.01 and you want modbus to read this, simply add an instruction in your program with: MOV 1 D1 All 16 bits in 1.00 - 1.15 are moved to D1, or modbus holding register 0.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0