Advertise Box

Showing posts with label Power Supply. Show all posts
Showing posts with label Power Supply. Show all posts

LM1578A Switching Voltage Regulator
The National Semiconductor LM 1578 A is a switching regulator which can easily be set up for such dc-to-dc voltage .conversion circuits as the buck, boost, and inverting configurations. The LM 1578 A features a unique comparator input stage which not only has separate pins for both the inverting and non-inverting inputs, but also provides an internal 1.0 V reference to each input, thereby simplifying circuit

LM1578A Switching Voltage Regulator
design and PC board layout. The output can switch upto 750 m A and has output pins for its collector and emitter to promote design flexibility. An external current limit terminal may be referenced to either the ground or the Vin terminal, depending upon the application. In addition, the LM 1578 A has an on board oscillator, which sets the switching frequency with a single external capacitor from < 1 Hz to 100 kHz (typical). It operates from supply voltages of 2 V to 40 V. It is provided with current limit and thermal shutdown. Duty cycle up to 90 %. Functional diagram is given in figure.
Description.
When compared to linear voltage regulators the switching voltage regulators are much power efficient. In the case of linear voltage regulators the difference between the input and output voltage is just wasted and for switching regulators there is almost no such wastage and that’s why the switching regulators have great power efficiency ranging up to 85% . In simple words, the switching regulator operates by taking small bits of energy from the input voltage source and then transferring it to the output with the help of a solid state switch and a control circuitry. Since the switching element is either fully open or closed at any moment, no energy is wasted  across it. The control circuit controls  the duty cycle of the solid state switch which in turn determines rate at which energy is transferred to the output.
The electronic circuit given here is of a simple and low cost switching regulator using the IC LM317 that can deliver up to 3A of current. The input voltage range of this circuit is between 8 to 35V DC and the output voltage can be adjusted between 1.8 to 32V DC. The output voltage can be adjusted by using the POT R4.
Circuit diagram.
3A switching regulator
Notes.
  • Assemble the circuit on a good quality PCB.
  • C4 and C3  must be a solid tantalum capacitor.
  • Transistor T1 and IC1 require heat sinks.
  • L1 can be a 600uH inductor.
                                                    Digital Multiple Voltage Power Supply
                                                        1.2 to 33 Volts DC @ 3 Amps




Description


The hart of this circuit is a LM350 adjustable positive voltage regulator (T2). The voltage regulator is capable of supplying in excess of 3 amps over an output voltage range of 1.2Vdc to 33Vdc. Its ease of use, thermal overload protection, large voltage range, current limiting, and high ripple rejection make it a great choice for a variable power supply. The voltage (on the Vout pin) is regulated by the current traveling out the ADJ pin through a resistor to ground. Therefore by changing the resistance the outputted voltage will change.  

Changing the resistance is controlled by an Atmel ATtiny2313 microcontroller (U1). The microcontroller has 2 main functions collecting user input and changing the output. Collecting user input is easy; there are two buttons (S1-S2), one to go to the next voltage and the other to go to the previous voltage. The buttons are connected to the microcontroller pins PD2 and PD3. When a button is pressed the microcontroller sees a high signal (+5 volts) on the corresponding pin. The rest of the time, when a button is not pressed the microcontroller sees a low signal (0 volts) on the corresponding pin because the pin in connected to ground trough a resistor (R2-R3), called a pull down resistor.
When the microcontroller sees an input pin change from low to high, it sends a high signal (+5 volts) to an output pin. There are five output pins PB0 PB1 PB2 PB3 PB4, each going through a small current limiting resistor (R4-R8) to a led (D2-D6), so you can see what the current selected voltage is, then to the base pin of a small 2n2222 transistor (Q1-Q5).
Each transistor has a resistor connected to its collector pin and its emitter pin connected to ground. When the transistor receives voltage on its base pin, power will flow from the collector to the emitter. This basically turns a resistor on or off which changes the current on the ADJ pin of the LM350 (T2).
The LM7805 (T1) is just a basic fixed 5 volt dc regulator to provide power to the microcontroller.
Diode D1 protects the circuit from a positive voltage being attached to ground.
Capacitors C1 C2 C3 C4 and C5 are used to keep steady power and decouple parts of the circuits.  

The LEDs don�t need to be mounted to the PCB. They can be mounted in a panel to easily display the selected voltage, or excluded completely and replaced with a jumper wire. They are currently set at the following values:
D2 -> 3.3v, D3 -> 5v, D4 -> 7v, D5 -> 9v, D6 -> 12v
Changing the value of R9-R15 will change the preset voltages to any voltage you want.
Where Ra is the component R9 and Rb is the component R10-R14 in parallel with R15. Remember that R10-R14 is in parallel with R15 and their value needs to be calculated as such.



Schematic





Diagramms






Parts List


Quantity
Reference
Description
1
R1
12k Ohm 1/8 Watt Resistor
2
R2, R3
10k Ohm 1/8 Watt Resistor
5
R4-R8
220 Ohm 1/8 Watt Resistor
1
R9
220 Ohm 1/4 Watt Resistor
1
R10
430 Ohm 1/8 Watt Resistor
1
R11
940 Ohm 1/8 Watt Resistor
1
R12
1874 Ohm 1/8 Watt Resistor
1
R13
3.6k Ohm 1/8 Watt Resistor
1
R14
13.6k Ohm 1/8 Watt Resistor
1
R15
2.2k Ohm 1/8 Watt Resistor
 
 
 
1
C1
2000uF  50v Capacitor
1
C2
470nF  50v Capacitor
2
C3, C4
100nF  Capacitor
1
C5
47uF  Capacitor
 
 
 
1
U1
Atmel ATTINY2313 Microcontroller
 
 
 
5
Q1-Q5
2N2222 NPN Transistor
 
 
 
1
D1
1N5402 3 Amp Diode
5
D2-D6
5mm generic LED
 
 
 
1
T1
7805 voltage regulator 5volt
1
T2
LM350T
 
 
 
2
S1, S2
Generic Momentary Switch or Button
2
J1*, J2*
Tyco 282841-2
*Not necessary

MCU Programming


The C# code for the microcontroller is in the file: MCU_Power_Supply.c
It can be easily modified to control 36 different voltages with this same circuit.  

Set the SUT_CKSEL fuse to: �Int. RC Osc. 4 MHz; Start-up time: 14 CK + 65 ms�
Make sure the CKDIV8 fuse is not set.  

The PCB also has connections for Rx Tx and PD6 so that an LCD display, computer control, and extra inputs and outputs can easily be added.

PCB











One important parameter in embedded system designing is power consumption. This parameter is directly related to the battery lifetime, if the system is to be powered from a battery. In order to determine the power rating of your designed system, you need to know how much current the system draws from the source at a given voltage. While working on my projects, I usually measure current by placing an external ammeter in series with the current’s return path. This is not always convenient to do, and so I thought of making a special power supply unit for my lab that would display both voltage and current information on a LCD screen while prototyping my circuit. This way I can continuously monitor how much power my test circuit is drawing at a specific operating voltage.

Multifunction bench power supply

This power supply unit provides fixed ±5 V as well as a variable dc voltage ranging from 1.25 V to  9 V. A PIC16F689 microcontroller is embedded into the power supply unit to measure the adjustable output voltage along with the load current. Besides, this unit also has a built-in frequency counter to measure the frequency of an external signal. The range is over 50 MHz. However, it has been tested up to 20.0 MHz, and works fine. There are still few I/O ports of PIC16F689 that are not used. So I am thinking about adding one or more features (like capacitance meter) to it. But that would be on my second version.
Theory
The fixed ±5 V power supplies are derived using LM7805 and LM7905 regulator ICs. A 12 V rectified output from a center-tapped transformer provides the dc inputs to these regulator ICs. For the variable dc output, a LM350 IC is used. LM350 is an adjustable 3-terminal positive voltage regulator that is capable of supplying in excess of 3A over a 1.2V to 33V output range. It requires only 2 external resistors to set the output voltage. Since my dc input is only 12 V (rectified output from the transformer), the regulated output from the LM350 IC would go up to 9 V (3 V less than the input, as specified in the datasheet). In order to obtain the full range of output voltage (up to 33 V) from LM350, you need a transformer with a higher output voltage. I rarely use power supply above 5 V in my projects, and therefore, a variable voltage source up to 9 V is good enough for me.
Next comes PIC16F689 microcontroller that measures the LM350 output voltage and current. You are right, I am implementing voltage and current measurement only to the LM350 output. The principles of voltage and current measurements using microcontroller were discussed in two of my posts: PIC-based digital voltmeter and How to measure dc current with a microcontroller. I am not going to repeat the details here. Both the parameters can be measured with built-in ADC channels of PIC16F689. Since the output voltage from LM350 could go higher than 5 V (up to 9 V in this situation), it is not directly  measurable from an ADC channel. A simple voltage divider network using two resistors is incorporated to scale down the output voltage to the safe ADC input range (0-5 V). On the other hand, the current to be measured must be first converted into voltage so that it could me measureable too with the ADC channels. The current to voltage conversion can be done by placing a small value resistance (shunt) in series with the current path. The voltage drop across the resistance will then vary linearly with the current. I am using a 0.286 Ω resistor (Rs) made by myself by coiling a 5 ft long 22 AWG solid copper wire that has a plastic insulation on its outer surface (see the picture below).

Current sensing resistor
Since this resistance is so small in value, the voltage drop across won’t be very high for small currents. Even for 1 A of current, the voltage drop across it would be only 0.286 V. To improve the resolution (and hence accuracy) of current measurement, this voltage must be amplified before the AD conversion process. An operational amplifier with a suitable gain can do this task. The figure below shows how this whole technique works.


Block diagram for voltage and current measurements
An interesting thing to be noted here is that the output voltage across the load (Vo) is actually the measured voltage (Vm) minus the voltage drop across Rs (Vs). For small load current, the difference between Vm and Vo won’t be very much, but it could be significant for higher current. For 1 A of load current, the output voltage across the load is 0.286 V less than the measured output voltage from LM350. This error will be corrected later in the software part by subtracting Vs from Vm.
The frequency counter uses Timer0 module in counter mode to measure the frequency of an external signal. A single transistor preamplifier stage is used to boost the low amplitude signals before they are sent to the Timer0 module for counting. An easily available BF199 RF transistor is used for this purpose.
Circuit Diagram
As mentioned earlier, two linear regulator ICs (LM7805 and LM7905) are used to derive fixed ±5 V supply. A center-tapped transformer output is rectified (using diodes) and filtered (using 4700 µF capacitors) to obtain unregulated ±12 V dc that serve as inputs to both the regulator ICs. The circuit diagram below shows all the components and their connections required for the fixed power supply.
Circuit diagram for fixed +/- 5 V supply

The variable power supply unit uses an adjustable regulator IC (LM350). The output voltage can be controlled through resistors R3 and Rp (see figure below). The expression for output voltage is, Vo ≈ 1.25 x (1+Rp/R3). This specific design allows the output voltage to vary from 1.25 to 9.0 V. R1 and R2 create a voltage divider network to scale the output voltage within the safe limit (0-5 V) of the microcontroller’s ADC channel. An additional zener diode at the output ensures that the input voltage at PIC’s ADC channel won’t be greater than 5.1 V. The scaled output is connected to AN0 channel (pin 19) of PIC16F689.


Variable power supply with voltage and current measurement
The measurement of current is possible with a shunt resistor (Rs = 0.286 Ω) and an operational amplifier circuit. Rs is placed on the return path of the current and therefore, the voltage drop across it is proportional to the current drawn from the variable power source. This voltage is first amplified by a non-inverting Op-amp circuit and then passed through another non-innverting buffer stage to lower the output impedance. The output from the buffer goes to AN4 channel (pin 16) of PIC16F689 for A/D conversion. With R4 = 1.3 K and R5 = 12 K, the overall gain of Op-amp stage is 10.23. I am using LM324 IC for the Op-amp stage. LM324 does not provided rail-to-rail swing; the maximum output is about 1.5 V less than the applied power supply voltage. In this case, LM324 is powered with 0-5 V, and therefore, the maximum output voltage could be about 3.5 V. This means the maximum input voltage to the Op-amp stage would be 3.5/10.23 = 0.342 V. This gives the maximum range of the measurable current to be 0.324/0.286 = 1.2 A. Current values higher than this will saturate the LM324 output. The range of the measurable current can be increased either by decreasing the gain of the Op-amp stage or by using  a different Op-amp IC that provides rail-to-rail output swing (0-5 V).
The preamplifier stage for the frequency counter has an RF transistor (BF199) that is collector-feedback biased using a 10 K resistor. The 1 K resistor with diodes D1 and D2 at the input side clamp the input signal levels to ±0.7 V. The 0.1 uF capacitor eliminates any dc component presented in the input signal. The amplified output is derived from the collector with a 470 Ω resistor in series and is sent to T0CKI pin of PIC16F689. The Timer0 module counts the number of incoming pulses through the T0CKi pin to determine the incoming frequency.


Pre-amplifier stage for frequency counter
PIC16F689 runs with an external 20.0 MHz crystal. A 16 x 2 character LCD (HD44780 compatible) is interfaced in 4-bit mode. Data were transferred through RB4-RB7 pins whereas the RS and E signals are controlled through RC7 and RC6 pins, respectively. A diode connected between RC1 and RA2 acts as a gating enable for frequency counter. When RC1 is high, the T0CKI input is also held high, disabling the counting process. RC1 is set to low when the microcontroller has to count the external pulses from the preamplifier stage output. The 470 Ω resistor at the output of the preamplifier stage is to prevent any possible short circuit at T0CKI pin due to the voltage conflict between pins RC1 and RA2.


Microcontroller I/O port assignments
I constructed the complete circuit on a 180 mm x 128 mm general purpose prototyping circuit board which is shown below
.
The complete circuit soldered on a general purpose prototyping circuit board.

Front panel installation
A/D Conversion Math
The use of A/D conversion for voltage and current measurements require some math to re-convert the digital outputs back to the voltage and current for display. Let’s work on displaying the voltage first. The analog input voltage (Va) at RA0/AN0 pin is related to the A/D conversion output (digital number, DN) as,
DN = Va * (1024/5) = 204.08 * Va   (Vref = 5 V, ADC resolution is 10-bit)
or, Va = 0.0049 * DN
But Va = Vout * R2/(R1+R2), Vout is the actual output from LM350.
=> Va = 0.2418*Vout
=> Vout = 4.136 * Va = 4.136 * 0.0049 * DN
=> Vout = 0.0203 * DN
This is the conversion equation for calculating the LM350 output voltage from the 10-bit A/D conversion result (DN) for channel AN0.
Similarly, for current measurement, the output of Op-amp (V0) is related to the AN4 channel A/D output as,
V0 = 0.0049 * DN (just as above)
But V0 is related to the load current (IL) through Rs as,
V0 = 10.23 * IL * Rs = 10.23 * 0.286 * IL = 2.926 * IL = 0.0049 * DN
=> IL = 0.001675 * DN (gives current from A/D conversion output)
As mentioned earlier, the output voltage is actually less than the calculated voltage (Vout) under load condition. This is because of the voltage drop across the shunt resistor Rs = 0.286 Ω due to current IL. The adjusted output voltage should be, therefore,
Vout = 0.0203 * DN – 0.286 x IL
Operation of Frequency Counter
The Timer0 module (no prescaler) is used as an external pulse counter whereas Timer1 module is used to generate a precise 100 ms duration as counting interval. This means that the resolution of frequency measurement is 10 Hz. This resolution is valid for frequencies up to 99990 Hz. Beyond this, the Timer0 module uses the prescaler (1:64) and the new resolution becomes 640 Hz or 0.64 KHz. As PIC16F689 is using 20 MHz clock, wit h 1:64 prescaler value, it can count frequencies over 50 MHz. The operation of frequency counter is like this.
  • Initialize Timer1 registers with appropriate values for creating 100 ms delay.
  • Enable Timer0 as counter with prescaler 1:64.
  • Count the pulses for 100 ms.
  • Frequency = 10 x No. of Pulses
  • If frequency < 99990, change prescaler to 1:1, re-calculate frequency, and display it (in Hz). Otherwise, display the frequency in KHz.
Software
I used MikroC compiler to develop the firmware. The compiler has built-in library routines for A/D conversion, LCD display, and Timer operation. This makes the firmware development easier and quicker. Both the source code and HEX files can be downloaded from the link provided below. Configuration bits for PIC16F689 can be set using the project edit window in MikroC editor (shown below).

Project Edit window in MikroC
Testing
The finished project is tested for voltage, current, and frequency measurement. The displayed voltage is cross-checked with an external voltmeter, and the readings are found consistent. A 56Ω resistor is connected as load to measure current. The output voltage is set to 5.2 V, and the displayed current is 90 mA. The ideal value of current should be 5.2/56 = 92.8 mA. This gives an error of about 3% in the measurement of current but the 56 Ω resistor itself has tolerance of 5%. The testing frequency counter is done by applying the 20 MHz microcontroller clock derived from OSC2/CLKOUT pin (3). The displayed value is 20.00128 MHz which is really close.

Testing with 20 MHz clock frequency from PIC16F689 circuit

Testing the voltage reading with an external voltmeter under no-load condition

Voltage and current under load condition (load is a 56 Ohm resistor with 5% tolerance).
Microcontrollers usually don’t have specific ports for measuring currents, but they do have ADC channels through which you can measure analog voltages of a certain range. This means a dc current can be indirectly measured by a microcontroller’s ADC channel by first converting the current into voltage. The simplest way of doing this is to place a resistance in series with the current path and measure the voltage drop across it. But hold on, if you place an additional resistance in the circuit, it will affect the original current. Therefore, we need to use a very small value resistance so that it’s effect in the circuit current won’t be significant.
Resistors with values less than 1 Ω are available in electronics stores. Depending upon the amount of current in the circuit, you need to choose proper power rating for the resistor. Suppose, if you pick 0.47 Ω, and the maximum current in the circuit is about 2 A, then the resistor should have the capacity of dissipating 4 x 0.47 ≈ 2 Watts of heat.
You can also make a small value resistance by yourself. Yes, by simply winding a copper wire into coil. I have made one from a 5 ft long solid copper wire (22 AWG) with plastic insulation on outer side, as shown below.

Current sensing resistance
Now lets measure its resistance. The resistance can be measured directly with a digital multimeter. My digital meter shows its value equal to 0.3 Ω. This measurement may have higher uncertainty as it is very small and most multimeter does not show values beyond 1 decimal digit. The resistance can also be measured using Ohm’s law. Connect a 47 Ω resistor in series with the coil resistance (Rs) and supply a 5V power as shown below. Next, measure the voltage across Rs and current through it separately using the multimeter. In my case, I found the measured voltage and current values to be 24.1 mV and 84.3 mA, respectively. This gives the resistance of the coil is about 0.286 Ω.

Now, suppose that the range of current to be measured using this coil resistance is from 0-2 A. Then the voltage drop across the coil resistance will be somewhere from 0 – 0.57 V. Because of its low dynamic range, this voltage signal may not be accurately measured with a microcontroller’s ADC module. So this requires some sort of voltage scaling. One way to achieve that is by using an operational amplifier circuit as shown below.

Opamp as a voltage scaler
In the circuit, Rs is the low value current sensing resistor (our coil resistor) which is connected in series with the load resistor. Our objective is to derive the load current (I). The low voltage drop across Rs is amplified by the non-inverting amplifier. The gain of the amplifier is set by Rf and Ri resistors. For Rf = 10 K, and Ri = 1.3 K, the gain of the amplifier would be about 8.7. This is enough to linearly scale Vs (0-0.57 V) to Vo (0- ≈5 V). Now you have 0-5 V voltage signal that corresponds to 0-2 A current through Rs. This voltage signal is now more appropriate for ADC conversion with Vref = 5 V.
Vo = 8.7 x I x Rs = 2.49I (Rs = 0.286 Ω)
=> I = Vo/2.49.
For 10-bit ADC with Vref = 5 V, resolution = 5/1024 = 0.0049 V. For input signal Vo, the ADC O/P will be Vo x 0.0049. Thus,
I = ADC O/P x 0.0049/2.49 = 0.00197 x ADC O/P
The current resolution would be therefore 0.00197 A (≈ 2 mA).

Bagi para hobby di dunia elektronik pasti memerlukan tegangan yang cukup bervariasi dalam setiap percobaannya. Untuk itu maka akan lebih baik jika kita mepunyai sebuah power supply yang sanggup bekerja pada tegangan dan arus yang bervariasi. Rangkaian sederhana dan komponennyapun tidaklah sulit di dapatkan disekitar anda. Berikut adalah gambar rangkaiannya:

Komponen:

P1            500R   Linear Potentiometer
P2 10K Log. Potentiometer

R1,R2 2K2 1/2W Resistors
R3 330R 1/4W Resistor
R4 150R 1/4W Resistor
R5 1R 5W Resistor

C1 3300µF 35V Electrolytic Capacitor (see Notes)
C2 1µF 63V Polyester Capacitor

D1,D2 1N5402 200V 3A Diodes
D3 5mm. Red LED

Q1 BC182 50V 100mA NPN Transistor
Q2 BD139 80V 1.5A NPN Transistor
Q3 BC212 50V 100mA PNP Transistor
Q4 2N3055 60V 15A NPN Transistor

T1 220V Primary, 36V Center-tapped Secondary
50VA Mains transformer (see Notes)

-----------------------------------------------

Tegangan maksimum 24 V dan arus maksimum 2 A
Introduction
This project will describe how to make a simple digital voltmeter (DVM) using a PIC16F688 microcontroller. The range of this DVM is 0-20V, but you can easily increase or decrease the range of input voltage as your requirements after you understand the voltage scaling method described in this project. The PIC micro reads the input voltage through one of the 8 analog channels and convert it to a 10-bit digital number using the internal ADC. Doing some math with ADC conversion (you will see later), this number can be converted to the actual measured voltage. The voltage is displayed in an HD44780-based character LCD.
Circuit Diagram and Description
You cannot feed a 20V signal directly to a PIC microcontroller’s input channel. It is too higher than its operating voltage, and the microcontroller could be damaged. So, first we need a voltage scaler that will scale down the input voltage to the safe operating voltage range of PIC16F688. It can be achieved by a simple resistor divider network shown below.

Using two resistors, R1 and R2, the input voltage ranging from 0-20V can be down converted to 0-5V. For the chosen values of R1 and R2, you can see that the output (Va) from the resistor divider network is 1/4th of the input voltage. If the input voltage goes beyond 20V, Va will exceed 5V, and this could be harmful for the PIC microcontroller. If you connect a 5.1V Zener diode across the R1 resistor, the output voltage Va will never exceed 5.1V. This will protect the microcontroller from any possible damage due to high voltage input. The voltage Va will go to AN2 (pin 11) channel of the PIC16F688 microcontroller. The rest of the circuit is shown below.
The LCD display is connected in 4-bit mode. If you have just 14 pins in your LCD module, then you may not have a back-light facility and you can ignore the pins 15 and 16. The contrast adjustment is done through a 5K potentiometer connected between +5V and Gnd. An in-circuit serial programming (ICSP) header is provided so that you can easily upgrade the firmware inside the PIC microcontroller in future if you make any changes. An external reset is helpful to bring the entire system to a known initial condition, when the microcontroller stops executing the program for some reason.
The complete circuit built on a breadboard is shown here. You need a regulated +5V power supply for this project (Why regulated? You will find the answer in the Software section below). You can use a LM7805 linear regulator IC for this purpose (read my article Regulated Power Supply for your Breadboard).
Software
Before writing the code for this project, you need to do some math related to AD conversion. You know that any application that uses analog-to-digital converters (ADCs), requires a fixed reference voltage to provide accurate digital count for input analog signal. If the reference voltage is not stable, the ADC output is meaningless. In this project, the reference voltage for ADC operation is selected to be Vdd (= +5 V). This is done by clearing the VCFG bit in ADCON0 register. Therefore, the ADC will convert any input voltage between 0-5 V in to a digital count between 0-1023. A major source of error in this project is the accuracy of R1 and R2 resistors. You are recommended not to use the rated values of the resistors. Rather measure their values with a good quality digital multimeter, and use those values for your calculation. What I found is R1 = 1267 Ω and R2 = 3890 Ω. Now,
0 – 5 V Analog I/P is mapped to one of the 1024 levels (0-1023 Digital Count)
=> Resolution = 5/1024 = 0.0049 V/Count
Also, Va = 1267*Vin/(1267+3890) = 0.2457*Vin
=> I/P voltage = 4.07*Va = 4.07* Digital Count * 0.0049
= 0.01994 * Digital Count
= 0.02*Digital Count (Approx.)
To avoid floating point, use I/P voltage = 2*Digital Count. Here’s how it works. Suppose, Vin = 4.6V. Then,
Va = 0.2457*Vin = 1.13V
=> Digital Count = 1.13/0.0049 = 231
=> Calculated I/P Voltage = 2*231 = 0462
In the 4-digit product (0462), the first two digits are the tens and units digits of measured voltage. and the last two are the decimal digits. So, the measured voltage will be 04.62 V. Only the first three digits will be displayed (04.6 V).
The firmware is developed in C and compiled with mikroC Pro for PIC compiler from Mikroelektronika. The PIC16F688 microcontroller uses internal clock oscillator at 4.0 MHz. MCLR is enabled and Power Up Timer is turned ON. You need to define RA2/AN2 input as analog by setting the corresponding bit in ANSEL register. VCFG bit of ADCON1 register is cleared to use Vdd = +5V as reference voltage for AD conversion. ADCON0 = 8 connects the AN2 input channel to the internal Sample and Hold circuit. Comparators on ports A and C pins must be disabled too (assign CMCON0 = 7). The configuration bits for the fuses are given below. You can set these in MikroC through Project->Edit Project.
Oscillator -> Internal RC No Clock
Watchdog Timer -> Off
Power Up Timer -> On
Master Clear Enable -> Enabled
Code Protect -> Off
Data EE Read Protect -> Off
Brown Out Detect -> BOD Enabled, SBOREN Disabled
Internal External Switch Over Mode -> Enabled
Monitor Clock Fail-Safe -> Enabled

The complete program written in mikroC is given here.
/* Project: Digital Voltmeter based on PIC16F688
Internal Oscillator @ 4MHz, MCLR Enabled, PWRT Enabled, WDT OFF
Copyright @ Rajendra Bhatt
Oct 10, 2010

*/
// LCD module connections

 sbit LCD_RS at RC4_bit;

 sbit LCD_EN at RC5_bit;

 sbit LCD_D4 at RC0_bit;

 sbit LCD_D5 at RC1_bit;

 sbit LCD_D6 at RC2_bit;

 sbit LCD_D7 at RC3_bit;

 sbit LCD_RS_Direction at TRISC4_bit;

 sbit LCD_EN_Direction at TRISC5_bit;

 sbit LCD_D4_Direction at TRISC0_bit;

 sbit LCD_D5_Direction at TRISC1_bit;

 sbit LCD_D6_Direction at TRISC2_bit;

 sbit LCD_D7_Direction at TRISC3_bit;

// End LCD module connections
char Message1[] = “DVM Project”;

unsigned int ADC_Value, DisplayVolt;

char *volt = "00.0";
void main() {

 ANSEL = 0b00000100; // RA2/AN2 is analog input

 ADCON0 = 0b00001000; // Analog channel select @ AN2

 ADCON1 = 0x00;   // Reference voltage is Vdd

 CMCON0 = 0x07 ; // Disable comparators

 TRISC = 0b00000000; // PORTC All Outputs

 TRISA = 0b00001100; // PORTA All Outputs, Except RA3 and RA2

 Lcd_Init();        // Initialize LCD

 Lcd_Cmd(_LCD_CLEAR);      // CLEAR display

 Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off

 Lcd_Out(1,1,Message1);

 Lcd_Chr(2,10,'V');
do {
  ADC_Value = ADC_Read(2);

  DisplayVolt = ADC_Value * 2;

  volt[0] = DisplayVolt/1000 + 48;

  volt[1] = (DisplayVolt/100)%10 + 48;

  volt[3] = (DisplayVolt/10)%10 + 48;

  Lcd_Out(2,5,volt);

  delay_ms(500);   // Hold for 500 ms

 } while(1);
} // End main()
Testing the DVM
Here are the DVM measurement output for various input voltages ranging from 0-20V obtained through a variable DC power source.
Variable power supply source
Questions, comments, and suggestions are welcome.
Introduction
A variable DC power supply is one of the most important tools for an electronics hobbyist. In order to carry out an experiment you need a reliable DC power source that can be varied according to the need of the experiment. Last week I felt I must have one on my workbench, and thought to make one for myself. This design is very simple but is great for powering almost all kinds electronic projects. It uses LM350 (a 3-pin IC) to generate a variable DC power supply. I would recommend to read the datasheet before doing this project.

The LM350 is an adjustable 3-terminal positive voltage regulator that is capable of supplying in excess of 3A over a 1.2V to 33V output range. They are exceptionally easy to use and require only 2 external resistors to set the output voltage.

Main Features

  • Adjustable output down to 1.2V
  • Guaranteed 3A output current
  • Guaranteed thermal regulation
  • Output is short circuit protected

Requirements
You need following things to make this variable power supplies.

  1. A 120/24V transformer
  2. A bridge rectifier IC or four general purpose diodes.
  3. Capacitors: 1000 uF, 50 V electrolyte (1), 0.1 uF ceramic (1), 1 uF, 50 V electrolyte (1)
  4. Resistors: 360 Ohm (1), 5 K potentiometer (1), 4.7K (1)
  5. A Rocker Switch for AC ON/OFF
  6. A voltmeter display (I used an analog one)
  7. An LED for power on indication. 
  8. A heat sink for LM350
  9. Wires, prototyping board, soldering iron, box, etc as per required.

Circuit Diagram

First of all you need to generate an unregulated 24V DC using the step-down transformer and the rectifier circuit. Use the 1000uF capacitor at the output to reduce the ripples. The circuit is shown below.

Fig. Bridge Rectifier Circuit using 4 Diodes

Next comes LM350 IC that takes in this unregulated 24V DC and with the use of two resistors (R1 = 360 Ohm, R2 = 5K Potentiometer) you can derive variable DC voltage. The circuit diagram along with the equation for output voltage is shown below. I took this circuit from LM350 datasheet and it shows R1 = 240 Ohm, but I am gonna use 360 Ohm as I am generating 18V DC at maximum.


The value of IAdj is about 100uA, so the error term is almost negligible.
Other things that are not included in the circuits above are a power on LED and the analog voltmeter display. I connected the LED to the output unregulated 24V DC through 4.7K resistor. This indicates the power switch is ON. Also connect the voltmeter to final output voltage terminals to display what voltage is being generated. Remember the heat sink for LM350.
 

Here are some of the pictures that I took while making this power supply.














    Finalized product.

I hope this project will be helpful to you and you have enjoyed reading this.
Related Posts Plugin for WordPress, Blogger...

Followers