PLC as master, PC as slave

Hassman

Member
Join Date
Jan 2013
Location
City
Posts
18
Hey all,

So I took on the task of creating a C# application using the nModBus protocol to communicate between my ClickPLC and my PC. It worked, I am able to read data, write data etc etc.

The problem is....I didn't realize that I have to continually "ping" (request read/write) the PLC for data, and I find this very inefficient, especially since it is only when the PLC input signals high that I want to register an event in my C# application.

So software talk aside....I want my PLC to act as the master, and my PC to act as the slave. I want my PLC to communicate with my PC and tell it to read its data ONLY when it receives a high input signal. This would be much more efficient, especially in terms of a system process standpoint, and ultimately meets the purposes of my task at hand.

Tips, ideas, thoughts? Thanks in advance!
 
From your description it sounds like the application you're running on the PC is the Mdbus master and the Click PLC is the Modbus slave. You will need to reverse those roles.
The Click PLC can be the Modbus master. You will have to set up your application on the PC side to be the slave. In your ladder logic in the Click you will need to use the high state of the hard wired input to trigger a Modbus write of the data you want to transmit.
 
Hey Steve, so the millio dollar question is, how do i transition from the ladder logic to send a modbus write to my pc? Im not looking for tou to solve thr problem for me, bit im kinda stumped. ive done very well on my own in learning the protocol, working in c sharp, addressing etc...but this issue has stopped me in my tracks
 
I think implementing your approach will be a major challenge on the PC side; specifically finding/developing Modbus slave software, since it's much more common for the PC to be the master.

I'd suggest looking at ways to meet your performance requirement under the PLC-slave PC-master architecture. For example, if you have to monitor a large number of possible events in the PLC, perhaps you could logical-OR them into a single "master alarm" bit, which would be the only PLC register you'd routinely poll. When that bit is set, the PC would then poll the individual alarm registers to determine what event has occurred, then go back to polling just the master alarm bit.

BTW, I'm using a Click in a home-automation system with a PC as Modbus master.
 
Hey Albert,

It's great to meet another click user....they are truly great little PLCs. I wish I had known about them when I was in school!

See that's the thing...the convention is to have the PLC as the slave, and PC as the master, and it's getting quite difficult to find a means for the PLC to act as the master with the PC on standby as the slave....I haven't given up hope yet, but it seems like I may just have to have a program running 24/7 on the PC that will be continually polling the PLC for inputs. It may be the safest, most consistent and surefire bet.
 
but it seems like I may just have to have a program running 24/7 on the PC that will be continually polling the PLC for inputs.
You'll have to have something running 24/7 in the PC no matter what you do. If the PC is a Modbus slave you'll need an application running that periodically checks the serial port to see if the Click has sent any new data. If the PC is the master the application will have to send a "read" command to the Click PLC and wait for the response.
 
I know what you mean Steve, I just meant "polling 24/7", it would be ideal for the program to have an interrupt whereby an event is handled in the event that a pushbutton is pressed on the PLC side (with the PLC being master saying "Hey PC, I've got some data coming your way")...but it seems like that is not doable....unless you have some suggestions?
 
Hello,

>unless you have some suggestions?

That is what a slave driver does. It waits for the master to initiate a message. Can you not program the click to only send a message on command?
 
Hi Mark,

Thanks for responding, and I did check out PeakHMI but I can not seem to get any responses from my PLC. Here is what I did

1: Used MODBUS RTU Serial Slave (from PeakHMI)

2: Configured settings accordingly (com port of PLC, baud-rate, parity etc etc, and slave id is 1)

3: Setup a push-button as an input on my PLC, and pressed it down to set my first input to high

4: I opened up the communications in the PeakHMI software, but see nothing. I don't see any changes in the register either.

Any tips? Did i overlook a step? Thanks for your help
 
As for programming the click to send a message by command, as far as I can tell I can not. It does have a "send" function, but that is through its ladder logic program, which i am not using, since i am developing its functionaltiy through C# using the nModBus library.
 
Hello,

OK

A master/slave protocol means one end is the master and initiates all communication cycles and the other end is the slave and responds to communication cycles initiated by the master.

A slave never initiates the communication cycle.

If you do not want the Click to be a slave and you do not want to program the Click to be a master, I am not sure what you want.

If you want an exception based protocol then MODBUS is not it. There are several protocols that might work for you, DNP3 is popular.
Polling is kept to a minimum but one end is still the master and other end, in the case of DNP3 is the outstation. It will initiate communication cycles under certain conditions.

From your first post:

>and I find this very inefficient

When you are talking about a point to point connection from two devices that have very low loading, most PCs and PLCs are not heavily loaded, efficient is what...

>So software talk aside....I want my PLC to act as the master, and my PC to act as the slave.

That contradicts the above about you do not want that because it is "inefficient".

>I want my PLC to communicate with my PC and tell it to read its data ONLY when it receives a high input signal.

What, you want the PLC to use an I/O point to command the PC to read the changed data?

That is possible. It will require PLC programming. But you do not want that "since i am developing its functionaltiy through C# using the nModBus library".

To conclude: using the MODBUS protocol alone will not get you what you want. It can, if you program the Click to act as a master.
 

Similar Topics

I'm using a Automationdirect CLick PLC (c0-02dd2-d). It has 2 RJ12 ports and 1 designated RS485 (we will call this port 3) port. My thought...
Replies
5
Views
3,163
I have downloaded Modbus Poll software ,so I can siulate SERVER and client. In my example Server is PC with IP - 192.168.0.17 SLAVe is PLC...
Replies
5
Views
3,490
Hello Guys, I have two different Micro 830 PLCs, namely 2080-LC30-100QWB and other one is 24AWB. I want to make one Micro 830 as Modbus Slave and...
Replies
1
Views
2,557
We are looking into purchasing a modicon momentum PLC that will control a slave using Modbus TCP over Ethernet. We would like to also export...
Replies
5
Views
4,345
Hi, I have two PLCs connected each other, one is Master whose station ID is 1 and the other is Slave whose Station ID is 4. By connecting SCADA...
Replies
2
Views
2,910
Back
Top Bottom