N:x to dint

Join Date
Jan 2013
Location
california
Posts
32
I need to read a set point from an SLC 505 N:x file from a compact logix and convert it to a Dint so I can use that set point and send it to an analog output to a point I/O device net module, also convert a temperature reading from the compact logix device net module and convert the Dint to an Int so I can send to the SLC 505 for display purposes. Any help would be appreciated
 
Do you need help with the Message (MSG) instructions to move the data around, or help with the INT/DINT type conversion, or help with scaling the data to fit the different types of I/O modules ?

In general, the MOV instruction in Allen-Bradley controllers automatically converts data types.

If I MOV SLCData[1] (an INT) to LogixData[1] (a DINT), the datatype is automatically changed.

As long as the INT data is really a Signed Integer, this works fine. If the INT data is really an *un-signed* integer, you have to manually account for the Sign bit.
 
thank you for the reply, yes i need convert an int to a dint for use in my compactlogix program. so your saying set up message instruction from compactlogix to read for example N7:0 and put in into an Int[0] then use a move instruction from the Int[0] to a Dint[0] and it will be converted automaticaly? and i can do the exact opposite if i need to? Dint[1] to int[1]? whats the difference between sighned and unsighned integers? i also read a rockwell example stating to use a FAL instruction to acomplish the conversion? thx again
 
The Wikipedia article on Two's Complement Integers makes my head spin, but the one on Sign Extension is a little simpler.

The highest bit in a 16-bit Signed Integer is the Sign bit. Bits 00-15 are the value.

If the Sign bit is true, the value is Negative. If the Sign bit is false, the value is Positive.

The same is true for 32-bit DINTs, but the Sign bit is Bit 31, while bits 00-30 are the value.

When you use MOV to move a INT value to a DINT and it's a positive value, all the bits move, one-to-one.

When you use MOV to move a INT value to a DINT and it's a negative value, the lower 15 bits move one-to-one but the Sign bit is moved from Bit 15 to Bit 31.

By contrast, the COP instruction in Allen-Bradley controllers copies all the bits exactly, without regard for the datatype and not taking the Sign bit into consideration.
 
When you use MOV to move a INT value to a DINT and it's a negative value, the lower 15 bits move one-to-one but the Sign bit is moved from Bit 15 to Bit 31.

Maybe too picky but when a negative INT is MOVed to a DINT the sign bit is actually moved through all the upper bits so that bits 15 through 31 all become '1'.
 
You are not being too picky, Bernie, you are totally right and I was over-simplifying.

The reason is because of how "two's complement binary" data encoding works, of course.

Have I told the story about the American, the Roman, and the PLC programmer here lately ?
 

Similar Topics

Hi I am being given several fault words (as a DINT) from a Drive that I am receiving into a Compactlogix L33ER controller. I have a small...
Replies
12
Views
1,134
I am working on a project with a Controllogix 5582 processor using v32 firmware where I will be communicating with a Genset using Modbus TCP. It...
Replies
14
Views
923
Hi! It is always said, that DINT is the most performant datatype in AB plcs. I while ago i made a performance test. Several instructions like ADD...
Replies
4
Views
648
Im trying to use a MSG instruction to get the serial numbers of all addon cards and display the serials on a HMI interface. I have the logic done...
Replies
2
Views
546
Just something I think about when choosing data types in Studio 5000. It seems logical, but I've never looked deeply into the question. When...
Replies
12
Views
1,348
Back
Top Bottom