Greetings. I have a serial servo controller that accepts numbers between 500 and 5500 to control the high pulse sent to the servos. I want to use arithmetic to generate words in that range, which won't be a big deal. However, the word that is sent to the servo controller is in the form of two bytes where bit 7 (MSB) of each must be 0. The controller concatenates the 7 bit bytes to get the position word. Since the picaxe's words are 2 8-bit bytes, generating a word bigger than 127 has a chance to make the LSB's msb 1, which kills the controller, i need a way to shift all bits past bit 6 to the "left" one space and make bit 7 a 0.
for example, we have the picaxe generate a 0d5000 (represented in binary):
00010011 10001000
Notice how bit 7 is a 1... this cannot do
what i need is for a 0 to be shoved into bit 7, pushing the displaced bits to the left:
00100111 00001000
...the same number(as seen by the servo controller, as it ignores the msb of each byte)
I could probably bruteforce this, but i am on a Picaxe 18 with only around 50 bytes of prog. space left. If anyone knows of an efficient way of shifting those bits, any help would be greatly appreciated.
Thanks,
travis75
for example, we have the picaxe generate a 0d5000 (represented in binary):
00010011 10001000
Notice how bit 7 is a 1... this cannot do
what i need is for a 0 to be shoved into bit 7, pushing the displaced bits to the left:
00100111 00001000
...the same number(as seen by the servo controller, as it ignores the msb of each byte)
I could probably bruteforce this, but i am on a Picaxe 18 with only around 50 bytes of prog. space left. If anyone knows of an efficient way of shifting those bits, any help would be greatly appreciated.
Thanks,
travis75