Clock code advice
Archiver
Posts: 46,084
Hi All,
Well, now that I have figured out how to drive my Nixies, it is time to
figure out the code ;-)
I am looking for advice on the best way to structure my code. I will be
receiving my time information in decimal format from WWBV receiver, i.e.:
hrs=12 min =30 seconds= 30. So I will chop that up into hrs_High, hrs_Low,
etc. I then need to compare the time and send the correct pins high/low so
the decoder lights the correct digit. What is the best way to organize this?
I could do a bunch of if/thens like:
if hrs_high = 1 then hrs_high_one
if hrs_high = 2 then hrs_high_two
and so one. But this is the dumb guy way (which is why it occurred to me)
but I know there is a better way. I just can't see it ;-) I need to keep the
code pretty streamlined, as the clock has seconds I have less than a second
to perform everything.
Thanks all!
Jonathan
www.madlabs.info
Well, now that I have figured out how to drive my Nixies, it is time to
figure out the code ;-)
I am looking for advice on the best way to structure my code. I will be
receiving my time information in decimal format from WWBV receiver, i.e.:
hrs=12 min =30 seconds= 30. So I will chop that up into hrs_High, hrs_Low,
etc. I then need to compare the time and send the correct pins high/low so
the decoder lights the correct digit. What is the best way to organize this?
I could do a bunch of if/thens like:
if hrs_high = 1 then hrs_high_one
if hrs_high = 2 then hrs_high_two
and so one. But this is the dumb guy way (which is why it occurred to me)
but I know there is a better way. I just can't see it ;-) I need to keep the
code pretty streamlined, as the clock has seconds I have less than a second
to perform everything.
Thanks all!
Jonathan
www.madlabs.info
Comments
ZEROPATTERN con xxxx ' pattern to make a zero
ONEPATTERN con xxxx ' pattern to make a one
Etc.
LOOKUP hrs_high,[noparse][[/noparse]ZEROPATTERN, ONEPATTERN, TWOPATTERN,...],outdigit
Digit=5
Gosub selectdigit ' pick the digit
Gosub writedigit ' write outdigit
<repeat>
Al Williams
AWC
* Control 8 servos at once
http://www.al-williams.com/awce/pak8.htm
>
Original Message
> From: Jonathan Peakall [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=ICUCbwmJLJ9Kcn9DuVT2OEUtJ0UXRlDAxsgbkruyyAr-4DtbHmKP1EZeb9dxODxOz-2cYqgbVuvchRljOW5T]jpeakall@m...[/url
> Sent: Saturday, February 01, 2003 10:05 AM
> To: basicstamps@yahoogroups.com
> Subject: [noparse][[/noparse]basicstamps] Clock code advice
>
>
> Hi All,
>
> Well, now that I have figured out how to drive my Nixies, it
> is time to figure out the code ;-)
>
> I am looking for advice on the best way to structure my code.
> I will be receiving my time information in decimal format
> from WWBV receiver, i.e.: hrs=12 min =30 seconds= 30. So I
> will chop that up into hrs_High, hrs_Low, etc. I then need to
> compare the time and send the correct pins high/low so the
> decoder lights the correct digit. What is the best way to
> organize this? I could do a bunch of if/thens like:
>
> if hrs_high = 1 then hrs_high_one
> if hrs_high = 2 then hrs_high_two
>
> and so one. But this is the dumb guy way (which is why it
> occurred to me) but I know there is a better way. I just
> can't see it ;-) I need to keep the code pretty streamlined,
> as the clock has seconds I have less than a second to perform
> everything.
>
> Thanks all!
>
> Jonathan
>
> www.madlabs.info
>
>
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the
> Subject and Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
>
>
with the new editor [noparse][[/noparse]you need to download the Beta 1 from our web site]. So
you could also do something like this:
Show_Hours_Tens:
SELECT (hours / 10)
CASE 0
' code to display 0
CASE 1
' code to display 1
CASE 2
' code to display 2
ENDSELECT
RETURN
To handle the low digit of hours, you would simply change the expression to
"hours // 10." I don't know how your Nixie drivers work, but there's
certainly the chance that you could create single SELECT CASE construct that
accepts a digit position, a value, then takes care of displaying it.
-- Jon Williams
-- Parallax
In a message dated 2/1/2003 10:05:24 AM Central Standard Time, jpeakall@mad
labs.info writes:
> Well, now that I have figured out how to drive my Nixies, it is time to
> figure out the code ;-)
>
> I am looking for advice on the best way to structure my code. I will be
> receiving my time information in decimal format from WWBV receiver, i.e.:
> hrs=12 min =30 seconds= 30. So I will chop that up into hrs_High, hrs_Low,
> etc. I then need to compare the time and send the correct pins high/low so
> the decoder lights the correct digit. What is the best way to organize
> this?
> I could do a bunch of if/thens like:
>
> if hrs_high = 1 then hrs_high_one
> if hrs_high = 2 then hrs_high_two
>
> and so one. But this is the dumb guy way (which is why it occurred to me)
> but I know there is a better way. I just can't see it ;-) I need to keep
> the
> code pretty streamlined, as the clock has seconds I have less than a second
> to perform everything.
[noparse][[/noparse]Non-text portions of this message have been removed]
interesting project..
Leroy
Original Message
From: "Jonathan Peakall" <jpeakall@m...>
To: <basicstamps@yahoogroups.com>
Sent: Saturday, February 01, 2003 11:05 AM
Subject: [noparse][[/noparse]basicstamps] Clock code advice
: Hi All,
:
: Well, now that I have figured out how to drive my Nixies, it is time to
: figure out the code ;-)
:
: I am looking for advice on the best way to structure my code. I will be
: receiving my time information in decimal format from WWBV receiver, i.e.:
: hrs=12 min =30 seconds= 30. So I will chop that up into hrs_High, hrs_Low,
: etc. I then need to compare the time and send the correct pins high/low so
: the decoder lights the correct digit. What is the best way to organize this?
: I could do a bunch of if/thens like:
:
: if hrs_high = 1 then hrs_high_one
: if hrs_high = 2 then hrs_high_two
:
: and so one. But this is the dumb guy way (which is why it occurred to me)
: but I know there is a better way. I just can't see it ;-) I need to keep the
: code pretty streamlined, as the clock has seconds I have less than a second
: to perform everything.
:
: Thanks all!
:
: Jonathan
:
: www.madlabs.info
:
:
:
:
: To UNSUBSCRIBE, just send mail to:
: basicstamps-unsubscribe@yahoogroups.com
: from the same email address that you subscribed. Text in the Subject and Body
of the
message will be ignored.
:
:
: Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
:
:
>receiving my time information in decimal format from WWBV receiver, i.e.:
>hrs=12 min =30 seconds= 30. So I will chop that up into hrs_High, hrs_Low,
>etc.
Hi Jonathan,
You have to be careful with the notation.
If it is in fact BCD (binary coded decimal), then what you will
receive is hrs=$12, min=$30 and seconds=$30. (denoted as HEX) And
in that case what you said about hrs_High etc is correct, to extract
the digits. That is what Al followed up on.
But it the values are really hrs=12, min=30 and seconds=30 as stated,
then that is different, and the method that Jon suggested using
hrs/10 and hrs//10 will extract the digits, or you could
alternatively use hrs dig 1 and hrs dig 0.
Just to add one more method to the mix, here is a way to read the
patterns from eeprom. (Like the one Al suggested using LOOKUP).
'{$PBASIC 2.5}
patterns data pzero,pone,ptwo ',... all ten digit patterns stored in eeprom
pattern var byte
do
gosub getclockreading
' assume BCD, e.g. hrs.nib1=1, hrs.nib0=2 for 12 oclock
read patterns+hours.nib1,pattern ' get the pattern from eeprom
digit=hours10 ' showdigit takes pattern and digit as input
gosub showdigit ' 10s of hours
read patterns+hours.nib0,pattern ' get the pattern
digit=hours1
gosub showdigit ' 1s of hours
' and so on for all the digits
' it might be possible to reduce this to one for-next loop
' if the digits are well placed consecutively in RAM.
loop
-- Tracy
Thanks for the ideas! I'm sure more questions will develop as I go along ;-)
Leroy, I am using a WWBV reciver that Parallax used to sell, but is now
discontinued. The company that made it only has expensive units now. I was
using a $15 wwbv clock that I hacked, and if I can figure out extracting the
date from it, I may use it for this project too.
Jonathan
www.madlabs.info
Original Message
From: "Tracy Allen" <tracy@e...>
To: <basicstamps@yahoogroups.com>
Sent: Saturday, February 01, 2003 10:55 AM
Subject: Re: [noparse][[/noparse]basicstamps] Clock code advice
> > I will be
> >receiving my time information in decimal format from WWBV receiver, i.e.:
> >hrs=12 min =30 seconds= 30. So I will chop that up into hrs_High,
hrs_Low,
> >etc.
>
> Hi Jonathan,
>
> You have to be careful with the notation.
>
> If it is in fact BCD (binary coded decimal), then what you will
> receive is hrs=$12, min=$30 and seconds=$30. (denoted as HEX) And
> in that case what you said about hrs_High etc is correct, to extract
> the digits. That is what Al followed up on.
>
> But it the values are really hrs=12, min=30 and seconds=30 as stated,
> then that is different, and the method that Jon suggested using
> hrs/10 and hrs//10 will extract the digits, or you could
> alternatively use hrs dig 1 and hrs dig 0.
>
> Just to add one more method to the mix, here is a way to read the
> patterns from eeprom. (Like the one Al suggested using LOOKUP).
>
>
> '{$PBASIC 2.5}
> patterns data pzero,pone,ptwo ',... all ten digit patterns stored in
eeprom
> pattern var byte
> do
> gosub getclockreading
> ' assume BCD, e.g. hrs.nib1=1, hrs.nib0=2 for 12 oclock
> read patterns+hours.nib1,pattern ' get the pattern from eeprom
> digit=hours10 ' showdigit takes pattern and digit as input
> gosub showdigit ' 10s of hours
> read patterns+hours.nib0,pattern ' get the pattern
> digit=hours1
> gosub showdigit ' 1s of hours
> ' and so on for all the digits
> ' it might be possible to reduce this to one for-next loop
> ' if the digits are well placed consecutively in RAM.
> loop
>
>
>
> -- Tracy
>
>
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
>
You might be interested in:
http://www.amug.org/~jthomas/example.pdf
or
http://www.amug.org/~jthomas/wwvb.html
for your clock..
I looked at your website and was interested in the 'sound laser' and the sound
refrigerator. Is there any information about these subjects a little easier to
understand? I read them, but am looking for more info.
Leroy
Original Message
From: "Jonathan Peakall" <jpeakall@m...>
To: <basicstamps@yahoogroups.com>
Sent: Sunday, February 02, 2003 9:20 AM
Subject: Re: [noparse][[/noparse]basicstamps] Clock code advice
: Tracy, Jon, Al, Leroy,
:
: Thanks for the ideas! I'm sure more questions will develop as I go along ;-)
:
: Leroy, I am using a WWBV reciver that Parallax used to sell, but is now
: discontinued. The company that made it only has expensive units now. I was
: using a $15 wwbv clock that I hacked, and if I can figure out extracting the
: date from it, I may use it for this project too.
:
: Jonathan
:
: www.madlabs.info
:
:
Original Message
: From: "Tracy Allen" <tracy@e...>
: To: <basicstamps@yahoogroups.com>
: Sent: Saturday, February 01, 2003 10:55 AM
: Subject: Re: [noparse][[/noparse]basicstamps] Clock code advice
:
:
: > > I will be
: > >receiving my time information in decimal format from WWBV receiver, i.e.:
: > >hrs=12 min =30 seconds= 30. So I will chop that up into hrs_High,
: hrs_Low,
: > >etc.
: >
: > Hi Jonathan,
: >
: > You have to be careful with the notation.
: >
: > If it is in fact BCD (binary coded decimal), then what you will
: > receive is hrs=$12, min=$30 and seconds=$30. (denoted as HEX) And
: > in that case what you said about hrs_High etc is correct, to extract
: > the digits. That is what Al followed up on.
: >
: > But it the values are really hrs=12, min=30 and seconds=30 as stated,
: > then that is different, and the method that Jon suggested using
: > hrs/10 and hrs//10 will extract the digits, or you could
: > alternatively use hrs dig 1 and hrs dig 0.
: >
: > Just to add one more method to the mix, here is a way to read the
: > patterns from eeprom. (Like the one Al suggested using LOOKUP).
: >
: >
: > '{$PBASIC 2.5}
: > patterns data pzero,pone,ptwo ',... all ten digit patterns stored in
: eeprom
: > pattern var byte
: > do
: > gosub getclockreading
: > ' assume BCD, e.g. hrs.nib1=1, hrs.nib0=2 for 12 oclock
: > read patterns+hours.nib1,pattern ' get the pattern from eeprom
: > digit=hours10 ' showdigit takes pattern and digit as input
: > gosub showdigit ' 10s of hours
: > read patterns+hours.nib0,pattern ' get the pattern
: > digit=hours1
: > gosub showdigit ' 1s of hours
: > ' and so on for all the digits
: > ' it might be possible to reduce this to one for-next loop
: > ' if the digits are well placed consecutively in RAM.
: > loop
: >
: >
: >
: > -- Tracy
: >
: >
: >
: >
: > To UNSUBSCRIBE, just send mail to:
: > basicstamps-unsubscribe@yahoogroups.com
: > from the same email address that you subscribed. Text in the Subject and
: Body of the message will be ignored.
: >
: >
: > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
: >
: >
: >
: >
:
:
: To UNSUBSCRIBE, just send mail to:
: basicstamps-unsubscribe@yahoogroups.com
: from the same email address that you subscribed. Text in the Subject and Body
of the
message will be ignored.
:
:
: Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
:
:
I saw that site. It was funny, as I had a partially dissassembled clock of
the same type on my desk when I found it. I do plan to look at it some more
to figure out extracting the date.
Not much information about the acuostic laser, pretty new stuff. I made the
ones you saw from that article you read, and that was all I found. I still
have a couple pieces of substrate, if you want one.
Jonathan
www.madlabs.info
Original Message
From: "Leroy Hall" <leroy@f...>
To: <basicstamps@yahoogroups.com>
Sent: Sunday, February 02, 2003 10:18 AM
Subject: Re: [noparse][[/noparse]basicstamps] Clock code advice
> Dear Jonathan,
>
> You might be interested in:
>
> http://www.amug.org/~jthomas/example.pdf
>
> or
>
> http://www.amug.org/~jthomas/wwvb.html
>
> for your clock..
>
> I looked at your website and was interested in the 'sound laser' and the
sound
> refrigerator. Is there any information about these subjects a little
easier to
> understand? I read them, but am looking for more info.
>
> Leroy
>
Original Message
> From: "Jonathan Peakall" <jpeakall@m...>
> To: <basicstamps@yahoogroups.com>
> Sent: Sunday, February 02, 2003 9:20 AM
> Subject: Re: [noparse][[/noparse]basicstamps] Clock code advice
>
>
> : Tracy, Jon, Al, Leroy,
> :
> : Thanks for the ideas! I'm sure more questions will develop as I go along
;-)
> :
> : Leroy, I am using a WWBV reciver that Parallax used to sell, but is now
> : discontinued. The company that made it only has expensive units now. I
was
> : using a $15 wwbv clock that I hacked, and if I can figure out extracting
the
> : date from it, I may use it for this project too.
> :
> : Jonathan
> :
> : www.madlabs.info
> :
> :
Original Message
> : From: "Tracy Allen" <tracy@e...>
> : To: <basicstamps@yahoogroups.com>
> : Sent: Saturday, February 01, 2003 10:55 AM
> : Subject: Re: [noparse][[/noparse]basicstamps] Clock code advice
> :
> :
> : > > I will be
> : > >receiving my time information in decimal format from WWBV receiver,
i.e.:
> : > >hrs=12 min =30 seconds= 30. So I will chop that up into hrs_High,
> : hrs_Low,
> : > >etc.
> : >
> : > Hi Jonathan,
> : >
> : > You have to be careful with the notation.
> : >
> : > If it is in fact BCD (binary coded decimal), then what you will
> : > receive is hrs=$12, min=$30 and seconds=$30. (denoted as HEX) And
> : > in that case what you said about hrs_High etc is correct, to extract
> : > the digits. That is what Al followed up on.
> : >
> : > But it the values are really hrs=12, min=30 and seconds=30 as stated,
> : > then that is different, and the method that Jon suggested using
> : > hrs/10 and hrs//10 will extract the digits, or you could
> : > alternatively use hrs dig 1 and hrs dig 0.
> : >
> : > Just to add one more method to the mix, here is a way to read the
> : > patterns from eeprom. (Like the one Al suggested using LOOKUP).
> : >
> : >
> : > '{$PBASIC 2.5}
> : > patterns data pzero,pone,ptwo ',... all ten digit patterns stored in
> : eeprom
> : > pattern var byte
> : > do
> : > gosub getclockreading
> : > ' assume BCD, e.g. hrs.nib1=1, hrs.nib0=2 for 12 oclock
> : > read patterns+hours.nib1,pattern ' get the pattern from eeprom
> : > digit=hours10 ' showdigit takes pattern and digit as input
> : > gosub showdigit ' 10s of hours
> : > read patterns+hours.nib0,pattern ' get the pattern
> : > digit=hours1
> : > gosub showdigit ' 1s of hours
> : > ' and so on for all the digits
> : > ' it might be possible to reduce this to one for-next loop
> : > ' if the digits are well placed consecutively in RAM.
> : > loop
> : >
> : >
> : >
> : > -- Tracy
> : >
> : >
> : >
> : >
> : > To UNSUBSCRIBE, just send mail to:
> : > basicstamps-unsubscribe@yahoogroups.com
> : > from the same email address that you subscribed. Text in the Subject
and
> : Body of the message will be ignored.
> : >
> : >
> : > Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
> : >
> : >
> : >
> : >
> :
> :
> : To UNSUBSCRIBE, just send mail to:
> : basicstamps-unsubscribe@yahoogroups.com
> : from the same email address that you subscribed. Text in the Subject
and Body of the
> message will be ignored.
> :
> :
> : Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
> :
> :
>
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
>