PLC as Data Concentrator...

Fasthotrod

Member
Join Date
Oct 2007
Location
Oklahoma
Posts
26
Good afternoon everyone.

A while back I asked for input regarding the use of a PLC to act as a 'data concentrator' as an interface between a new power system and an old building monitoring system. The original thread can be found here:

http://www.plctalk.net/qanda/showthread.php?t=34611

Since then, I have purchased the following:

One AD DO-06AR PLC: 120VAC w/Relays
Two FO-08DAH-2 8 Channel Analog Output cards
ZipLink DN-15TB Communications Connector Module
ZipLink ZL-DN15TB -CBL
One DL-06 Programming Cable
One DirectSoft5 Software package
One Users Manual

I installed the software and was able to communicate with the PLC. I wrote a quick program and made some outputs switch when given an input. (Hold the applause... I'm new at this. :oops: )

So now I think I am ready to dive into this project. (Okay... I know I'm not ready, but I don't have a choice but to dive in. :) )

I have been looking at data in my generator controller (Kohler DEC 550) using the Monitor III software on my laptop. My laptop is connected (RS-232) to the controller right now, but I can switch it to 485 using a dongle. (I'll be testing this to make sure I have my RX/TX lines setup properly between my laptop, PLC, and hardware points.)

Anyway, I have the documentation for the power system equipment, so now I need to figure out how to grab the data I need. I'll throw out an example and maybe you guys could point me in the right direction?

Example: I want the PLC to read what the generator output voltage is (0-150 VAC) and provide me an analog output (0-5 VDC).

The Kohler documentation states that this information is located in the following location in the generator controller:

Register: Data Description: Access: Data Type: Range/Units:
40004 ..... L1-L0 Voltage ... RO ... WORD ..... Volts AC
40005 ..... L2-L0 Voltage ... RO ... WORD ..... Volts AC
40006 ..... L3-L0 Voltage ... RO ... WORD ..... Volts AC

I need to have a rung in my PLC program that requests this data, so looking in my PLC manual on page 5-204 it says to do this by using a MODBUS Read from Network (MRX) command. The question is: How?

I need to have a rung that tells the CPU to send a command on out on Port 2 (K2?) to slave device #1 (DEC 500 controller: K1? ) and have it perform a Function Code: 03 - Read Holding Registers. I went to the end of the rung and added a MRX box, but I am confused as to how to configure it.

Does anyone have any example programs that I could use to learn from?

Tips, hints and suggestions are greatly appreciated. Thanks in advance!

Mark
 
Mark,

Don't know about this PLC but in the end they all are the same.

Modbus is a protocol. What this means is that the "string" that you will sent through the com port will need to be built in a certain order for the receiving device to understand it.

This string is an ASCII assembly of bits and bytes. Normally you shuld go the easy way and use some pre-built Modbus comunicatiing function block that are available with your brand of PLC.

The function block should have a SEND buffer and a RECEIVE buffer.

You would write the addresse and the command and the number of consecutive word you want this command to apply to... and thenhit the SEND bit of the block.. and voila...

Soon has you send the string... you should receive the answer back from the device you are trying to talk to...

Look for a function block that is named something like MOD.... or serialmod or whatever has a modbus sound to it.

Sometimes its a special function block that do not automaticaly get loaded when you start your programming software and you have to pick it from a librairy and insert it into the software... some other time you even have to go and get it from the manufacturer website.

You should first find this function block... the the real problems will begin... you are now the in-house expert.

I dont beleive anybody does the string build and CRC check by hand anymore... time flyes.
 
Thank you for taking the time to reply, Pierre. :nodi:

I am using an Automation Direct Micro PLC, DL-06. The software package I am using is DirectSOFT5. I have found the section in the manual where it refers to MODBUS RTU Instructions, and I am attempting to perform a "MODBUS Read from Network (MRX)" command.

AD defines this as follows, "The MODBUS Read from Netrork (MRX) instruction is used by the DL-06 network master to read a block of data from a connected slave device and to write the data into V-memory addresses within the master. The instruction allows the user to specify the MODBUS Function Code, slave station address, starting master and slave memory addresses, number of elements to transfer, MODBUS data format and the Exception Response Buffer."

This sounds like the instruction that I need to use, correct? It seems simple enough... Tell the PLC CPU to send a request out on port 2 (K2) to slave address 1 (K1) with function code 03 - Read holding registers. The "Start Slave Memory Address" would be 40004 in my example above from what I can tell.

The "Start Master Memory Address" is confusing, but I assume it means the memory area within the PLC to save the data I pull from the slave device.

When it asks for the number of elements, I get confused. Does it already know that I am looking at a register, thus knows to grab the 16 bits of data in one look, or do I need to tell it to look for all 16 bits?

584/984 mode needs to be used for the MODBUS Data Format from what I can tell, due to the 5-digit code in the register.

I'll keep playing with it and see what I can come up with...

Mark
 
You wont be able to read individual bits on Modbus only complete words.

The number of elements to transfer will mean how many words you want to read from the slave, so in your example it would be 3, you can usually read up to 125 words on modbus although this can be different depending on the slave, they all have to be sequential of course
 
You are right, "Start Master Memory Address" is where the instruction will store the data in the PLC. I would recommend storing it in a V-memory location. In this example, the number of elements will be the number of consecutive registers you want to read. It looks like you want to read three (K3). Good luck, and be sure to double check the cable pin-out on both ends for the Modbus communications.

edit:
Looks like tragically beat me to the answer. One other thing to add, be sure to include the "Port 2 busy bit" on the rung for this instruction, like shown in the manual.
 
Last edited:
It's starting to make more sense as I plow through it. đź“š

Thanks for the clarification regarding MODBUS capturing the WORD and not the individual bits. I hate to make assumptions, and I got this nasty habit of needing to know every little detail about how things work.

So let's step it up a bit. Let's say that I now want to grab information from Registers 40033 and 40034. Because the PLC grabs the info via MODUS and it's sequential, I can't just use one line to pick and choose the data I need, right? In other words, I can't grab 40004-40006, skip down to 40033-40034, and so on.

I'll need one line to grab 40004-40006, and then another line to grab 40033-40034 correct? I THINK that I can use one line to grab all of the data from 40004-40034, but if I am not using the data then why grab all of it? I think it would be better to just pick/choose what I need and go from there.

Thoughts?

Mark
 
I'll need one line to grab 40004-40006, and then another line to grab 40033-40034 correct? I THINK that I can use one line to grab all of the data from 40004-40034, but if I am not using the data then why grab all of it? I think it would be better to just pick/choose what I need and go from there.
It will take less time to read 40004 - 40034. That's because the Modbus master has to process only one transaction with the slave compared with two transactions to read 40004 - 40006 and then to read 40033 - 40034. The overhead involved in setting up the second read request and waiting for the response exceeds the additional time required for the slave to transmit the unneeded data when you do it with a single read.
 
Correct, you need to do 1 read per block of registers so 40004 for 3 and then do another one for 40033 for 2,

You should be able to look at an activity bit and a report status for each read, so when one has finished initiate the next read and so on, if you get an error report then either stop the read or set an alarm bit to an HMI or SCADA etc. (if you are using one that is)

Sometimes its just easier to take all the data from a slave rather than having to pick and choose bits, if they all have 50 registers just read all of them and use what you want, there is no harm in doing that if you have the memory in the PLC available to store it

Doing it this way you can align data on similar addresses in the PLC memory so read 34 from slave 4 to the PLC in registers 101-134 then slave 6 to the PLC to registers 201-234, you then know if you need the 20th word in each slave its on 120 and 220 or something along those lines.
 
Steve Bailey said:
It will take less time to read 40004 - 40034. That's because the Modbus master has to process only one transaction with the slave compared with two transactions to read 40004 - 40006 and then to read 40033 - 40034. The overhead involved in setting up the second read request and waiting for the response exceeds the additional time required for the slave to transmit the unneeded data when you do it with a single read.

Thanks, Steve. That makes sense. Grab the data, stick it in memory, and use only what I need to make my analog outputs work. Asking the PLC to stop while receiving a reply from the slave slows down the process. Got it.

So if I follow you guys right, I would still need to use two rungs/instructions when grabbing data from multiple registers/areas that are further apart, correct? From what tragically1969 was saying, I can grab up to 125 words at a time... so let's say I grab the info from 40000-40050, but I also need the data in 41500-41515. (I want to ignore the information in-between.) In this case I would need to split it up into two rungs make it work, correct?

I'm sorry for the newb questions, guys. This is my first PLC project and I feel like I'm learning to swim by jumping into deep water. :oops:

Thanks.

Mark
 
tragically1969 said:
Correct, you need to do 1 read per block of registers so 40004 for 3 and then do another one for 40033 for 2,

You should be able to look at an activity bit and a report status for each read, so when one has finished initiate the next read and so on, if you get an error report then either stop the read or set an alarm bit to an HMI or SCADA etc. (if you are using one that is)

Sometimes its just easier to take all the data from a slave rather than having to pick and choose bits, if they all have 50 registers just read all of them and use what you want, there is no harm in doing that if you have the memory in the PLC available to store it

Doing it this way you can align data on similar addresses in the PLC memory so read 34 from slave 4 to the PLC in registers 101-134 then slave 6 to the PLC to registers 201-234, you then know if you need the 20th word in each slave its on 120 and 220 or something along those lines.

Thanks for the explanation, tragically1969. (y)

I bought a book on PLC's a while back (Programmable Logic Controllers - Frank D. Petruzella, 2nd Ed.) and I have been reading about how to set this thing up. The logic portion seems easy enough, and if I were using this to design a control panel it seems like it would be a piece of cake. (Or at least a bit easier than wiring up a bunch of relays and timers. :D )

Asking it to read information on a network... not so much. :unsure:

Thanks again for the help, everyone!

Mark
 
The PLC does not stop while waiting for the data from the slave. It processes the Modbus commands and responses in the time between program scans. Data from a Modbus slave may not be available until several scans after the read request.

You're right about needing more than one read request when the addresses are widely separated. That's why it makes sense to group together all of the data that will need to be accessible via Modbus.
 
Steve Bailey said:
The PLC does not stop while waiting for the data from the slave. It processes the Modbus commands and responses in the time between program scans. Data from a Modbus slave may not be available until several scans after the read request.

You're right about needing more than one read request when the addresses are widely separated. That's why it makes sense to group together all of the data that will need to be accessible via Modbus.

Ohhhh... I gotcha. So is it right that the only 'stop' that happens is between the MODBUS request for register data and the reply from the slave? That's the purpose of the interlock, right? To prevent the PLC from sending multiple commands to the slaves and honking up the communications?

Thanks for the info, Steve!

Mark
 
That's the purpose of the interlock, right? To prevent the PLC from sending multiple commands to the slaves and honking up the communications?
Whenever I've set up a Modbus master in ladder logic, I've used a one-shot to trigger the read or write command. I don't send another command until I've received confirmation that the first command was processed successfully or until the timeout period has elapsed.
 
Mark,

If you can handle some more reading, these links are for Bernie Carltons AD comm port setup. Bernie is the man when it comes to comm port stuff.
http://www.theplcguy.com/Modbus/hooking_up_1.htm
http://www.theplcguy.com/Modbus/hooking_up_2.htm
http://www.theplcguy.com/Modbus/hooking_up_3.htm
http://www.theplcguy.com/Modbus/hooking_up_4.htm
http://www.theplcguy.com/Modbus/hooking_up_5.htm
http://www.theplcguy.com/Modbus/hooking_up_6.htm
http://www.theplcguy.com/Modbus/hooking_up_7.htm

Also in DS5 there are some examples that ship with the software.
1. Open DS launch
2. Right click on projects, browse will open up, click on that
3. Double click on the examples folder
4. Double click on ladder examples
5. Double click on modbus examples
6. The project you want is the MWX_MRXexample project

All you will need to do is change the MWX to a MRX. At this point you will have two MRX boxes one for each group of modbus registers.
 
Sorry for the delay in responding, guys. I was down in Texas for the weekened and I just got a chance to check back in.

Steve Bailey said:
Whenever I've set up a Modbus master in ladder logic, I've used a one-shot to trigger the read or write command. I don't send another command until I've received confirmation that the first command was processed successfully or until the timeout period has elapsed.

Good deal. I'll make sure to do the same. :nodi:

milldrone said:
Mark,

If you can handle some more reading, these links are for Bernie Carltons AD comm port setup. Bernie is the man when it comes to comm port stuff.
http://www.theplcguy.com/Modbus/hooking_up_1.htm
http://www.theplcguy.com/Modbus/hooking_up_2.htm
http://www.theplcguy.com/Modbus/hooking_up_3.htm
http://www.theplcguy.com/Modbus/hooking_up_4.htm
http://www.theplcguy.com/Modbus/hooking_up_5.htm
http://www.theplcguy.com/Modbus/hooking_up_6.htm
http://www.theplcguy.com/Modbus/hooking_up_7.htm

Also in DS5 there are some examples that ship with the software.
1. Open DS launch
2. Right click on projects, browse will open up, click on that
3. Double click on the examples folder
4. Double click on ladder examples
5. Double click on modbus examples
6. The project you want is the MWX_MRXexample project

All you will need to do is change the MWX to a MRX. At this point you will have two MRX boxes one for each group of modbus registers.

A HUGE thanks for the links! I read through Bernie's examples and it's great to see how he did everything. I'll look into the DS5 examples to see if I can get a handle on how this all works.

Thanks again for the information, guys! I really appreciate it!

Mark
 

Similar Topics

Just came across a configuration that I am not familiar with. In this configurartion, there are several PLC 5/40E rack with local analog I/O cards...
Replies
5
Views
7,268
Hi Iam using monitouch hmi(V9 soft) with omron plc cj2m (CX programmer). In this I want to read a data from hmi to plc. The data was like...
Replies
0
Views
90
I am working with beckhoff plc in twincat 3 environment. I have a array of struct which I want to make persistent. I declared it with...
Replies
0
Views
102
Hi everyone id like to start by saying im not a PLC programmer so my technical terminology is limited. i would like advice on what software is...
Replies
4
Views
287
I`m looking into different solutions for gathering data from different PLC`s (different manufacturers) to a central storage locally or cloud. The...
Replies
12
Views
837
Back
Top Bottom