Did you look at the Set Target (Compact/Pololu protocol) command in the User’s Guide? There is an example there about how to calculate the low and high bits. The example is in C, but many languages have a similar syntax.
Yes, I did look at the manual but it’s not really helpful.
For example, if we want to set the target of servo 0 to 1500 µs, we could send the following byte sequence:
in decimal: 132, 0, 112, 46
I just need to know how to calculate the 112/46 digits, that part I don’t really understand.
In the manual for c# it shows:
serialBytes[2] = target & 0x7F; // Second byte holds the lower 7 bits of target.
serialBytes[3] = (target >> 7) & 0x7F; // Third data byte holds the bits 7-13 of target.
0x7f = 127 in decimal, but I don’t understand the rest.
I’m not an engineer or anything, just an amateur programmer
I can’t tell you how to write the VB equivalents of the C operators in the manual, but it shouldn’t be hard to find a VB reference online that has such information.
The whole point of those computations is to break a 14-bit number up into two 7-bit numbers, each of which can be sent as a separate data byte in your serial command packet. To do this, you need to set the first data byte equal to the lowest seven bits of your number:
serialBytes[2] = target & 0x7F;
In binary, 0x7F is 01111111. Bitwise-ANDing (&) this value with target preserves the low seven bits while clearing all the others, since 1 & x = x while 0 & x = 0.
To get the appropriate bits in to the second data byte, we need to bit-shift (>>) our target appropriately and once again mask the desired bits with a bitwise AND:
serialBytes[3] = (target >> 7) & 0x7F;
By the way, please make sure you specify which product you are using, especially when we have multiple similar products with different protocols. I know you said it in another thread, but it’s helpful to see it directly in the thread one is responding to.