Counting problems....
Mikael S
Posts: 60
In a code for a digital clock i use this instruction: "mins = mins + 1" (mins VAR Word) for·setting the minutes. It works execept when it going to change the 10'th minutes. For example can i see in my debug screen when·it counts: 28 - 29 - 2A - 2B - 2C -2D - 2F -30 -31 -32. Why does it count the letters?? How can i fix this??
Thanks for any help!!
Regards,
Mikael S
·
Thanks for any help!!
Regards,
Mikael S
·
Comments
I think you are counting in HEX. Do a quick search and you will see how to do base 10 and base 60 to use a clock function.
' {$STAMP BS2}
' {$PBASIC 2.5}
· mins· VAR Byte
start:
· mins· = mins + 1
· 'PAUSE 50
· IF mins.HIGHNIB = 6 THEN mins = 0
· DEBUG HEX2 mins
· PAUSE 500
· GOTO start
Mikael
To enable you to read the value of your variable on your computer monitor there are several "formatters" that take your 1's and 0's and format them in a way you are able to read them.
In your code you are using the HEX2 formatter that displays your 1's and 0' as a 2 digit hex value.
What it seems like you really need is the DEC2 formatter which will display the variable as a decimal number.
Do a little research on computer numbering systems , it's really worthwhile.
Jeff T.
or· you need to ,HEX secs , HEX mins, ·HEX hrs
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 1/28/2010 12:12:58 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike2545
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike2545
However, the BS2 doesn't do this. When the low nibble counts from 9 to the next number, in binary (and hex) that's $0A, not $10. So, to send data (and interpret data) from the 1302, realize it's BCD. To send data (and interpret data) from the BS2, you can use the "DEC" modifier. But the two systems -- BCD and HEX -- ARE different from each other, and do require some conversion to use properly.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike2545
Post Edited (Mike2545) : 1/30/2010 12:48:03 AM GMT
/Mikael