Conversions
whitelancer
Posts: 23
To anyone that can help,
I am trying to take a decimal number and turn it into a hexadecimal number that i can send to my servo controller to move the servo motors. The process needs to take a number (such as 300) and then convert it to binary from. Then 2 data bytes need to be created with Data 2 containing the lower 7 bits, and Data 1 containing the upper bits as descirbed in this link (http://www.pololu.com/products/pololu/0207/ssc03a_guide.pdf). I was hoping if there was a program already created for conversion purposes since I don't think the Javelin has it embedded or if anyone could help me out.
Thanks!
I am trying to take a decimal number and turn it into a hexadecimal number that i can send to my servo controller to move the servo motors. The process needs to take a number (such as 300) and then convert it to binary from. Then 2 data bytes need to be created with Data 2 containing the lower 7 bits, and Data 1 containing the upper bits as descirbed in this link (http://www.pololu.com/products/pololu/0207/ssc03a_guide.pdf). I was hoping if there was a program already created for conversion purposes since I don't think the Javelin has it embedded or if anyone could help me out.
Thanks!
Comments
int value = 300;
then to convert into 2 7bit databytes:
int data2 = value&0x7F; //data2 holds lower 7 bits
int data1 = (value>>>7)&0x01; //data1 bit0 holds MSB
regards peter
Thanks!
Only that all databytes must have bit7 cleared (pololu mode).
Please give an example of your data and into what you
would like it converted (in bytes).
regards peter