Saturday, August 31, 2019

0000 0000 0000 1010

The ubiquitous 555 timer

Since 1971 the 555 timer has been chugging along providing all manner of pulses for hobbyist projects along with serious electronic devices. When you need accurate, cheap and reliable timing, the 555 is your chip. You can buy a hundred of them for a pittance, and then scour the net for a hundred applications. There are a few variations (e.g. low current CMOS ICs), but I return to the NE555 because it's pretty rugged and I've only blown up a few by mistake!

I will make a few 555 circuits in this blog, but for the moment I'll start with a basic variable frequency square wave output, found in many guises all over the place. A quick search online reveals many 555 calculators, but I'll use this one to make the circuit below.










Saturday, August 24, 2019

0000 0000 0000 1001

TSOP4838 IR receiver

Although some of the components featured on this blog have been purchased and used in projects, there is a lot of stuff I really don't know why I bought - a bit like storing nuts for a rainy day I guess, or maybe just because I'm nuts.

Anyway I stumbled across a packet of weird looking bulging three prong components in the plastic tubs of goodies and identified them as TSOP4838 IR receivers. I'm guessing they could be useful, but for now I just wanted to test them and make sure that they did what is advertised on the packet - receive IR signals. 




I originally built a circuit which had an LED shining brightly and then flickered a bit when an IR remote activated the TSOP4838, and that was perfectly fine, but it would have been a bit of a fall in complexity after last week's effort!

So I kept poking around the internet and found a more engaging circuit which had two things of interest - firstly the indicator LED was off until activated, and secondly it used a PNP transistor. I have a few packets of PNP transistors but could never see the point of them until now. From the link above comes the following revelation:
"We have use BC557 PNP transistor here, to reverse the effect of TSOP, means whenever the output is HIGH LED will be OFF and whenever it detects IR and output is low, LED will be ON. PNP transistor behaves opposite to the NPN transistor, it acts as open switch when a voltage applied to its base and acts as closed switch when there is no voltage at its base."
Although the internet version of the circuit has both a receiver and an emitter (provided by a 555 timer set at 38kHz), I thought I'd be a bit lazy and just point a TV remote at the receiver and see what happened. Also now that I can see that the circuit works well, it can be easily used to check if I need to replace the batteries in a remote control.

Here's the circuit on fritzing:


And here it is in "real life", plus a video of it in "action".







Saturday, August 17, 2019

0000 0000 0000 1000

LM393 comparator (and the LM358 Op Amp)

Measuring stuff in the real world can be messy - for instance when the ambient light drops around dusk it can oscillate about a value which you may be trying to measure (e.g. to turn on an artificial light). I have dealt with this same scenario a couple of times.

One project I have measures light exactly in this way, but I have an attiny13 microcontroller providing software hysteresis by switching on if the sensor value is above "350", but not switching off until the value is below "250". These are nominal values.


Noisy signal tamed by hysteresis (green lines)
Another project uses an LM393 voltage comparator to poll a magnetic sensor and then feed a digital 1 or 0 to the microcontroller. The magnetic sensor is noisy, but the resultant digital signal rings loud and clear.

Configured as Schmitt trigger the LM393 hysteresis is provided according to the following diagram and formulae.




I've seen a lot of formulae and online calculators for hysteresis using op amps and comparators, but the equations shown above for Vth and Vtl actually work when measuring all of the parameters (including crucially the Vol and Voh numbers), as can be seen in the screenshot below from a spreadsheet.




So now we construct the circuit shown below based on those numbers, first with fritzing and then on a breadboard.






In the circuit above 9V supplies three key components. Firstly 9V is fed to the LM317 from a previous blog which then provides variable signal voltage to Vin.

Secondly the op amp/comparator needs to be powered itself and accepts 2V to 36V.

Finally 9V is fed to a voltage divider that supplies the reference voltage (in this case 5V).

When the LM317 signal is above the upper threshold (~5.5V) then the output of the LM393 is high (2.66V). When the signal drops below the lower threshold (~5.2V), the output drops to low (0.03V). 2.66V is enough to weakly drive a lot of LEDs, but most likely it is better to use a transistor switch as shown in the video below.





So we get lovely hysteresis after all of that, importantly based on some measured values. It's a bit of a dark art and I've certainly read much conflicting advice on the subject - but if you're keen there is some quality information available. Good luck.



Sunday, August 11, 2019

0000 0000 0000 0111

HT7333 Voltage Regulator

This week I'll put the HT7333 voltage regulator into a circuit. I chose these for an IoT project centred around the ESP8266, which needs an input of ~3.0-3.6V. At the time I was using either 6V lantern batteries or 3xAA (4.5V) batteries which (would have) fried the ESP8266. Initially using a linear voltage regulator, I was a bit shocked by the losses in the conversion (and therefore how quickly the batteries drained), so looking around and using this video as a guide, I chose the HT7333 for it's low quiescent current (4μA).

I'm not convinced now that it is the best option as it can only output around 250mA - and often the ESP8266 needs a little more beef. I've tacked on a 1000μF or a 2000μF capacitor sometimes to act as a backup for this situation when the ESP8266 wants to connect to the internet - but now I get a bit worried about losses through capacitor leakage.


From the datasheet
I have both TO-92 and SOT-89 packages for this IC, and definitely the TO-92 is easier to solder - but I do like the smd packages and the challenges that arise from their use (plus the size is sometimes important). 










Saturday, August 3, 2019

0000 0000 0000 0110

Two LM317 voltage and current controllers

A while back I discovered the versatility of the LM317 chip - it can control voltage in one configuration and current in another. Whilst a switching voltage regulator would be great for efficiency, the linear regulator such as the LM317 provides lovely steady power. So soon I'll be building a power supply that includes a switching regulator to take the voltage down to a couple of volts more than needed (thus giving great thermal efficiency) and then uses two LM317 chips working together to provide the smooth voltage and current required.

From the data sheet here is the voltage regulator circuit.

And here is the current regulator circuit.


Testing the LM317 as a voltage regulator


Testing the LM317 as a current regulator

Finally I grabbed a 32V AC-DC adapter, plugged it in to a cheap power supply module and then into the breadboard with the LM317 twins configured first for voltage and then for current.


When the buck converter arrives I'll pop it, the LM317s and some other bits and pieces into a nice box and have a pretty nifty bench power supply.