RSLogix question - combining data types and converting from hex to SP Float

opmal7

Member
Join Date
Dec 2014
Location
Moline
Posts
35
I have a 3-axis sensor that I'm working on integrating with a Micrologic PLC. The sensor has a RS-422 output and I'm using an RTA Automation PLC to ASCII device to communicate between the sensor and the PLC.

The sensor uses messages made up of hex data of the format SOH, Msg ID, #of bytes in message, Chksum, data1, data2... Because the RTA device translates the hex to ASCII, I have it set to pass the messages as an array of integers. So, I have an array of integers configured to read as hex, and in RSlogix I can see the array containing hex values from the RS-422 output of my sensor.

I need to combine two array values and display the result as a single SP Float value. For example, N1:3 contains 3E02, and N1:4 contains 8621. The SP float should be 3E028621, and convert to the equivilant decimal (0.1275, I believe). I'm more of a systems integrator, rather than PLC programmer, so does anyone know what sort of instructions I could use in RsLogix to work with this data and display the result I want? Thanks, and let me know if you've got any questions or need additional info.
 
Last edited:
Use a COP instruction to copy the two integers to a float table. add a COP instruction then hit F1 for details on it.

[Further troubleshooting]
you may need to do a word swap or byte swap (SWP) depending on what sort of endians you have.

I don't think there is a word swap function, so you will have to, for example, move (MOV) your N7:3 address to N7:5, then COP N7:4 and N7:5 to F9:0.
 
Use a COP instruction to copy the two integers to a float table. add a COP instruction then hit F1 for details on it.

[Further troubleshooting]
you may need to do a word swap or byte swap (SWP) depending on what sort of endians you have.

I don't think there is a word swap function, so you will have to, for example, move (MOV) your N7:3 address to N7:5, then COP N7:4 and N7:5 to F9:0.

Thank you for the info! I don't think I'll need to swap the order of any data but good to know just in case. Does it matter if one of the hex integers begins with 0? Lets say N1:5 contains 0AF7 (which displays as AF7 in RsLogix) and N1:6 contains 0001 (which just displays as 1). If I use the COP instruction, will it combine to 0AF70001?

Also, is it possible to combine the first/last 2 digits of the integer array values. Lets say in the above example I also have N1:7 which contains 1111, but the actual SP float value I'm looking for starts halfway through N1:5 and ends halfway through N1:7. So, my SP float I'm looking for is F7000111. Any idea if that sort of thing is possible?
 
Does it matter if one of the hex integers begins with 0?
No
Lets say N1:5 contains 0AF7 (which displays as AF7 in RsLogix) and N1:6 contains 0001 (which just displays as 1). If I use the COP instruction, will it combine to 0AF70001?
Yes

Also, is it possible to combine the first/last 2 digits of the integer array values. Lets say in the above example I also have N1:7 which contains 1111, but the actual SP float value I'm looking for starts halfway through N1:5 and ends halfway through N1:7. So, my SP float I'm looking for is F7000111. Any idea if that sort of thing is possible?

Incase you don't have it already, there is the instruction set reference manuals available form ab.com/literature
It varies depending on which MicroLogix you are using, but search for Micrologix reference manual.

I would want to use a BSL instruction, but you would need eight of them, or jump logic which is hard to follow.

in your case, I would use the following instructions in order, using N7:100 to N7:105 as temp storage.
Code:
COP N7:5 N7:100 3 //copies three words starting at N7:5 to N7:100
SWP N7:100 3 //swaps the high byte and low byte in each of N7:100,101,102
MVM N7:100 FF00h N7:103 //Masked moves to move each byte to it's location
MVM N7:101 00FFh N7:103
MVM N7:101 FF00h N7:104
MVM N7:102 00FFh N7:104
COP N7:103 F9:1 1 //copy the finalised bytes to a float
 
Use a COP instruction to copy the two integers to a float table. add a COP instruction then hit F1 for details on it.

[Further troubleshooting]
you may need to do a word swap or byte swap (SWP) depending on what sort of endians you have.

I don't think there is a word swap function, so you will have to, for example, move (MOV) your N7:3 address to N7:5, then COP N7:4 and N7:5 to F9:0.

I'm trying to use the COP instruction to combine the two integers to a single float, but the COP instruction only has 1 source and 1 destination. I'm getting the error "Operand sizes do not match" when I try to download the program to the PLC. Any ideas?
 

Similar Topics

Oh, I hope someone can help! I have one little problem holding me up from studying this weekend. I'm using Rslogix micro starter light, it's a...
Replies
7
Views
2,981
So I have a PID loop on an 1756-L61 running V17 software just for background. Also the PID PV is a pressure transmitter and the CV is speed sent...
Replies
1
Views
892
Hello Please Help, I want to use a FSC instruction that will scan 20 DINT arrays. If the arrays are greater than 1000 display the value. How do I...
Replies
4
Views
1,755
Hey all, I just joined today. Not sure if this question is in the right place or if anyone has asked it before. I am monitoring a machine from...
Replies
2
Views
1,435
Note, I have NO experience with RSLogix products. Never done anything beyond installing the software for others. Please forgive me for my...
Replies
9
Views
4,608
Back
Top Bottom