View previous topic :: View next topic |
Author |
Message |
talhahs
Joined: 14 Oct 2010 Posts: 14
|
single byte command |
Posted: Tue Dec 07, 2010 10:12 am |
|
|
Hi all, I have to send single byte commands to sabertooth motor driver IC. Kindly tell me the difference between the two commands below:
and
Which one is the better? |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Tue Dec 07, 2010 10:31 am |
|
|
Only the first sends a single byte. The second sends three: 0x31, 0x32, 0x37. |
|
|
talhahs
Joined: 14 Oct 2010 Posts: 14
|
|
Posted: Tue Dec 07, 2010 10:33 am |
|
|
Thanks a lot bro!
Well can you please explain how did you come up with [0x31, 0x32, 0x37] for 127 ? |
|
|
gpsmikey
Joined: 16 Nov 2010 Posts: 588 Location: Kirkland, WA
|
|
Posted: Tue Dec 07, 2010 11:18 am |
|
|
The ASCII values for "1"= 0x31, "2"=0x32 and "7"=0x37 - three distinct ascii characters. I just recently purchased the new version of the compiler and in with the manual was a handy plastic guide with "C syntax tables" on one side and an ASCII chart on the other side. Actually a handy guide :-) Anyway, in the one case, you are sending a byte with the decimal value of 127 (0xFF) and in the second case (the printf()) you are sending a string of 3 characters 1,2 and 7. Hope that helps
mikey _________________ mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3 |
|
|
|