You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old February 12th, 2019, 11:25 AM   #1
Sanderson4401
Member
Canada

Sanderson4401 is offline
 
Join Date: Jun 2018
Location: Canada
Posts: 4
RSlogix 500: Combining and seperating 16 and 32 bit registers for Modbus

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!
  Reply With Quote
Old February 12th, 2019, 11:37 AM   #2
mellis
Member
United States

mellis is offline
 
Join Date: Nov 2004
Location: Cincinnati, Ohio
Posts: 821
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.
  Reply With Quote
Old February 12th, 2019, 12:18 PM   #3
Sanderson4401
Member
Canada

Sanderson4401 is offline
 
Join Date: Jun 2018
Location: Canada
Posts: 4
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?
  Reply With Quote
Old February 12th, 2019, 01:01 PM   #4
OkiePC
Lifetime Supporting Member
United States

OkiePC is offline
 
OkiePC's Avatar
 
Join Date: Mar 2005
Location: ENE of Nowhere Oklahoma
Posts: 10,192
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.
__________________
It's not all the variables I am most concerned with, it's the undiscovered constants.

Last edited by OkiePC; February 12th, 2019 at 01:12 PM.
  Reply With Quote
Old February 12th, 2019, 01:33 PM   #5
lfe
Member
France

lfe is offline
 
Join Date: Jun 2007
Location: Barcelona
Posts: 422
Maybe you have an endianess problem, due Modbus does not define in what order the 16bit words are sent when 32bit types are transmitted
__________________
Suppanel HMI
  Reply With Quote
Old February 12th, 2019, 04:41 PM   #6
Peter Nachtwey
Member
United States

Peter Nachtwey is offline
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: Vancouver, WA, US
Posts: 6,896
Quote:
Originally Posted by lfe View Post
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.
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon
  Reply With Quote
Old February 12th, 2019, 05:09 PM   #7
OkiePC
Lifetime Supporting Member
United States

OkiePC is offline
 
OkiePC's Avatar
 
Join Date: Mar 2005
Location: ENE of Nowhere Oklahoma
Posts: 10,192
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.
__________________
It's not all the variables I am most concerned with, it's the undiscovered constants.
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 05:27 PM.


.