I'm building a control mechanism for a seat heater in my car. Eventually, it will drive power relays to control the current to the heating elements. It works in a simulation on simulator.io, but it behaves erratically when realized on a solderless breadboard, with a 74LS76.
The idea is to press one button, which will (by tripping the clock input) cycle it through "Off," "Low," and "High," and for the initial state on vehicle power-up to always be "Off" (as opposed to a simple double-throw rocker switch, which remains latched).
I'm obviously doing something wrong, but I don't know enough about TTL to know what I'm doing wrong.
Here is a screenshot from simulator.io. The actual simulation can be accessed at https://simulator.io/board/6TOaOHKnHJ/1
Here is what I currently have on the breadboard, with the 74LS76 pin numbers marked. The capacitor is (theoretically) supposed to ground the "clear" inputs on power-up, so that it always powers up in an "Off" state (again, the whole point of the circuit).
So far, I've switched from pulsing clock from Vcc without a pull-down, to pulsing it from Vcc with a pull-down, to the present pulsing it from ground with a pull-up, and I've gone from driving the LEDs directly from a high on the Q outputs (which of course overloaded them), to driving them directly from a low on the ~Q outputs, to the present driving them through a transistor from a high on the Q outputs.
Aside from bounce, the major erratic behavior seems to be one of states: theoretically, the only allowable states are "both LEDs off," "green LED only," and "both LEDs on"; yet this isn't how it behaves in practice.
It took a while for the parts (mainly some 74LS14s and a bigger solderless breadboard) to arrive, and they arrived just in time for all my free time to be consumed by a newsletter that had to make it out the door, but Sunday, I had a chance to build the Schmitt trigger RC debounce circuit given on "ganssle.com":
For testing purposes, I inserted an LED with a dropping resistor between Vcc and the output. At first, I had a terrible time getting the thing to work at all, using the original value of 18k (actually, 20k was the closest I could get) for the resistor in parallel with the diode, and also failing to notice that my new solderless breadboard didn't have continuous top-to-bottom power rails. (In fact, because of the latter, I thought perhaps I'd blown the 74LS14 by feeding it signal with no power.) Even after I bridged the gaps in the power rails, it didn't start to actually work until I reduced that resistor to 4.7k.
Success, on the erratic cycling issue! Connecting the Schmitt trigger output to the clock inputs, the outputs cycle properly and reliably, at least from tapping a clip-lead from the debouncer input on ground. Hopefully, I'll have time this evening to move the control circuit onto the larger solderless breadboard, and try it with the actual switch.
That's a big piece of the problem, but it's not the whole problem: there's still the matter of the pre-clear: the control circuit appears to power up with the outputs in a "low power" state, rather than the desired "off" state. Currently, the pre-clear is (assuming I copied the resistor value onto the schematic correctly) just a 1 µF capacitor connecting pins 3 and 8 to ground, and a 1k resistor connecting it to Vcc. I may just need to play with the resistor value, or plug in a bigger capacitor, but failing that, would maybe something with a couple of the unused Schmitt triggers help?
Late last night, I experimented with the resistors on the *PRE and *CLR inputs, and found that if I increased both of them from 1k to 100k, the pre-clear function started working reliably, and if I added a 390k across the capacitor, it worked even better.
Not entirely sure why the pull-up on the *PRE inputs would have an effect, but I'm not going to argue with it.
Tonight, I should have time to see whether, now that the clock inputs are being fed from a Schmitt trigger debouncer, the 1k pull-up on them is still actually serving a purpose, or if it can be deleted. I suspect the latter.
Updates:
- Deleted the pull-up on the clock, as planned. Works fine.
- When I moved the main circuit onto the larger breadboard, and tightened things up so that it would fit on the PC board, it started malfunctioning (but it would work normally if I had a voltmeter between Q on the second FF and ground.
- This morning, I tried increasing the resistors between that and the output transistor, and I tried adding a pull-down resistor, none of which worked. I finally swapped in a different 74LS76, and everything works now. It might be that I damaged the FF; it might be that one or more pins weren't making good contact. I've bagged the "iffy" 74LS76, and will try swapping it back in once everything is moved to the PC board.
Because it's TTL, I bought my ICs in triplicate. If I'd had the guts to try this in CMOS, I'd have probably bought ten of each IC.