Converting DINT to INT in Logix w/o causing FAL Error

Yep - The L8x series is awesomely fast...but they come with some subtle gotchas.

Effectively, there are things that previous processors would allow you to do (it wasn't really right on your part, but they forgave you of your sins) that the new L8x will not tolerate.

Bit 15 in an FAL is one of those. There are several others that are referenced in the manual for converting to an L8x (yes, an entire 58 page manual).

I suspect that most conversions to an L8x will go off without a hitch. I've had a couple like yours that took some investigation and some program changes to make them work.

The manual also gives a procedure for converting a previous version that is probably different from your normal approach. It has you save the program to an .L5 K file and then convert that. I found that this method flagged out several errors that quietly passed through the other way.
 
Instead of doing a copy, you might try ANDing. I don't have the later processor, so I cant test it. Change the destination to
DINT[Fal_Copy.pos] AND 16#FFFF
 
šŸ™ƒ

That's the kind of catch-all that I was racking my brain for the other day! Actually, that should work within an FAL instruction for mass conversion as well as with brute force for just a few. I'll have to give that a try. Thanks!!!

Oops. I meant 00FFh, since all that you want is the lower bytes...
 
Rootboy, I believe you were actually right the first time. I need to move the lower 16 bits, so it would be 16#0000FFFF.

I suspect the problem is that the internal workings of the FAL take the result of the Expression and place it into a temporary DINT. When it tries to move that temporary DINT into the Destination INT, bit 15 will still cause grief if it is set. This is where what rdrast stated about the valid range of an INT comes into play.

My gut is telling me that I need an AOI that will either force the DINT value into the range of a valid INT or I need to COPY the lower 16 bits from the DINT to the INT.

I've got three key players out for the next few days, so I won't be touching this issue anytime soon. Thanks again, folks, for all of your help!
 
Rootboy, I believe you were actually right the first time. I need to move the lower 16 bits, so it would be 16#0000FFFF.

Hah! Serves me right trying to post while sleepy... :)

That, and I spend waaay too much time in the 8-bit world (I collect retro computers. Amigas, Commodores, MSX's, BBC's, TI-99's, and even an Aquarius or two)
 
Last edited:
Happy Friday folks! It's been a while but I wanted to follow up with my solution. I went with a rather simple fix that uses a copy instruction. This is essentially a bit transfer rather than a value transfer, resolving the issue presented earlier by rdrast.

Step 1: COP or CPS the DINT array data into an INT array
(note: CPS length = FAL length x 2. Make sure this "scratch" array is long enough.) This puts bits 0-15 from each DINT element into the even INT elements & bits 16-31 into the odd INT elements.

Step 2: Use an FAL instruction to pass only those even scratch elements into the INT array that's used by the MSG.

NOTE: any data in bits 16-31 of any DINT tags does not get passed through but this is acceptable for my application. Also notice how TestDint[1] to TestInt[1] gets treated like an unsigned to signed INT conversion.

Ladder Logic
L8x_DintToInt_FAL.JPG

Dint data
L8x_DintToInt_Dints.JPG

Scratch data
L8x_DintToInt_ScratchInts.JPG

Int data
L8x_DintToInt_Ints.JPG
 
Last edited:
Would it not have been easier to just change your DINT arrays back into good-old 16-bit INT arrays and message them to your PLC5's directly ??


To be honest, the existence of the INT data-type is mainly there to maintain compatibility with legacy 16-bit architecture processors.
 
daba,

Agreed. It's fine that the conversion replaced all the INT files with DINT arrays. However, for the minority that are used in messages to/from PLC-5 processors just create new tags that are INT arrays. It solves the whole issue of allowable value range elegantly with no fuss.

For example, if your conversion produced an array N7[0-999] as DINT and the range N7[100-109] is for a message to a PLC-5, you can create a tag N7msg as an INT array to use for the MSG instruction. You can keep the 100-109 range if you like (some plants want the new code to match the PLC-5 code as much as possible). The problems come from transferring data to and from a DINT array. Just don't do it and you avoid the issues.

Also, I think the real problem with the FAL approach was that the data had a value of 32768 in the DINT. This is out of range for an INT and it should fault. How it faults is where the difference between the L7x and L8x occurs, but if it doesn't fault there is no difference. If the data had been expressed as -32768 in the DINT, it should have worked as desired. INT -32768 in decimal is 2#1000_0000_0000_0000. DINT 32768 in decimal is 2#0000_0000_0000_0000_1000_0000_0000_0000 but they are not the same value. If the DINT had been -32768 or 2#1111_1111_1111_1111_1000_0000_0000_0000, then the FAL would have worked as expected. Even though it takes 32 bits to express this value in a DINT, it can be MOVed to an INT successfully.
 
Last edited:
Work Around I have used since Jul 2019

I ran into this issue while converting a PLC-5/80 to L83ES. Like "mellis" was saying, use an indexed MOV to drop the DINT's into the INT's. It is not my favorite approach, but it works. Global 1mSec Timer bumping a Counter for an Index. then MOV your way through the arrays from DINT to INT.

Here is a code example:
XIO(Global_1mSec_Tmr.DN)TON(Global_1mSec_Tmr,?,?);
XIC(Global_1mSec_Tmr.DN)CTU(N7_as_INT_Index_Ctr,?,?);
[XIC(N7_as_INT_Index_Ctr.DN),XIC(B4[5].2)]RES(N7_as_INT_Index_Ctr);
XIO(N7_as_INT_Index_Ctr.DN)MOV(N7[N7_as_INT_Index_Ctr.ACC],N7_as_INT[N7_as_INT_Index_Ctr.ACC]);

I hope that helps! ;-)

N7_as_INT.PNG
 

Similar Topics

Is there anyway to convert a BOOL to a INT (DINT or SINT) in ladder logic. I am working in RSLogix5000 and am attempting to count 4 Discrete...
Replies
3
Views
5,439
I have 3 values. DINT values. They make a product number when assembled together. D: DINT; L: DINT; H: DINT; The variables D, L and H are...
Replies
6
Views
6,594
I need to convert DINT's to INT's to provide MODBUS data registers. What is the best way to do that in a 90-30 / VersaPro project?
Replies
6
Views
14,180
Hello everyone, can anyone help me with covert the STL code to ladder. Iam using plc s71200. A %DB1.DBX33.7 // angel of vaccum...
Replies
2
Views
175
Hello PLCs Forum, I am in a bit of a pickle and was hoping someone could offer me some help. I have a .rss file and just need to see the ladder...
Replies
2
Views
95
Back
Top Bottom