Serial 8-servo controller

17 is 23 expressed in base 16 (and Dec 56=Hex 38, and Dec 128=Hex 80). Hexadecimal numbers (0x17) are numbers in base 16, as opposed to base 10 like we’re all used to. The letters A through F are used for the extra six digits (unfortunately not apparent in any of the numbers mentioned so far). If we were all born with eight fingers on each hand, we’d all probably be counting in Hex! Number systems based on powers of two are common in computer applications, since they lend themselves to digital representation.

To illustrate, lets do a little counting in binary (base 2), octal (base 8), decimal (base 10), and hexidecimal (base 16).

Binary, Octal, Decimal, Hexidecimal:
0, 0, 0, 0
1, 1, 1, 1
10, 2, 2, 2
11, 3, 3, 3
100, 4, 4, 4
101, 5, 5, 5
110, 6, 6, 6
111, 7, 7, 7
1000, 10, 8, 8
1001, 11, 9, 9
1010, 12, 10, A
1011, 13, 11, B
1100, 14, 12, C
1101, 15, 13, D
1110, 16, 14, E
1111, 17, 15, F
10000, 20, 16, 10
10001, 21, 17, 11
10010, 22, 18, 12
10011, 23, 19, 13
10100, 24, 20, 14
10101, 25, 21, 15
10110, 26, 22, 16
10111, 27, 23, 17
11000, 30, 24, 18
11001, 31, 25, 19
11010, 32, 26, 1A
11011, 33, 27, 1B
11100, 34, 28, 1C
11101, 35, 29, 1D
11110, 36, 30, 1E
11111, 37, 31, 1F
100000, 40, 32, 20

If you use a Windows computer, load up the calculator, and under the “view” menu select “scientific”. You should now have a set of buttons that let you switch the displayed number between Hex, Dec, Oct, and Bin. Play around a little! You’re all set when you get this joke:

Why did the programmer wear a scary costume to the Christmas party? Because he confused Dec 25 with Oct 31! Hahahaha!

Anyway, you can generally enter numbers in whatever base you like in your code, and the compiler will convert it all to binary anyway. So, you can type in MAX_ANGLE=4350, or MAX_ANGLE=0x10FE. The 0x just lets the compiler know you’re talking in hex now, in either case it will internally represent the number as 1000011111110 anyway.

For an answer to your second question, I think I’ve got a good explanation of how to calculate the Pololu mode absolute position command numbers this thread. Let me know if anything is unclear!

-Adam