BCD Help Please!

Graham Ogle

New Member
I'm back again with another BCD question. I can convert a number to BCD or a decimal to two BCD nibbles. But I need each nibble to be to base 10, i.e. the range is from 0 to 9, not 0 to 15. How can this be done please?
Alternatively, since the decimal nibble is never greater than 9, can I map these 4 bits, to 4 output pins and another 4 bit nibble to another 4 output pins? I can set all pins to one nibble or the other, but not independently.
I am trying to control a frequency synthesiser which needs a programming number upto 15999. I am trying to replicate BCD thumbwheels which would show upto 15 on the most significant digit and 9's on the other 3.
Any help would be much appreciated.
Thanks
 

BeanieBots

Moderator
Not really sure what you concern is?
Each nibble of a BCD number IS base 10. If it were not, it would simply be an 8-bit binary number.
You say you can convert to BCD, so simply do that for the lower 3 digits but just output the raw binary (0 to 15) for the last digit.
That assumes that you equipment will understand a value over 9 on one of its BCD inputs. Normally this would be done with two BCD wheels 0-9 and 0-1.
 

Graham Ogle

New Member
Thanks for the information. I think I've been going round the same loop so many times, I've got myself confused. I'll give it a go.
Thanks
Graham
 

rfs

Member
Graham. Have a quick look at this nonsense.
It might help.
<code><pre><font size=2 face='Courier'>'to split ONE frequency into four separate values
'EACH value is a FOUR bit number
'I use w3 for the main input number
'b1, b2, b3, b4 were just easy values to remember, while working
'
'


let w3 = $F999 ' Input as HEX and you're halfway there. Change value to check.
'
'




'OR b7 = $F9 ' see Basic guide p6 ...
'and b6 = $99 ' It's the same thing, except longer to type.


'
sertxd (&quot;w3= &quot;,#w3,&quot; b7= &quot;,#b7,&quot; b6= &quot;,#b6, 13,10,13,10) ' Print a check.
Start new line
'


b1 = b7/16 'move bits 4 to the right
b2 = b7*16 'move bits 4 to the left' to remove bits 7-4
b2 = b2/16 'move bits 4 to the right

b3 = b6/16 'and again
b4 = b6*16
b4 = b4/16
'

sertxd (#b1, &quot; &quot;,#b2,&quot; &quot;,#b3,&quot; &quot;,#b4, 13,10) ' print a check
'

' And then remove MOST of this program
' and say
' pins = b7 do things. Then
' pins = b6

'Hope this MIGHT help </font></pre></code>






Edited by - rfs on 23/04/2006 20:28:30
 
Top