RSlogix 500: Combining and seperating 16 and 32 bit registers for Modbus

Sanderson4401

Member
Join Date
Jun 2018
Location
Canada
Posts
4
I'm having trouble preparing some data for use with Modbus. I have to send and receive each parameter over 2 16 bit registers and the I can't find an easy way to combine and separate 32 bit registers. I believe I can do it just with math instructions but it seems like there should be a better way. Anyone have any experience with situations like this?

I'm using RSlogix 500 with a ML1400 PLC and I'm communicating with a Littelfuse MP8000.

Thanks!
 
The best way is to use the COP instruction.
COP #F8:0 #N7:0 2 will take one FLOAT and copy it to two INTs.
COP #N7:0 #F8:0 1 will take two INTS and copy it into one FLOAT.

The key here is that COP is a straight bit copy, it does not interpret the data at all.
 
Thanks! I might be doing something wrong though, when I try to verify the following ( COP #F8:2 #N7:6 2 ) I get an operand sizes do not match error. Any idea what might be causing that?
 
For whatever reason, in a Micrologix they came up with a new instruction for copying data between types with different data structure. Use CPW instead of COP. With CPW the length is based on source element size, not the destination as with COP.
 
Last edited:
Maybe you have an endianess problem, due Modbus does not define in what order the 16bit words are sent when 32bit types are transmitted
 
Maybe you have an endianess problem, due Modbus does not define in what order the 16bit words are sent when 32bit types are transmitted
This is true and insane. However, we use Modicon PLCs as the standard.
When sending a 32 bit value, modicon sends the low word first and the high word second but within each word the high byte is sent first and the low byte is sent second. This is screwy. When ever we get into p!$$!ng contests with other companies we ask if they can correctly send and receive 32 bit values from a Modicon PLC. If they can then there is no problem.
 
The Endianness is a separate issue from just getting the bits copied in this particular application. If the words are out of order and the CPW instruction works, the result will be jacked up, and THEN he will have to do word swapping to fix it. It is even possible to get a result that generates an illegal bit representation of a floating point number...then you get the beloved Math Overflow error.
 

Similar Topics

Hello, Haven't been on in a while. I need to generate a bit level pdf of the I/O for RSLogix 500. I can generate a report but it just shows the...
Replies
1
Views
117
I would like to copy register N61:131 thru N61:147 into ST252:0 I keep failing What happens is I copy into ST252:0,1, 2 etc. What am i missing...
Replies
18
Views
493
I'm trying to fix a mess of code on an older machine that's running a Micrologix 1400 and an RS232 ASCII barcode scanner. The previous guy had...
Replies
3
Views
310
I'm not super familiar with the Micrologix line of processors, but I am pretty familiar with RSLogix 500. I'm trying to simply copy a string to...
Replies
4
Views
265
I have been using RSLogix 500 version 9 for a long time now. I am about to need to move to something else Rockwell related to cover the...
Replies
8
Views
911
Back
Top Bottom