timing problems when outputting a cd4518 to a cd4081 - Page 1
Forum section: electronics / projects

author: JeanF
author_rank: Regular Contributor
timestamp: October 03, 2013, 03:51:44 am
content: Hello,I'm trying to debug a 7-segment clock I made, following the instructions I found in a magazine. It is entirely done in CD4xxx logic. Of course, it needs 12 ICs instead of a single PIC and it can also be used as a heater in winter, since all the necessary segments are turned on (no multiplexing) and I also had to uses smaller dropout resistors than expected because my 7 segment panels were a bit dim. But...long story short :There is a 4.194 MHz quartz oscillator and a divider (CD4521) to have a nice 1Hz square wave. Then the first BCD counter in a CD4518 counts the seconds, and the second counter in the same chip deals with the tens of seconds.The two counters have their output bits (Q0 Q1 Q2 Q3 or Q1 Q2 Q3 Q4, I have seen both and I don't know which is more correct) wired to two CD4511s for the LED display but that's another story.When the tens of seconds go 1, 2, 3, 4, 5, 6 the output of the 4518 goes 1000, 0100, 1100, 0010, 1010, 0110 respectively. There is a AND gate (CD4081) wired to the two middle bits to detect the 60th second and reset the counters (and increase the minutes).I hope I am clear, I do my best, but if you want the (poorly drawn original) schematic, here it is :http://jfsimon.net/images/forums/clock.JPGNow here is the problem :All seem to work fine, after 59 secs it goes back to 00 and increases the minutes by 1, but "sometimes" it ALSO triggers at the 40th second, just after 39. So my minutes counter is increased of +2min every minute, which is a bit annoying.My first guess was that there could be a very short moment, between 3 and 4, when it goes from 1100 to 0010, where the output could be 1110 or 0110 for a short moment, and the AND gate is so quick that it detects that. Is this possible ?Part of the problem is that the issue is not very repeatable. I plugged 4 LEDs + 100k resistors on the 4518 with some minigrabbers to check if the bits were correctly changing, and this fact (having parallel wires connected) makes the issue go away. When I disconnect my "el-cheapo LED signal analyser", boom, it happens again.The same thing happens on the "tens of hours" counter.I also tried to modify the supply voltage, and for example at 5v the clock goes +1min at 40sec, continues to count (41...) AND +1min too at 60sec before going back to 00sec, whereas at 12v it goes +1min at the 40th sec and boom, 00 sec.What can I do to reliably solve this problem ? I once thought "I could bodge a inverting gate and some more AND gates to properly detect "0110" instead of "x11x" " but I'm not sure if it will change anything...Thanks for any help !

author: David_AVD
author_rank: Super Contributor
timestamp: October 03, 2013, 04:38:36 am
content: My first question is do you have the required decoupling capacitors close to every IC ?

author: JeanF
author_rank: Regular Contributor
timestamp: October 03, 2013, 10:14:51 am
content: Yes sir, I think so ! 100nF mylar film everywhereThanks.

author: IanJ
author_rank: Unknown
timestamp: October 03, 2013, 10:47:21 am
content: Hi,A quick look.......It looks like the problem is the transition of 3 to 4 tens, i.e. 1100 to 0010, i.e. for a fraction of a mS the AND gate is seeing the two middle bits at 11, i.e. as one bit turns off and the other turns on.You might get away with a wee bodge, i.e. load up those two pins with a resistor on each so they transition high to low, low to high faster. That might stop the AND gate picking up 11.You could also trying using the same IC from a different manufacturer. I've noticed timing issues over the years between various, i.e. 4013 flip-flops.A better fix would be re-designing the logic so that the issue is completely removed. There's nothing worse than 4000 series / 74 series logic designs with on the edge timing issues.Ian.

author: JeanF
author_rank: Regular Contributor
timestamp: October 03, 2013, 11:42:14 am
content: Thank you very much. Indeed, a 10k pulldown on these two bits seem to fix the problem. I didn't know that output load changed propagation times !Yeah, the design is overall not very good, I suspect that even the board layout is questionable (all these jumpers...) and there was a missing track in the provided copper layer, one of the CD4511s wasn't powered correctly but I took ages to figure it out because it was almost working (I guess it was powered by parasitic power by one of the IOs, as with some PICs ?? anyway... fixed)but I still wanted to finish troubleshooting, in order to at least have a usable clock after all the hours I spent. So let's say the resistor trick will be good enough this time...Of course I'm not asking you to redesign the logic from scratch, but do you know some general guidelines to avoid these problems ?Thank you again

author: IanJ
author_rank: Unknown
timestamp: October 03, 2013, 01:14:49 pm
content: Quote from: JeanF on October 03, 2013, 11:42:14 amNot really!...........you've done a good job of attempting some old school electronics design & build.......you've got yourself a working product and you've learned some things along the way..............just continue as you are doing and your builds will get more complex, better, more reliable and more fun!Ian.

author: JeanF
author_rank: Regular Contributor
timestamp: October 03, 2013, 01:56:15 pm
content: Well, i finally got it to workI may reduce the value of the pulldown resistors on Q2 and Q3 fpr the 10s of hours counter, it looks like some randomness remains in the thing with 10kohm...I'll let it run for a few days and we'll see...The original design used 2.54mm headers to connect the two boards, and the display pcb was not like this (there were 4 leds to make the display XX:XX:XX ; I chose to hijack the decimal points for that purpose) and I didn't like it...errors made : (among many more)- trying to avoid a proper pcb etching (on the LED board) by cutting pads on the bare copper with x-acto and ruler... maybe good for a few leads but definitely not for 6*7 segments ! too many bridges and bad connections...- saying "headers ? nah, i'll just go with loose wires" (again, not good for 50 parallel wires)- forcing capacitors into place when the pin spacing doesn't match the actual pcb (I first usedthis type of packagebut the strain on the leads made them fail and I had to swap them all with the proper ones...lessons learned :- think about timing next time- no more multi-pcb designs without a proper way to interconnect them !!thanks again !