Monday, September 23, 2013
A Car Battery Monitor
Just as I was going up a hill, the lights began to dim and the engine coughed. A large semi-trailer loomed in the rear-vision mirror as I pushed the clutch in and tried to restart. My speed was falling rapidly and my lights were blacked out - I was like a sitting duck in the middle of the road, as the semi-trailer came rapidly bearing down on me. I just managed to pull the car off the road, as the semi-trailer came screaming past, missing me by inches! After calling for assistance from the NRMA, the problem was found to be a fault in the alternator, which was failing to charge the battery. The battery voltage had been falling under the heavy load of the lights and at the worst possible time, there was not sufficient power for the lights or the motor.
After the initial shock wore off, I put on my thinking cap to come up with a PIC-based solution to the problem. What was really needed was a display and a buzzer, to get my attention should the voltage fall outside a specified range. So my design criteria was set, a series of LEDs could indicate the voltage and a buzzer would also be used to warn of problems.- Visual indication of battery voltage
- Audible warning when voltage becomes low
- Screw terminals for easy connection
- Simple and easy to build
The circuit is based on PIC16F819 18-pin microcontroller which has an analog-to-digital (A/D) input to monitor the battery voltage and outputs capable of driving LEDs directly, to keep the component count down. There are seven LEDs in all, giving a good range of voltage indication. The topmost LED, LED1, comes on for voltages above 14V which will occur when the battery is fully charged. LED2 indicates for voltages between 13.5V and 14V while LED3 indicates between 13V and 13.5V. Normally, one of these LEDs will be on. LED4 covers 12.5V to 13V while LED5 covers 12V to 12.5V. LED6 covers from 11.5V to 12V while LED7 comes on for voltages below 11.5V. These two LEDs are backed up by the piezo chime which beeps for voltages between 11.5V and 12V and becomes more insistent for voltages below 11.5V.
That might seem fairly conservative. After all, most cars will start with no troubles, even though the battery voltage might be a touch below 12V, wont they? Well, no. Some modern cars will happily crank the motor at voltages below 11V but their engine management will not let the motor start unless the voltage is above 11V. So dont think that a modern car will always start reliably. This little battery monitor could easily prevent a very inconvenient failure to start! So lets describe the rest of the circuit. The incoming supply is connected via diode D1 which provides protection against reverse polarity while zener diode ZD1 provides protection from spike voltages.
A standard 7805 3-terminal regulator is then used to provide a stable 5V to the microcontroller. The battery voltage is sensed via a voltage divider using 33kΩ and 100kΩ resistors. This brings the voltage down to within the 0-5V range for the A/D input of the PIC16F819. Port B (RB0 to RB7) of the microcontroller is then used to drive the various LEDs, with current limiting provided via the 330Ω resistor network. RB7, pin 13, drives a switching transistor for the piezo buzzer.
Software:
For the software, the design follows the basic template for a PIC microcontroller. Port A and its ADC (analog-to-digital converter) function are set up while port B functions as the output for the LEDs and buzzer. Once the set-up is complete, a reading will be taken at port RA2, the input for the A/D convertor. This reading is then compared with a series of values to determine the range of the voltage. This is similar to a series of "if" statements in Basic language. If the voltage is found to be within a certain range, the relevant port B pin will be turned on. If the voltage is below 12V, the buzzer will be turned on for a brief period, to signal a low battery condition. As the voltage falls below 11.5V, the frequency of the beeps will increase, to signal increased urgency.
All the parts are mounted on a small PC board measuring 46 x 46mm (available from Futurlec). The starting point should be the IC socket for the PIC16F819, as this is easiest to mount while the board is bare. The next item can be the PC terminal block. The resistors and capacitors can then follow. Make sure the electrolytics are inserted with correct polarity.
Make sure that you do not confuse the zener (ZD1) with the diode when you are installing them; the diode is the larger package of the two.Even more important, dont get the 78L05 3-terminal regulator and the 2N3906 transistor mixed up; they come in identical packages. The 78L05 will be labelled as such while the 2N3906 will be labelled "3906". And make sure you insert them the correct way around. The buzzer must also be installed with the correct polarity. The 330Ω current limiting resistors are all in a 10-pin in-line package. There are four green LEDs, two yellow and one red. They need to be installed in line and with the correct orientation.
Testing:
Before you insert the PIC16F819 microcontroller, do a voltage check. Connect a 12V source and check for the presence of 5V between pins 14 & 5 OF IC1. If 5V is not present, check the polarity of regulator REG1 and the polarity of the diode D1. If these tests are OK, insert the IC and test the unit over a range of voltage between 9V and 15V. Make sure that all LEDs come on in sequence and the piezo buzzer beeps for voltages below 12V.
Now it is matter of installing the unit in your car. It is preferable to install the unit in a visible position for the driver. However, it should not obscure any other instruments. The unit should be connected to the cars 12V supply after the ignition switch. This will turn the unit off with the other instruments and prevent battery drain while the motor is not running.
Author :Alan Bonnard Copyright : Silicon Chip Publications Pty Ltd
Friday, April 12, 2013
A Discharger for Receiver Battery Packs
There are a couple ways you could modify the circuit to work with a 5-cell 6-volt receiver battery pack. The two 1k resistors are a divider network, so one way would be to change the resistors to change the sampling voltage at the comparator. The formula for a divider network is Vout=Vin(R2/(R1+R2)) or R1=R2*((Vin/Vout)-1). Here, R1 is the resistor connected to the positive lead and pin 7 of the comparator, Vin is 5.25 volts (1.05 volts per cell discharge shutoff threshold), and Vout is the reference 2.1 volts (the voltage produced by the LM317T and the 180 and 270 ohm resistors). You can use R2 as the same 1k value that was there before. So R1=1000*((5.25/2.1)-1)=1500=1.5k. So swap the top 1k resistor in the schematic for a 1.5k, and the new shutoff voltage for your device will be 5.25 volts.
To increase the discharge rate, decrease the resistance of the load resistors. You could use four 100 ohm resistors in parallel instead of two, for example, and it would discharge twice as fast. Resistance of a number of resistors in parallel is the value of the resistor devided by the number of the resistors. Here, 100 ohms/ four resistors is 25 ohms. At five volts, current is (5 volts)/(25 ohms)=0.2 ampere or 200mA. Be careful not to decrease resistance too much however--the small signal transistor used in this particular circuit is probably only rated for maximum 500 mA.
Circuit diagram :
Parts:
273-074 Miniature Piezo Buzzer, 12v, PC board mount
271-312 1/4 watt 5% carbon film resistors, 500 pieces (Just do it!)
276-1778 LM317T adjustable voltage regulator
276-1712 Quad comparator LM339
276-1622 LED assortment (20 count)
276-2009 NPN Silicon transistor MPS2222A (2N2222)
Custom electronics:
I post this design not because I think this is a brilliant piece of circuit design but because the design works, and it can give you a start on your own experimentation. The idea is to use the power available from the discharging battery to monitor the voltage of the battery, shut off discharging at a preset voltage (here 1.05 volts/cell), and sound an alarm when discharging is complete. To do so means a voltage reference powered by the changing voltage of the battery, here the LM317T and the 180 with 270 ohm resistors. You could just as easily use a LM336 (see the low voltage warning buzzer page) or a zener with resistor, or something else as a reference. Since the reference voltage must be below the ambient battery voltage, a pair of 1k resistors provides the divided test voltage. The LM339 is a four way comparator.
This design uses really three comparators: in addition to the one driving the transistor, a comparator drives the LED and another drives the buzzer. But you could use a single comparator (like the LM311) with the buzzer across the emitter and collector of the transistor, and the LED in series with a 270 ohm resistor across (parallel with) the 100 ohm load resistors. With the transistor conducting, the voltage drop across base and emitter is low, and the buzzer is quiet. The tiny current in a piezo buzzer (7 mA), when the transistor is not conducting, would be divided between the load resistors and the LED, and the LED is dark.
A word about the comparator.
Build a Digital Stopwatch 0 60sec

Monday, April 8, 2013
How to Make a Small Homemade Automatic Voltage Stabilizer for TV sets and Refrigerator
Referring to the figure we find that the whole circuit is configured with the single op amp IC 741. It becomes the control section of the whole design.
Saturday, April 6, 2013
Build a LT3582 12 DC 5V to 12V DC Converter

Friday, April 5, 2013
How to Drive a Relay through an Opto Coupler Circuit
The question was asked by one of the interested members of this blog, Miss Vineetha.
Before studying the proposed design, lets first understand how an opto coupler works.
An opto-coupler is a device which encapsules an LED and a photo-transistor inside a hermetically sealed, water proof, light proof package in the form of an 8 pin IC (resembling a 555 IC).
The LED is terminated over a couple of pin outs, while the three terminals of the photo-transistor is terminated over the other three assigned pin outs.
The idea is simple, its all about providing an input DC from the source which needs to be isolated to the LED pin outs via a limiting resistor (as we normally do with usual LEDs) and to switch the photo transistor in response to the applied input triggers.
The above action illuminates the internal LED whose light is detected by the photo-transistor causing it to conduct across its relevant pin outs.
The photo-transistor output is normally used for driving the preceding isolated stage, for example a relay driver stage.
As shown in the following circuit diagram, the relay driver may consist a NPN transistor or a PNP transistor.
If its a PNP transistor, the base is coupled at the collector of the photo transistor, alternatively, if a NPN transistor is used in the relay driver, the trigger is received from the emitter of the photo transistor quite like a Darlington paired configuration.
The rest of the operations are self evident.

Thursday, April 4, 2013
How to Make a Long Duration Timer Circuit
A simple timer can be built through many countless options. You can transistors, CMOS gates like NAND gates, NOT gates, linear ICs like 555, 741, 324, or simply more specific type of CMOS IC like the 4060.
All these devices besically generate oscillations which are adjustable right from a few Hz a second to a atomic fraction of a Hz.
Further more these ICs can be integrated together to form more complex timer circuits that may be used for generating very long time intervals.
In this post we see how two different modes of ICs are coupled together to form a long duration timer circuit.
Referring to the circuit diagram.
IC1 is an oscillator counter IC consisting a built in oscillator stage and generates clock pulses with varying periods across its pins 1,2,3,4,5,6,7,9,13,14,15.
The output from pin 3 produces the longest time interval and therefore we select this output for feeding the next stage.
The pot P1 and the capacitor C1 of IC1 can be used for adjusting the time span at it pin 3.
The higher the setting of the above components the longer the period at pin #3.
The next stage consists of decade counter IC 4017 which does nothing but increase the time interval obtained from IC1 to ten folds. It means if the the time interval generated by IC1s pin #3 is 10 hours, the time generated at pin #11 of IC2 would be 10*10 = 100 hours. Similarly if the time generated at pin #3 of IC1 is 6 minutes, would mean a high output from pin#11 of IC1 after 60 minutes or 1 hour.
When power is switched ON, capacitor C2 makes sure that the reset pins of both the ICs are appropriately reset, so that the ICs begin counting from zero rather than from some irrelevant intermediate figure.
As long as the counting progresses, pin #11 of IC2 remains at logic low, such that the relay driver is held switched OFF.
After the set timing lapses, pin#11 of IC2 goes high activating the transistor/relay stage and the subsequent load connected with the relay contacts.
The diode D1 ensures that the output from pin#11 of IC2 locks the counting of IC1 by providing a feed back latch signal at its pin #11.
Thus the whole timer latches until the timer is switched OFF and restarted again for repeating the entire process.

R1, R3 = 1M
R2, R4 = 1K,
C1, C2 = 1uF/25V,
D1, D2 = 1N4007,
IC1 = 4060,
IC2 = 4017,
T1 = BC547,
POT = 1M linear
RELAY = 12V SPDT
A Simple Function Generator
The circuit consists of integrator IC1b, whose output is applied to comparator IC1c. The output of the comparator is a rectangular signal The output of IC1b is raised by amplifier IC1d to a level that allows the full output voltage range of the operational amplifier to be used. Op amp IC1a provides a stable virtual earth, whose level is set to half the supply voltage with P1. The smooth setting of the frequency is made possible by feedback of part of the output of the comparator to the input of the integrator via P2. This preset is usually not provided in standard triangle-wave generators. Network D1-R1-D2-R2-P3 makes it possible to give integrator capacitor C3 different charging and discharge times.
Waveform variable independently of frequency (triangle wave and sawtooth)
Duty cycle of rectangular signal can be set independently of frequency
Applications:
Test and measurement
Pulse-width control
Summary of preset action:
P1 – sets virtual earth to a level equal to Ucc/2;
P2 – sets the frequency;
P3– sets the waveform;
P4 – sets the hysteresis of the comparator (frequency and amplitude of the triangle-wave signal)
P5 – sets the amplification of the triangle-wave and sawtooth signals.