Lookup command and hex numbers?
mmccarty
Posts: 3
I'm pulling time and date from a RTC and trying to use the lookup command to store times for daily timed events, but I am running into problem with the dates stored as hex numbers. When I use the "day" variable as the index for the lookup command it counts over by the decimal equivalent. (29th day of the month counts over 41 places instead of 29). Am I missing something simple here or do I need to convert the hex day into a decimal index variable beforehand? How?
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
· -- Carl, nn5i@arrl.net
indx = (date.NIB1 * 10) + date.NIB0
The next question:
I have times stored in a table in a four digit format (1545, 1600, 1830). What would the best way to convert into separate hours and minutes variables to compare to the RTC for alarm events?
-Mac, KB9HV
Personally, I would do your table in BCD as HEX rather decimal, then you can just deal with the nibs:
But you could leave it BCD especially if you are using an RTC that is also BCD -- you can just compare the "read" word and an assembled BCD word from the RTC -- greater than, less than, equal to, etc. and it will work just fine as Hex words. If you need to compare just hours or just mins, you could use the high and low bytes.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
offtime is the times in the lookup table and hrs and mins is the time from the RTC:
IF offtime.BYTE1=hrs AND offtime.BYTE0=mins THEN
DEBUG HOME, "TIMES UP!!!"