[chbot] HEX and ANSII ATMEGA and Delphi

Andrew Starr ajstarr at gmail.com
Sat Oct 24 23:13:44 BST 2020


You need to use an unsigned int, assuming your ints are 16 bits. You also
need to be sure T2 is always >= T1, otherwise you'll have underflow in your
subtraction

On Sun, Oct 25, 2020, 11:06 AM Marshland Engineering <
marshland at marshland.co.nz> wrote:

> 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
>
>
> _______________________________________________
> Chchrobotics mailing list Chchrobotics at lists.ourshack.com
> https://lists.ourshack.com/mailman/listinfo/chchrobotics
> Mail Archives: http://lists.ourshack.com/pipermail/chchrobotics/
> Meetings usually 3rd Monday each month. See http://kiwibots.org for
> venue, directions and dates.
> When replying, please edit your Subject line to reflect new subjects.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ourshack.com/pipermail/chchrobotics/attachments/20201025/23520f03/attachment.html>


More information about the Chchrobotics mailing list