
RobotArm (Customer) asked a question.
Pack Word function question
I am trying to use the PKW instruction in Productivity 2000.
I am sending the words to JXC91_Output_Data3 which is 16 Bit Unsigned, 1D array
If you see the 2nd attached picture, you can see RUNG#5 that I am trying to send "2" to JXC91_Output_Data3(7). It showed "10" in that rung, I guessed it was binary
If you see RUNG#8, my plan was to send ONE HUNDRED to JXC91_Output_Data3(10), but the PWK shows "68". It is not ONE HUNDRED (decimal) nor the right binary.
It is a bit confusing me. Any clue?
I believe the issue is that it appears you are using static values in the PKW for your position 1 and position 2.
Try using 8 bit integer tags instead and set up the default format as "binary". Then use data view to write a value of 100 into your position 1 tag.
So should I put decimal number of the static binary into PackWord if I really want to use static number?
Thanks
Yes. Just enter 100 into position 1. Like I did in the graphic on rung 2.
Looking at the help file P275 the examples are showing using a static bit pattern. So you would either need to enter a constant of 100 for position 1 or use an 8 bit integer and then load in a value of 100.
I don't know what the intended behavior of the instruction is when dealing with static values but it is doing the following:
Your static value of 1100100 is not interpreted as 100. Your value is being interpreted as decimal 1 million, 100 thousand, 100 trying to be represented as a byte which the maximum number that can be represented is 256. 1100100/256=4297.27. 4297*256=1100032. The 68 is the remainder. You can do as described by the admin or use the PKB (pack bits) instruction to enter a static value as you're trying to do with PKW instruction.
https://accautomation.ca/productivity-1000-series-plc-data-handling-instructions-part-2/
The above post might help you out.
Regards,
Garry
https://accautomation.ca/series/productivity-1000-plc/
If you know the numaric value of what you are wanting to send I would the copy data instruction and just copy it as a numaric value. I could be wrong but it looks like to me you are converting a numaric value to binary to try to convert it back to an unsigned int.