Saturday, February 1, 2020

0000 0000 0010 0000

CD4017 Frequency Divider IC (again...)

I ran into a problem when testing (playing with) the 555 square wave signal generator. If I use small values for the capacitors (<100pf) and resistors (<2k), then the timer frequencies rise and I have a lot of trouble checking the output of the generator with my cheap DSO138 oscilloscope (limit 200kHz). The signal looks like it degrades and then disappears from about 50kHz onwards.


Mmmm...not much of a "square" wave at 50kHz
Yep, and all squares gone at 150kHz
I wanted to know if the obvious signal degradation at higher frequencies was a function of the oscilloscope or the signal generator itself, so I needed a way to "slow" the signal up to measure - like an electronic gear system.

When searching online for solutions ("NO to a $500 oscilloscope!", says the budget-master) I found a couple of references to using a CD4017 decade counter. I have used this chip before and blogged about it already when I made a stupid clap switch circuit.

In some configurations this chip is capable of frequency division, for example taking a clock input of 100Hz and dividing it by two to output 50Hz. It can maximum divide by a factor of 10 (pin 15 tied to ground), so I thought that at least I could "down shift" the signal by this amount and maybe get more sense from the oscilloscope.

In the CD4017 datasheet there is actually a hint that you can "cascade" the counters and thus continue dividing by 10. So if I can link three such chips correctly, I could now lower the frequency by a factor of 10x10x10=1000, so a dodgy signal at 50kHz=50000Hz might perhaps be readable by my dumb 'scope at 50Hz.


The cascade shown in the datasheet seems like an overly complicated circuit with overflows, AND gates, etc. I thought that maybe all I really need to do is pump a signal from one CD4017 (divided by 10) into the input of the next chip as per the following circuit diagram.


The yellow wire is the signal from the 555 generator to pin 14 (clock, indicated with a blue LED), then each chip is powered by a red wire from VCC. Blue is GND, grey from GND to pin 13 (clock inhibit) will make the counter advance one at the positive edge of the clock signal. Orange from pin 15 (reset) tied to ground makes the IC divide by 10.

Finally, white from chip 1 (pin2 - output) to chip 2 (pin 14 - clock) and from chip 2 (pin 2 - output) to chip 3 (pin 14 - clock) provides each cascaded chip with the divided by 10 signal from the previous chip. I will test this version of a cascading signal divider with a lower frequency first, and then ramp it up and see what's happening at the higher frequencies.


I have a strong suspicion at the end of this investigation that the lovely square wave we can see on the screen at these higher frequencies is a result of monitoring the output of the CD4017 IC, which squares the signal off nicely, even if you feed it a sine wave (see the video). Maybe the signal generator output is genuinely "messy" at higher frequencies? 

So I guess to resolve this remaining question I will need to start campaigning to higher powers to fund a proper oscilloscope so that I can measure the direct output!

In the meantime with the help of the CD4017 I can output a clean square wave at high frequencies from the 555 timer (indeed an opAmp or comparator would also be a solution to "squaring off" a messy signal). It is nice to know that I can make a fit for purpose clock signal - I think I'll feed it to an Attiny85 as an external clock just for fun at some stage.





Saturday, January 25, 2020

0000 0000 0001 1111

FS8205A Mosfet Battery Protection

Not so much a circuit I build this week, but rather a commercially bought circuit/shield that I thought I'd have a crack at repairing. I ordered some 18650 battery chargers which also double as a power supply (claimed 3V-1A and 5V-2A output).

Everything looked wonderful until I didn't read the many warnings on both the board and the website and stuck an 18650 battery into the holder with the wrong polarity. ZAP!! Burnt finger for me, and magic smoke production for the charger.

Always read the fine print
I suppose a normal person would throw the whole thing in the bin and look for a commercial replacement at many times the cost. But after taking a closer look at the broken board I thought that only one component looked completely spooked by the experience - a little 8-pin TSSOP package sitting on the edge of the board. I couldn't tell what the label was through the charred remains, but in an un-fried version of the same board it seemed to be a FS8205A Mosfet Battery Protection IC. The cost of a new charger/power supply is around AUD 3.81, and cost of 10pcs FS8205A is around AUD 0.77, so no problem - order and wait.

When the chips arrived, it was simply a matter of de-soldering the fried chip using a hot air gun, and then plonking on the replacement and re-soldering. I do enjoy the SMD soldering and if you are a little wary of it then order one of the many practise kits available and have a go - it's not that difficult. A pair of comically large enlargement glasses can help as well.

Normal operation

Fried guy

De-soldered old chip with keen replacements in the background

Re-soldered and ready for action
The end result is a working charger and power supply, and a glow of satisfaction for it's owner. Nice one.


Postscript: the "un-fried" charger went "fttt!" as well with the same component at fault, and this time I didn't put the battery in the wrong way, so obviously a bad batch of mosfets and probably the reason for offloading stock cheaply to unsuspecting Tasmanians half a world away. Anyway, a desoldering and resoldering session ensued and now I have two perfectly fine chargers/power supplies!








Saturday, January 18, 2020

0000 0000 0001 1110

Your own PCB (final)

So the lovely 555 based square wave signal generator PCB arrived from JLCPCB. The story so far:

  1. Dream up a suitable project to illustrate how easy it is to make a PCB, this one based on the 555 timer which can output a square wave signal of variable frequency
  2. Design and test the proposed circuit on a breadboard
  3. Use online software to connect all components in the circuit in preparation for ordering and manufacturing
  4. Layout PCB design and order the PCB, then wait by the postbox for a couple of weeks

So now the only thing left to do is to assemble and test the PCB. Note that I used the TLC555 version of the 555 timer which is CMOS based and not only uses a lower voltage, but also requires very little current in operation. The TLC555 can also output a much higher frequency than the bog standard NE555 - 2MHz vs 500kHz. There are other versions of the 555 around as well - nice chip!

"Panelized" board from JLCPCB
Most components are SMD, arriving from LCSC
Components gathered and ready to solder
The signal generator ready to fire up






Saturday, January 11, 2020

0000 0000 0001 1101

HT7850 SOT-89 5V Voltage Regulator

Some voltage regulators are known for their inefficiency, and some for their stability. The HT78XX series of regulators are touted as:
... a series of positive, linear regulators feature low quiescent current (5uA typ.) with low dropout voltage, making them ideal for battery applications. The devices are capable of supplying 500mA of output current continuously. They are available with several fixed output voltages ranging from 1.8V to 5.0V. Although designed primarily as fixed voltage regulators, these devices can be used with external components to obtain variable voltages and currents. These rugged devices have Thermal Shutdown and Current Limiting to prevent device failure under the "worst" of operating conditions.
I wondered if "500mA of output current continuously" is true, and also what are "worst" conditions and can I replicate that? Firstly though, what do you do with SOT-89 packages if you want to test a component on a breadboard in a circuit? I found a few options in the buckets including a legit SOT-89 to DIP adapter, a SOIC-8 to DIP-8 adapter and finally a standard two sided blank prototyping PCB.



These little blighters aren't cheap, and one thing spotted AFTER ordering (¯\_(ツ)_/¯) is that they have a max input voltage of 8V - not much compared to say the LM78XX which is happy with a 35V input. Anyway the "fun part" for me is the soldering so away to the bench.


Clipped prior to soldering


On the way to making the adapter


The DIP-8 version having headers added
The frankenstein version on a bog standard PCB


So now that we have the soldered versions ready to test - let's try a few variations on a theme, using the suggested "basic circuit" from the datasheet with a load of a resistor and 3W LED.







The last thing to try is maybe use this little linear regulator instead of a zener diode in the QX5252 circuit. 



So you can see from the above that at 1V input to the joule thief, I replaced the 5.1V Zener with the HT7805 and it works! Not only for an LED, but wafting the ergs out to an Attiny13 with a blinky sketch also worked fine - now that could be very interesting for the future - watch this space.





Saturday, January 4, 2020

0000 0000 0001 1100

CD4026 7-segment Counter

Take two on this chip as those in the bucket originally were FAKE! So I got my money back from AliExpress and re-ordered. The wait was worth it because they turned up a few weeks later and actually worked as advertised - nice.

There was only one unanticipated problem - the outputs from the CD4026 chip are "1" for "HIGH" which turns on each segment from a common cathode 7-segment display, but sadly if you only happen to have common anode 7-segment displays in the parts bucket then the result takes a little interpretation. 


Red = what is lit, Green = what should be lit!
I have ordered some common cathode displays to make better (easier) use of the chip, but in the meantime I looked for a solution - is it possible to turn all "1" signals to "0" and vice-versa?

Well, yes! You just need an IC that has multiple NOT gates - for instance a CD4069 Hex Inverter as per last week's blog would be perfect, just add one transistor based NOT gate to complete the seven required inverters and hey presto we have a display that works on "1"s and not "0"s.



In "real life" the result is as shown in the video below.


Eagle-eyed viewers will spot a lone resistor going from the transistor not gate to segment D. There's a case to be made for resistors on all outputs as seen in many circuits shown online. I just threw one in here as the single segment output from the transistor not gate was showing up brighter on the display and it became a little distracting. A 220Ω resistor cured the imbalance and the resultant overall display was more evenly lit.





Saturday, December 28, 2019

0000 0000 0001 1011

CD4069 CMOS Hex Inverter

What to do when your signal comes out reversed from what you need? If it is only one problem signal, then you could whip up a transistor-based solution as per this useful website. If you need seven signals inverted because of an ordering mishap, then a hex inverter (plus a single transistor solution) might be a better approach.

An inverter is a common logic gate (NOT gate) which has the following symbol and truth table.



If you clump a few NOT gates together in a logic chip - you get a CD4069 hex inverter (see screenshot from the datasheet below). So a "1" or "HIGH" sent to pin 1 (A) returns a "0" or "LOW" on pin 2 (G=Ā), and vice versa.




Fortunately in the many buckets of bits I have a few CD4069UBE chips lying around looking for a purpose. The pinout is very straight forward, but before I use the whole chip to reverse a bunch of signals (next blog), I will test it on a very simple circuit - involving of course a blinking LED.



The 555 is not really disembodied out to the side, but it is just shown here providing a clock signal which is a "1, 0" square wave at a particular frequency. And to show that all of the inputs/outputs are ready for quality inverting, I've plugged all six in plus an extra transistor NOT gate - but why seven? Well, next time I'll look at "fixing" a seven segment display gone slight awry.









Saturday, December 21, 2019

0000 0000 0001 1010

Your own PCB (Part IV)

Now that the 555 signal generator circuit has been designed and tested, the next step is to arrange all of the components on a PCB and hit the manufacture button (oh, and pay!). There are heaps of options but there are just two important ones for me that I'll mention - a copper ground layer (which I always add to my PCBs now that I know how to do it) and panelising the design to maximise the number of PCBs for the price paid.

I like to use a local autorouter, but hard core designers will lay down all the tracks as well - more power to them. My early efforts at manual routing took a lot of time, and although it was a good learning exercise I now just go straight to the autorouter running locally. Fast and accurate!

Try not to stress too much about the design as I don't think I've yet ordered a PCB that I've been entirely happy with - there will always be a detail or two that you don't like and will need to change. Some of my PCBs are on their fifth or sixth iteration and I'm still unhappy! Keep experimenting with the design and take a few days and a few revisits before you hit the "order" button.

I laid out this circuit on a board four times then had it manufactured, noting when it arrived that the connection between pin 6 and the potentiometer had not been made! I can still use the boards (after a quick solder), but this video is about version 5 which I hope has everything ironed out.

Here is a quick video of the 555 signal generator (V5) being laid out.


If you want to make/modify this project, you will find all of the files zipped up and available through this link.

When the PCBs arrive I will solder up the resulting PCB and run it through it's paces.