[chbot] HEX and ANSII ATMEGA and Delphi

Marshland Engineering marshland at marshland.co.nz
Sat Oct 24 23:06:19 BST 2020


After a few days of mulling it over I have come up with the following
thoughts.

If I send the raw TCNT1 data in HEX, it is the shortest data set. 2 problems,
Delphi has to convert the hex into some human readable form to work with it,
ie hex to integer, and, I cant use special characters for data separation eg
'.'

If I convert the TCNT1 into a hex string, then Delphi is happy. I can use
special characters etc and sending 'FFFF' is shorter than '65535'.  However a
bit of work for no real advantage.

Lastly, just send the ascii equivalent of the integer, easiest and have this
working. I do have one problem with itoa. When the value is over 32768, it
starts returning -ve value strings. Done some reading on this and others have
found similar but as yet, no solution. This was actually the original reason
why I started looking at sending the hex. 

I have also realized that my c knowledge a bit iffy with regards to int, char
etc. Say for example, I read an initial value on the counter T1 and then a
second value T2. The TCNT1 value is a 16 bit binary or 4 byte word. How do I
get T2-T1 with the result in hex ? 

Cheers Wallace




More information about the Chchrobotics mailing list