Convert 3) SINT to 1)DINT

Bullzi

Lifetime Supporting Member
Join Date
Jun 2012
Location
Colorado
Posts
1,530
Happy Monday Everyone,

I am trying to read the Assembly Number from a Flow Meter via Hart. It is coming back to me as 3 USINT values. I have these placed in SINT tags. How can I convert these 3 SINT values into 1 DINT value so I can read the number?

Thanks for the help!!
 
Are the SINT's in an array that has more than just the 3 elements in it?

If it's only 3 elements, then I think you can COP SINT[0] to DINT with a length of 1.

If there is more in the array than just the 3 SINT's, then you might have to use 3 BTD's or something like that.

Let's say your array of SINT's is a length of 10 and your data is in 0-2. Copying into a DINT will copy 4 bytes (because a DINT is 4 bytes) so it will copy [0], [1], [2] and [3].
 
I found a solution.
I took the 3 array elements and COP SINT[0] to DINT1
Then SWPB DINT1 to DINT2
Then BTD DINT2 to DINT3 to move the bit pattern so the LSB is in the bit 0 position.

What a PITA!! The Bit pattern coming back from the device is reversed is there a way to reverse a SINT bit pattern. SWPB doesn't work with SINT data types.

Thanks for the help!!
 
This is one of the great opportunities to use an Add-On Instruction and just brute-force the moves, bit by bit, with pairs of XIC and OTE instructions.
 

Similar Topics

Hi guys I have a barcode scannes which gives me some numbers (SINT) that I want to convert into ASCII, so that I can see that ASCII char insted...
Replies
6
Views
2,802
Hi all! looking for help converting an 8 bit word SINT tag into decimal. I have an IFM SBN246 flow sensor wired in my controller (L310ER) and it...
Replies
4
Views
2,179
Hey guys, I'm trying to get a number out of a INT and move it to a SINT. Source: 2#0000_0001_1100_0010 Dest.: 2#0000_0000 Tried to...
Replies
5
Views
1,913
This pertains to RSLOGIX 5000. I have a machine that sends me back a single ASCII character in a SINT and I need to convert it into its decimal...
Replies
2
Views
2,371
Hello all, I'm currently working on a servo motor linear positioning system (ball screw). I'm all set up regarding communication between my HMI...
Replies
1
Views
99
Back
Top Bottom