QUESTION: BCD or BINARY?

techElder

Well-known member
After re-reading Hippy's famous BCD to decimal code snippet, this question occurred to me.

Where you had to
  • read the values of two 16-bit counters to get LSB and MSB separately
  • combine the resulting 16-bit word (LSB) with another 16-bit word (MSB) somehow to get a total count
  • subtract that total from a starting count to get an "elapsed" count
  • present the "elapsed" count to a visible display
Would you choose to accumulate the count in BINARY or BCD?
 

hippy

Ex-Staff (retired)
I would go with binary. Trying to do maths with BCD numbers can easily become a nightmare so often ends up converting to binary to do that anyway.
 

westaust55

Moderator
Another vote to use binary - the "native" language of most microcontrollers and computers (analog computers and a few others do exist)
 

Buzby

Senior Member
  • ... read the values of two 16-bit counters to get LSB and MSB separately ...
Is the combined raw count a 32bit number divided into two 16bit words ?

The PICAXE can't read a 32bit number in one operation, so you will have issues when the two 16bit values are read at two seperate times.

You need some method of latching the 32bit value while the read operations take place.

Are these counters in the PICAXE, or external ?

Cheers,

Buzby
 

techElder

Well-known member
Counter is actually external, the outputs are latched, and I will have to deal with two 16-bit words (8-bit nibbles) within the PICAXE to get the total elapsed time. (I'm not expecting any more than 24-bit significance and may mask off the most significant 8-bits.)

I wasn't going there yet, because I don't really have any coding done, but I will have to deal with some math involving the 32-bit number; such as "which 32-bit number is greater" comparison.

The ultimate goal is to transmit the 32-bit number as ASCII via a serial link.

PS. Sounds like since I'm not going to directly transfer the count to a display, BINARY is the hands-down winner.

Is the combined raw count a 32bit number divided into two 16bit words ? ... You need some method of latching the 32bit value while the read operations take place. ... Are these counters in the PICAXE, or external ?
 
Top