Is there a parameter that stops the last bit from being a sign bit?
User input groups
-
Noob1982 -
March 22, 2019 at 1:29 AM -
Thread is marked as Resolved.
-
-
you can use the function Roll left or right in the ladder on the group input .
-
directly, no. You can move the value of the input group to an M register and then shift the M register left or right and put the result in an output group.
-
I'll probably just get my input numbers from the register by grouping them in the ladder. I just can't get it to read right when all the bits are turned on. If I turn them all on in one group I should get 255 but instead I get -1.
-
Sounds like you have parity turned on. What controller are you using?
-
It's the YRC1000 controller. This is a new feature that allows you to set up your own custom I/O groups. So I can start with saying I want the group to start at input 1 and make it up to 32 bits long. Problem with it right now is I can't use the full group only up to the last bit. Like I said before if I look at all 8 in a group instead of getting 255 I get -1. I understand it's a sign bit for positive or negative but it's stupid to have it the way it is because I can't use it if I turn on that last bit. I've asked Motoman about it but I haven't got an answer yet. As of right now I've mapped them to a group of inputs that I'll never use do I can make the 9 bits long allowing me to use the full group of 8.
-
I had a chance to play with a YRC and the User group function. The robot I was on only had 8 inputs attached to it so I can only say what I saw and what I did.
First of all I set a user group to start at input one and end at input 8. I can see the same thing as Noob1982, when all the inputs are on the group value is -1. If I only turned on input 8 I got a value of -128. I next set the group to end at 7 and got the same result, if all the inputs in a group are on the value is -1 and if only the last input is on I get a value of -64. Don't know why but I will ask around and see what can be fixed.
The next test I did was to set the group to end one value higher than what I had, so the group started at 1 and ended at 9. This seemed to make it happy. I got 255 when all the bits are on just like I should.
Next week (time permitting) I will try to make two and then three small groups to see what happens.
-
To somewhat expanded on this and explain why Doc is seeing what he is seeing.
Using Doc's example of a 8-bit user group, we are used to I/O as being only positive, 2 to the 8 power, or 0 to 255. A user group can be negative or positive values. To relate this to an I variable, 2 to the 16 power has 65536 combinations. If it were unsigned the values could only go 0 to 65535. If it is signed, like an I variable, then the values are split even positive and negative, -32768 to 32767.
Using an User Group of 8 bits has 256 combinations. It is signed. So the acceptable values are -128 to 127. The most significant bit denotes a positive or negative value.
Back to Doc's example:
When all the switches are on, switch 8 is saying the value is negative. A negative value will show in two's complement. This equates to -1 in two's complement. With only switch 8 on, still saying the value is negative, the twos complement value is -128.
Decimal Value Binary Twos Complement
0 0000 0000
1 0000 0001
2 0000 0010
126 0111 1110
127 0111 1111
-128 1000 0000 1000 0000
-127 1000 0001 0111 1110
-2 1111 1110 0000 0010
-1 1111 1111 0000 0001To get the two's complement negative notation of a value, you write out the number in binary. You then invert the digits, and add one to the result.
-
That's a great explanation. Thanks very much for taking your time to post it.
-
My message above assumes no parity. It's a different ballgame with parity as another bit in the group becomes the parity bit and lessens the values the group can be.