Modbus with CompactLogix L32E using ModbusMaster.acd

Marie1982

Member
Join Date
Feb 2007
Location
House
Posts
121
Hi,

I'm trying to communicate between a CompactLogix L32E and a power transmitter using Modbus RTU. I use a 1761-NET-AIC. Has anyone ever used the sample file ModbusMaster.acd? I read another thread about this topic but it didn't answer my question.

I want to know how to manage de commands send to the slave. I know I can write up to 40 commands and that if I do, the PLC will execute them one after the other. What I want to do is verify if my command has successfully been sent. In the document (CIG-AP129A-EN-P page 32), they give four steps to do that. The second one is send the command to the Modbus slave... How do I control that? Just by putting ModCommand[].enable to 1?

Also, what happens if I have multiple read or write commands to do? If I do multiple reads, where do the data go? I see only one tag where the program sends data: Mod_Data_InpReg3. How do I manage that?

Thank you

Marie
 
Setting the Mod_Commands[0].Enable bit to a 1 will trigger that command to start polling.

Mod_Commands[0].FunctionCode controls what modbus function code is used and will determine which array the data goes into.

If you set Mod_Commands[0].FunctionCode to a 3, it will perform a 4x register read and the data will be placed in Mod_DataHoldReg4 data array. The array element it ends up in will depend on what you have configured in Mod_Commands[0].AddressOffsetinMaster and Mod_Commands[0].StartingAddress. They are basically added together in the program so you have to be carefull on how those are set up.
 
I can't remember exactly how the offset functioned, that was well over a year ago. The best of my memory was if you wanted to read 43051 and place it in data array 200 you needed the following parameters. Mod_Commands[4].StartingAddress = 3050, Mod_Commands[4].AddressOffsetinMaster = -2850. This might be off by a register so double check the data once you have it working.
 
That manual is pretty interesting, it doesn't tell you what types the registers really are. The modbus protocol states that 3x registers are read only and 4x registers are read/write. I would try looking at the r/w column and use a 3x read (FC-4) for r and a 4x read (FC-3) for r/w registers.
 
I have this document, but there is no explanation about how to use the code, only how to add it in the project. The only example doesn't answer my questions.
 
I have this document, but there is no explanation about how to use the code, only how to add it in the project. The only example doesn't answer my questions.

Documentation explanation is good , you have to try the program & make feel of it
 
Hi,

I have received all my components and am trying to communicate.

I am trying to read the system type of my power transmitter. It is located at the address 130. Since this address is a R/W, I guess it is in the 4xxxx registers.

Here is how I configured my Modbus command:

ModbusCommand[0].Enable = 0
ModbusCommand[0].EchoReceived = 0
ModbusCommand[0].ScanNumber = 0
ModbusCommand[0].OffsetAddress = 0
ModbusCommand[0].SlaveAddress = 1
ModbusCommand[0].FunctionCode = 4
ModbusCommand[0].StartingAddress = 130
ModbusCommand[0].NumberOfPoints = 1

When I enter those parameters, I have 0 both in
Mod_Data_InpReg3[130] and Mod_DataHoldReg4[130]

When I turn the enable bit to 1, EchoReceived turns to 1 and I get 100 in Mod_Data_InpReg3[130] and 0 in Mod_DataHoldReg4[130]. However, in the controller, I set the system type to 10, 40 and 42 and I got the same result.

How do I interpret that???

Thank you
 
I tried command code 3 and I got the 100 in the Mod_DataHoldReg4[130] register instead of the Mod_Data_InpReg3[130].

What is the difference between code 3 and code 4???
 
Modbus function code 3 is a 4x register read and function code 4 is a 3x register read. Here is a brief list of common function codes.

Common Modbus function codesCodeDescription01Read coil status02Read input status03Read holding registers04Read input registers05Force single coil06Preset single register07Read exception status15Force multiple coils16Preset multiple registers17Report slave ID
 

Similar Topics

Hey guys, A couple of quick questions but first a layout of what I'm working with. Compactlogix 1769-L37erm controller. The current system we...
Replies
2
Views
1,232
Going to preface this by saying I am a complete modbus newbie, so apologies if my terminology is off... We have a Prosoft PLX31-EIP-MBTCP modbus...
Replies
3
Views
1,329
Client's Customer has an L64 v20 with MCI56-MCM Modbus in 2 slots. Client has an 1769-L16ER-BB1B v20 that needs to communicate with the L64 via...
Replies
3
Views
2,297
Hi Everyone Ive got an AB 1769-L33ER (i read its modbus compatible) and im looking to communicate with a Chinese multi controller via Modbus. Ive...
Replies
6
Views
2,276
Dear All, I need help to sort out some issue i am facing , i wanted to read the data from the device that has modbus communication protocol . and...
Replies
7
Views
4,316
Back
Top Bottom