Question about binary to BCD converter using counters

Thread Starter

Dave Lowther

Joined Sep 8, 2016
332
I've been looking at this circuit posted by @crutschow here
1743843359883.png
I'm considering implementing it (for educational purposes), but first I want to understand how it works.
The part that's confusing me is the terminating condition.
For example, when the 8 bit binary input is 23 decimal (hex 0x17), my understanding is:
  1. On the first clock 7 is loaded into U1 and 1 is loaded into U9.
  2. After another 7 clocks, U1 has counted down to 0 and U1 /COUT has gone low.
  3. After the next clock U1 count has wrapped from 0 to 15, U9 has counted down from 1 to 0, and U9 /COUT has gone low.
  4. At the next clock U9 /COUT gets clocked into U6, thus restarting the process.
It seems to me that the process shouldn't be restarted when U9 /COUT is low. It should only be restarted when U1 /COUT goes low and U9 /COUT has previously gone low or is currently low.
As I didn't see any comments, about the restart condition not working, in the thread I copied the schematic from, I'm thinking I've misunderstood something about the way it works.
Would someone be kind enough to tell me where my understanding is wrong?
 

Irving

Joined Jan 30, 2016
4,996
No, that is correct. If you read the datasheet for the CD4029 you will see that /COUT is gated with /CIN so is only low when /CIN is low, which achieves exactly what you surmised. Here's a pretty simulation....

1743861835534.png
 

Thread Starter

Dave Lowther

Joined Sep 8, 2016
332
If you read the datasheet for the CD4029 you will see that /COUT is gated with /CIN so is only low when /CIN is low, which achieves exactly what you surmised.
Thank you. I've read this data sheet a few times in the last 36 hours. It's like a photocopy, so I can't copy / paste text from it. This is the part I misunderstood:
1743863795479.png
I think my misunderstanding arose from using this rationale:
- It doesn't count unless /CARRY-IN is low
- So the text highlighted in yellow can only happen when /CARRY-IN is low
- Hence the text in red brackets seemed redundant.
Thanks for your help. I think I understand how it works now. I just need to absorb what you said and have a good think about the little -ve going spike on V(/cout) to convince myself that I really do understand how the flip flop only registers the change when there's a proper width pulse on V(/cout).
 

MrChips

Joined Oct 2, 2009
34,628
So you have 0-255 as 8-bit binary and you want to output 3-digit BCD.
You can do with with two 256-byte ROM chips.
You can also do it with a single MCU chip.
 

Irving

Joined Jan 30, 2016
4,996
Thanks for your help. I think I understand how it works now. I just need to absorb what you said and have a good think about the little -ve going spike on V(/cout) to convince myself that I really do understand how the flip flop only registers the change when there's a proper width pulse on V(/cout).
The little -ve spike is a race condition when decrementing the second counter from 0001 to 0000. As clk goes high, it puts /COUT low, but also puts /cout0 high, which pulls /COUT high again. Whether this occurs for real or is an artifact of the simulation remains to be seen. But since /COUT is clocked into the FF by the same clock its really of no consequence as everything is sync'd to the rising edge of clk..
 

Thread Starter

Dave Lowther

Joined Sep 8, 2016
332
So you have 0-255 as 8-bit binary and you want to output 3-digit BCD.
You can do with with two 256-byte ROM chips.
You can also do it with a single MCU chip.
Yes, well actually it will probably end up being 9 bit binary.
I'm helping a young beginner who wants to make a binary adder to add / subtract two signed 8 bit numbers and display the result on 7 segment displays. They want to do this without using an MCU. They want to learn about using chips like 74 series.
We've discussed that it could be done with a lookup table in ROM, and we may choose that option. I've not had a lot of success finding available ROMs at a reasonable price, although I've not spent much time on this yet. I've not looked into how we'd program them either.
I've also looked at a DM74184 datasheet, which offers this solution:
1743874049417.png
I've not checked price or availability for DM74184s.
At the moment I'm just finding out enough about how the solutions would work, whether the parts are available, and at what cost. When I'm done with investigating the counter solution, I'll spend some time looking at the other possible solutions.
It's been a while (~40 years) since I was working full time doing hardware design at this level, so my knowledge of what's available these days isn't good.
 

MrChips

Joined Oct 2, 2009
34,628
There aren't too many parallel EEPROMs left to buy now. Here's an idea how to use one to near capacity for 3 displays.
Clever idea to use multiplexed 7-segment output instead of generating BCD.
Now you can go beyond 0-511 display, four digits and even more.
 

dl324

Joined Mar 30, 2015
18,219
I've not checked price or availability for DM74184s
Likely unavailable, but you could implement them by programming PROMs.
When I'm done with investigating the counter solution, I'll spend some time looking at the other possible solutions.
I have programmed M27C4002 EPROM as a 0-9999 binary-BCD converter. That device is convenient because all of the address lines are on one side and the data lines on the other:
1743890154107.png
Availability of parallel EPROMs hasn't been an issue for me. I have hundreds of MC27C4002 as well as 1MB, 512KB, 256KB, 128KB, 64KB and dozens of 32KB and 16KB parts. Available for bartering or for sale.

The counter solution always seemed inefficient to me.
 

Irving

Joined Jan 30, 2016
4,996
Availability of parallel EPROMs hasn't been an issue for me. I have hundreds of MC27C4002 as well as 1MB, 512KB, 256KB, 128KB, 64KB and dozens of 32KB and 16KB parts. Available for bartering or for sale.
Fair enough, though I was looking for electrically erasable rather than UV-erasable parts. There are quite a few on eBay but not found a main dealer with stock of the 27C4002.
 

crutschow

Joined Mar 14, 2008
38,316
If you want to directly drive a 7-segment display to show the decimal output, you could use the CD40110 decade counter-driver in place of the BCD up-counter in the Post #1 circuit.
 
Last edited:

Thread Starter

Dave Lowther

Joined Sep 8, 2016
332
Thank you all for the comments since my last post. I'm still (slowly) understanding the behaviour shown in post #2 for how the counter internals 'ignore' /CIN the first time. There's quite some complexity in the internal circuitry shown in the datasheet.
I've resorted to writing some code to implement my understanding of how it behaves. I probably should have invested the time in learning spice, but I only tried it briefly a few years ago, so I'm pretty much a complete beginner with it.
I've got more work to do on my understanding, but I'm getting there. I'm not sure how much free time I'll have for the next two weeks as there will be grandchildren staying here during their Easter school holidays.
I'll report back when my code implementation of my understanding matches the behaviour shown in post #2.
I do have a collection of EPROMS from 'back in the day'. I still have a UV eraser, but no programmer.
 

MisterBill2

Joined Jan 23, 2018
27,173
Many years back, when most of us were just being introduced to computers and the binary notations, I saw a circuit that used discrete logic to convert binary to a decimal number. So it can be done with logic that was available in 1964. My recollection is that it was done with a lot of adders.
So probably the way to go is to first develop the scheme of the math to convert binary to decimal. That is not that complicated, although it is very tedious. But not quite so tedious doing it one digit at a time.
 
Top