# Generating logic using 555s

Quick back story: I bought a bunch of 4-digit LED displays because they were going cheap. They are great & work well, but - like most/all (?) multidigit displays, they only have pins to light 1 digit at a time. No problem, a couple of shift registers and an Arduino, and you can run them no bother: The Meddling Monk: Cheap 4-digit displays from SparkFun

So, onto something more useful; I added a MAX6675 chip & a thermocouple to make myself a nice 4-digit thermometer. I plan to use this to convert a humble toaster oven into a reflow soldering oven (done many times before, but I like to plough my own furrow). The problem is, because it takes a significant portion of time (several mSec) to poll the MAX device, the display flickers every time I access it. Specifically, because of the way I did my multiplexing, the display "stalls" on the last digit (the degree symbol if the temp < 999 degrees C); so that appears to flash bright while the rest of the display appears to flash dim. Solving this flicker is the purpose of this post & question...

The plan is this: Use 4 shift registers, 1 per digit, daisy chained together. Use some NANDs and NORS to "read" a 2-bit logical signal to switch the appropriate shift register ON, AND power the appropriate digit anode, per the truth table below:

``````A  B  | D1  D2  D3  D4
------|---------------
0  0  |  1   0   0   0
0  1  |  0   1   0   0
1  0  |  0   0   1   0
1  1  |  0   0   0   1
``````

So - how to generate the A & B truth table? You've probably already guessed I plan to use 555 timers - 2 of them in fact. One will be an astable multivibrator, the second a flip-flop. Trawling t'interwebs (because I have not used a 555 for 20 years...) I found a flip-flop (FLIP FLOP and MEMORY CELL Circuit) and a handy calculator with astable multivibrator option (555 Calculator).

Plugging the astable multivibrator circuit into the flip-flop circuit, with the output of the first 555 being the switch, I came up with this schematic (I used a 556 to reduce the part count a little). I haven't had a chance to build it yet, so I figured I'd ask here first to make sure I'm not doing something dumb. Please note that to get a 50% duty cycle on the astable multivibrator, the calculator basically wanted a zero ohm resistor; so R1 on my schematic corresponds to R2 on the astable multivibrator circuit, and R1 doesn't exist.

The values I've chosen should correspond to a refresh rate of about 1kHz +/- a few %.

So.... will it work? I will find out tomorrow unless someone tells me that that schematic will burn my 556 out...

In theory, if that does work, then the display will drive itself based on whatever values are in the shift registers. So I can load the new values at my leisure, leaving the Arduino to do whatever it wants to do. Better yet, if I run the outputs through transistors, presumably I can use the same driver to run ALL the displays I might use in a project....

For future reference avoid the original 555's and 556's if possible, they crowbar
the supply to the tune of 300mA or something like that, use the CMOS equivalents
7555 and 7556 which are much kinder to the rest of the circuit and don't need 220uF decoupling capacitors! At the very least put some decoupling on your circuit.

CMOS 555's have less leakage and tolerate a wider supply range too.

More importanty, based on what I understand about 555s, that circuit will never oscillate because Threshold and Trigger are permenantly tied to Vcc.

You're not wrong jiggy, R1 should in fact be between threshold/trigger & vcc, and discharge should be wired straight to Vcc. A cockup caused by the different pin layouts on the 556 vs 555...

So - how to generate the A & B truth table?

Use a 74LS42 chip, that will do it.

Grumpy_Mike:

So - how to generate the A & B truth table?

Use a 74LS42 chip, that will do it.

I need the A&B inputs generating, not the D1-4 outputs.

Sorry a 74LS148.

But that is not a compleate truth table then and you have drawn in back to front. Inputs are always on the left outputs on the right.
The full truth table will have 16 entries

Sparkfun's price is OK, though FastTech has a pack of 5 red 4-digit displays for 232c:
http://www.fasttech.com/products/1009/10000386/1042703-0-56-4-digit-seven-segment-numeric-display-red-5

I think maybe we are talking at cross purposes here?

I need to generate all 4 values of a 2-bit counter - i.e. 00, 01, 10, 11 - I don't actually care what order they appear in.

These become the A & B values in the truth table.

I will then decode these using logic to switch my LED digits on/off.

So, rough block diagram:

2-bit counter -> 2-bit decoder -> LED displays (active high)

The schematic above is the 2-bit counter only. I haven't done the decoder yet. 74LS139 would do that job, except it has active low outputs, and I want active high. As I have a small selection of Quad-NAND and Quad-NOR ICs, I'll just build the logic by hand.

ralphd:
Sparkfun's price is OK, though FastTech has a pack of 5 red 4-digit displays for 232c:
http://www.fasttech.com/products/1009/10000386/1042703-0-56-4-digit-seven-segment-numeric-display-red-5

Nice price - 46 cents each approx. Makes you wonder how Farnell get away with charging £3.28 (each!) for effectively the same thing

You're not wrong jiggy, R1 should in fact be between threshold/trigger & vcc, and discharge should be wired straight to Vcc. A cockup caused by the different pin layouts on the 556 vs 555...

Wiring Discharge straight to Vcc is also a cockup likely to cause your chip to explode. Is it really that important to have a 50% duty cycle? If so, you need another resistor and a diode to get duty cycles less or equal to 50%. You'll have to look up the circuit and formulas, because I don't remember offhand. Or, if 50% isn't that important, just use two resistors. You need it there to prevent DIscharge from becoming a short to GND.

Since it looks like you're just using the 555 as a clock input, duty cycle isn't that critical. You could just use a pair of resistors.

There should be no problem with this. A MAX6675 can run with an SPI clock of up to 4MHz (which happens to be the Arduino default) and it only transfers two bytes of data. Sixteen clock cycles at 4MHz is four microseconds, not "several milliseconds." I have written interrupt-driven multiplex code for a four-digit, seven-segment display. It gets control every 100µs via interrupts generated by one of the ATmega's internal timers. Actually every 1000µs would be fine, but I also implemented brightness control so I use the higher frequency to implement a 10-100% duty cycle. The only external hardware required is transistors for digit drivers and associated resistors, and of course resistors for the segment driver lines.

because of the way I did my multiplexing, the display "stalls" on the last digit

Can't you just change the way that you do the multiplexing in the arduino SW?

In any case, I don't see how you can get the single flipflop in a 555 to create a 2-bit counter or a 4-bit shift register. Since it's a simple set/reset flipflop, I don't see how you can get it to count at all.

74LS139 would do that job, except it has active low outputs, and I want active high.

So a 74LS04 will allow you to simply invert the outputs, you get 6 in a package.

You can make a two bit counter with a 74LS74 or a 74LS93.

However I agree with westfw you are better off solving your problem with the MAX6675 chip.

I'll ask the 6675 Q in another thread. It could be that i take 10 samples from it at a time. The flicker is less obvious if I take fewer samples.

Anyway... back to this exercise. What I've been trying to do is this:

555 No. 1 - is set up as a clock. Ideally 50% duty cycle or near as, because I want to use it's output as "B" in my truth table.
555 No. 2 is set up as a flip-flop (according to the link previously given - they used a switch instead of another 555 of course). This I wanted to "flip" or "flop" whenever 555 No. 1 went high - thus it would be forced to oscillate at 1/2 the speed of the first timer. This would be output "A" in my truth table.

I fixed a couple more errors in my schematic, added a 2nd resistor per jiggy's post (didn't want to fry my chips... and for initial testing a 50% duty cycle didn't need to be bob on. Especially as it turns out I'm sorely lacking in resistor & capacitor values).

Unfortunately, it didn't quite work; it "flipped" as 555-1 went high, and "flopped" when 555-1 went low; so basically it just mirrored it. See attached pic ("A" is the bottom trace, "B" is the top trace).

So: Plan B, I shall use a decade counter & a single 555 as a clock. Unless there's an obvious way of making the 555-2 only flip or flop as 555-1 goes high (or low - either way will work)? Basically, I want the 'scope to show the wave forms per the attached "DesiredWaveform" image.

What sort of shift register are you using? What pin will your decoder outputs be connected to? If it's the typical 74xx595s, those have an active low OE (Output Enable) input. Maybe you're looking at the Latch pin (STCP) by mistake.

There's a reason most decoders have active low outputs: most of the inputs that would use them are active low.

I need both active low (for the shift registers) and active high (for the common anode display)...

Wouldn't a common anode display work better with high-side switching with PNPs? In that case, active low will power the transistors the correct way, too.

Even if you need a mix of active high and active low, I'd recommend getting a 2-to-4 active low decoder and a hex inverter chip. That'll give you everything you need in 2 chips (with 2 inverters to spare), as opposed to the 3 or 4 NAND/NOR chips it would take you to implement the combinatorial logic of a decoder yourself. A dual D Flip-Flop chip can be your 2 bit counter (or just use a counter chip), and one 555 as the clock means you can implement this thing with 4 chips, max.

I'm actually using a 4022 octal counter to generate my pulses, and an inverting buffer to translate them to active high for the shift registers. I didn't take a pic of the 'scope showing that output, but it works perfectly.

I guess, using transistors, I could use this one sub-circuit to drive several displays - I do have a project in mind which will be use several 4-digit displays up...

PS: I am now using the 555 purely as a clock...

TS555CN are nice, way higher frequency than NE555P, 3.7MHz to 0.1MHz, meaning they're more accurate. Also they're low power, cost a little bit more mind you