Thursday, April 29, 2010

--> Digital power supply using AT89C2051 microcontroller

Here’s the project which gives out various output voltages and this voltage can be easily controlled by two switches. The switches are connected to P3.0 and P3.1.
The variable voltages are obtained with help of the LM317. This IC is an variable voltage regulator IC which can give regulated output from 1.2v to 37v. This voltage regulator can withstand upto 1.5A of current. Since LM317 is protected against short-circuit, no fuse is necessary. Thanks to automatic thermal shutdown, it will turn off if heating excessively.
Although this ic is capable of delivering upto 37v, this circuit is designed to give upto 18v.
 
This is the basic circuit with an LM317. The output voltage is selected using two resistors. Normally R1 is chosen to be around 220R or 240R and i am using 240ohms. The formula for calculating the value of R2 is V = 1.25(1+(R2/R1)) or to put it another way R2 = R1((V/1.25)-1).
For example to get an output voltage of 8.5v.   R2 = 220((8.5/1.25)-1) = 1276 ohms. The nearest preferred value to this would be 1K3.
Setting R2 to zero, ie. grounding the Adjust pin, will cause the output voltage to drop to 1.25v.
By adjusting the value of this R2 resistor we can obtain a variable voltage at the output. This is done by the microcontroller with help of the relays.

If the R1 is switched on then the resistor R8 comes into action, like this we can obtain the variable voltage at the output. When the LM317 input is 18V the resistance values are 2K, 1.4K, 865Ω, 704Ω, and 327Ω, for output voltages 12V, 9V, 6V, 5V and the 3V  with the above circuit.
The next circuit shows with 13relays, so we can get the output voltage in 13steps.
 
Assembly Code:
[code:asm]ORG 0000H
MOV P1, #0FFH
MOV P3, #0FFH
L0: JB P3.0, L0    ; Pressed key 1 if pressed down, transfers L0 
L1: JNB P3.0, L1   ; Pressed key 1 if lifted, transfers L1 
CLR P1.7       ; Operates the 1st port
Q0: JB P3.1, L2     ; Pressed key 2 if pressed down, transfers Q0
Q1: JNB P3.1, Q1   ; Pressed key 2 if lifted, transfers Q1
SETB P1.7      ; Turns off the 1st port
LJMP L0       ; Transfers L0 
L2: JB P3.0, Q0     ; Pressed key 1 if pressed down, transfers Q0
L3: JNB P3.0, L3    ; Pressed key 1 if lifted, transfers L3
SETB P1.7      ; Turns off the 1st relay
CLR P1.6       ; Operates the 2nd relay
Q2: JB P3.1, L4
Q3: JNB P3.1, Q3 
SETB P1.6 
CLR P1.7 
LJMP L2 
L4: JB P3.0, Q2    ;
L5: JNB P3.0, L5 
SETB P1.6     ; Turns off the 2nd relay
CLR P1.5      ; Operates the 3rd relay
Q4: JB P3.1, L6
Q5: JNB P3.1, Q5 
SETB P1.5 
CLR P1.6 
LJMP L4 
L6: JB P3.0, Q4 
L7: JNB P3.0, L7 
SETB P1.5      ; Turns off the 3rd relay
CLR P1.4       ; Operates the 4th relay
Q6: JB P3.1, L8
Q7: JNB P3.1, Q7 
SETB P1.4 
CLR P1.5 
LJMP L6 
L8: JB P3.0, Q6 
L9: JNB P3.0, L9 
SETB P1.4      ; Turns off the 4th relay
CLR P1.3       ; Operates the 5th relay
Q8: JB P3.1, L10
Q9: JNB P3.1, Q9 
SETB P1.3 
CLR P1.4 
LJMP L8 
L10: JB P3.0, Q8 
L11: JNB P3.0, L11 
SETB P1.3           ; Turns off the 5th relay
CLR P1.2            ; Operates the 6th relay
Q10: JB P3.1, L12
Q11: JNB P3.1, Q11 
SETB P1.2 
CLR P1.3 
LJMP L10 
L12: JB P3.0, Q10 
L13: JNB P3.0, L13 
SETB P1.2           ; Turns off the 6th relay
CLR P1.1            ; Operates the 7th relay
Q12: JB P3.1, L14
Q13: JNB P3.1, Q13 
SETB P1.1 
CLR P1.2 
LJMP L12 
L14: JB P3.0, Q12 
L15: JNB P3.0, L15 
SETB P1.1           ; Turns off the 7th relay
CLR P1.0            ; Operates the 8th relay
Q14: JB P3.1, L16
Q15: JNB P3.1, Q15 
SETB P1.0 
CLR P1.1 
LJMP L14 
L16: JB P3.0, Q14 
L17: JNB P3.0, L17 
SETB P1.0           ; Turns off the 8th relay
CLR P3.2            ; Operates the 9th relay
Q16: JB P3.1, L18
Q17: JNB P3.1, Q17 
SETB P3.2 
CLR P1.0 
LJMP L16 
L18: JB P3.0, Q16 
L19: JNB P3.0, L19 
SETB P3.2            ; Turns off the 9th relay
CLR P3.3             ; Operates the 10th relay
Q18: JB P3.1, L20
Q19: JNB P3.1, Q19 
SETB P3.3 
CLR P3.2 
LJMP L18 
L20: JB P3.0, Q18 
L21: JNB P3.0, L21 
SETB P3.3           ; Turns off the 10th relay
CLR P3.4            ; Operates the 11th relay
Q20: JB P3.1, L22 
Q21: JNB P3.1, Q21 
SETB P3.4 
CLR P3.3 
LJMP L20 
L22: JB P3.0, Q20 
L23: JNB P3.0, L23 
SETB P3.4           ; Turns off the 11th relay
CLR P3.5            ; Operates the 12th relay
Q22: JB P3.1, L24 
Q23: JNB P3.1, Q23 
SETB P3.5 
CLR P3.4 
LJMP L22 
L24: JB P3.0, Q22 
L25: JNB P3.0, L25 
SETB P3.5            ; Turns off the 12th relay
CLR P3.7             ; Operates the 13th relay
Q24: JB P3.1, L26 
Q25: JNB P3.1, Q25 
SETB P3.7 
CLR P3.5 
LJMP L24 
L26: JB P3.0, Q24 
L27: JNB P3.0, L27 
SETB P3.7             ; Turns off the 13th relay
LJMP L0              ; Transfers L0   
END[/code]
Download the ASM code from here: at89c2051-LM317T-voltage-regulator.zip (4.13 kb)  

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

No comments:

Post a Comment