Dint to Int and Int(F)

Orn Jonsson

Member
Join Date
Apr 2002
Location
Boise Idaho
Posts
125
Hi all.
Transferring data back and forth between Compact Logic and AB PowerFlex 40p. (Ethernet IP).

All parameters in the Drive are INT. Commanded position is INT (High) and INT (low). Low is for 2 decimals.

I would like to enter my position data via the touch screen as DINT (2 assumed decimals).
For example "123.45" would have to split up in to 123 in INT(high)and 45 needs to go to INT(low).

How do I isolate 123 from 45 and place in two INT? (de-concatenate)?
:sleep:
Thanks
 
Last edited:
What about rounding daba?

Do this:
Code:
iLow := OrigVal MOD 100;
iHigh := (OrigVal - tInt) / 100;
ps. i dont know how compactlogix handles integer division rounding, dabas could work too.
 
DIV, with all arguments of an integer type (DINT, INT, or INT), will perform integer maths, and will truncate the result -

so...
45650 DIV 100 = 456

You will get the same answer if your divisor is a REAL (tag or literate)...
45650 DIV 100.0 = 456

BUT and a big BUT, only when the number is even.
Look at this one...
45750 DIV 100.0 = 458Logix5000 systems use the "Round-to-Even" algorithm, where .5 results go up OR down, to the nearest even number.
 
Last edited:
MOD with REAL

Thanks a lot for the info "daba" and "Turpo". I had no Idea that MOD existed. Now that I read up on things a bit I am leaning towards using:
Enter data in REAL with two decimals on the touch screen, use TRN to truncate and put result in INT high. Then Do MOD on same REAL number and put result in INT low.
Will test this on site in a an hour.
🍻
 

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,135
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
926
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
650
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
549
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,354
Back
Top Bottom