hashmi.mohammad
Member
Good Morning,
I'm using RS Logix 5000 to program an Allen-Bradley 1769-QBFC1B Version 20.12 and want to use the Byte Swap Instruction (SWPB), but not having much luck with it. I've attached a picture of the logic I've written for it and trying to debug it.
Currently, I have a scanner that reads a badge and takes a 6 digit index number and stores it into the Cognex_Scanner:I.ResultData[0] tag (SINT). Then I use the COP instruction to move it into Index_Number_Self_Check_Part_1.DATA[0] (STRING).
Then I convert the String to a DINT using the STOD instruction. So the value goes from 054609 to 54609. I actually need a way to keep the leading 0 as well. So I need it to read 054609 in the DINT tag also.
Finally, I apply the SWPB instruction on the DINT tag using order mode HIGH/LOW or 2. Ultimately, I want to go from 054609 to 506490, but it reads 20949, which makes no sense to me. The index_number_self_check_part_1_byte_swap that reads 20949 is also a DINT.
Any help debugging this code would surely be appreciated. Thanks.
P.S. And yes, I am toggling the input bits, so first I toggle 'Badge Scan', then I toggle "always_off_bit", and then I toggle "test".
I'm using RS Logix 5000 to program an Allen-Bradley 1769-QBFC1B Version 20.12 and want to use the Byte Swap Instruction (SWPB), but not having much luck with it. I've attached a picture of the logic I've written for it and trying to debug it.
Currently, I have a scanner that reads a badge and takes a 6 digit index number and stores it into the Cognex_Scanner:I.ResultData[0] tag (SINT). Then I use the COP instruction to move it into Index_Number_Self_Check_Part_1.DATA[0] (STRING).
Then I convert the String to a DINT using the STOD instruction. So the value goes from 054609 to 54609. I actually need a way to keep the leading 0 as well. So I need it to read 054609 in the DINT tag also.
Finally, I apply the SWPB instruction on the DINT tag using order mode HIGH/LOW or 2. Ultimately, I want to go from 054609 to 506490, but it reads 20949, which makes no sense to me. The index_number_self_check_part_1_byte_swap that reads 20949 is also a DINT.
Any help debugging this code would surely be appreciated. Thanks.
P.S. And yes, I am toggling the input bits, so first I toggle 'Badge Scan', then I toggle "always_off_bit", and then I toggle "test".