kjacoby
Member
Good afternoon. I am working on setting up a position shift through a PV on a motoman robot. I already have a working solution, but I am trying to find out if there is a cleaner way.
I am currently taking 4 integers from a PV.
Robot 1 shift X
Robot 2 shift X
Robot 1 shift Y
Robot 2 shift Y
I am sending the values, 0-13 to the Slc500 5/05.
I am then multiplying the integers to shift them left so I can do a masked move to my output table.
So to shift 3 of the offsets I multiply by 16, 256, and 4096. I then have a MVM masking so I can copy the integer value to the correct Group Input on the robot.
The problem comes with my Integer value having a max of 32767. If I multiply my largest 4 bit value of 15 by 4096, I get 61440. Since the last bit is a sign, my integer file cannot accept that value. I have tried several different values, and have not been able to come up with an solution, that will take the first 4 bits, and place them to the last 4.
The first 3 offsets work perfectly. This last on was just a pain. The way I got around this is to multiply by 2048, to get my 1 away, and then perform a BSL to shift it that last spot, without an arithmetic overflow.
Is there a cleaner way to get this? If I had a DINT or a long available, I would have been done a lot sooner.
Thanks,
Kenneth
I am currently taking 4 integers from a PV.
Robot 1 shift X
Robot 2 shift X
Robot 1 shift Y
Robot 2 shift Y
I am sending the values, 0-13 to the Slc500 5/05.
I am then multiplying the integers to shift them left so I can do a masked move to my output table.
So to shift 3 of the offsets I multiply by 16, 256, and 4096. I then have a MVM masking so I can copy the integer value to the correct Group Input on the robot.
The problem comes with my Integer value having a max of 32767. If I multiply my largest 4 bit value of 15 by 4096, I get 61440. Since the last bit is a sign, my integer file cannot accept that value. I have tried several different values, and have not been able to come up with an solution, that will take the first 4 bits, and place them to the last 4.
The first 3 offsets work perfectly. This last on was just a pain. The way I got around this is to multiply by 2048, to get my 1 away, and then perform a BSL to shift it that last spot, without an arithmetic overflow.
Is there a cleaner way to get this? If I had a DINT or a long available, I would have been done a lot sooner.
Thanks,
Kenneth