Tutorial Microcontroller 8051
 
 
 
 
 
   

BACK

 

Simple Power Supply and Charger Circuits

Figure 4 shows a simple power supply circuit. I have tested with KABO, it works fine. For those who have a big capacity rechargeable battery, the resistance value of R can be selected for approx. 10% output charging current. DC in can be higher if your battery voltage higher than 8.4V, say. To ensure the output current is within the value calculated by R, measure DC current before. The maximum supply for LM317 is ~35V.

 

/* C52ADC.C
   4-channel 8-bit resolution ADC and 6-bit input port for C52-EVB
   Copyright 2000 Wichit Sirichote
   start conversion by high to low signal at RB0,
   40-bit data is then shifted out through PA4 with low-to-high trnasition 
   at RB0 The format is started from ADC0,ADC1,ADC2,ADC3,port_B
   ~60uS LSB
   after high-to-low starting 711 chip to read analog input and port B, 
   at least 60 microseconds
   required before low-to-high data shifted out to begin.
*/
#include <C52ADC.H>
           #fuses RC,NOPROTECT,NOWDT,PUT,BROWNOUT
byte buffer[5];
read_analog()
           {
           byte i;
           for(i = 0; i < 4; i++)
           {
           set_adc_channel(i);
           delay_us(5);
           buffer[i] = read_adc();
           }
}
read_portB()
           {
           buffer[4] = port_B;
           }
send_data_out()
  {
   byte i;
   for(i=0;i<40;++i){ // 5 bytes
   while (!input(PIN_B0));
   output_bit(PIN_A4,shift_right(buffer,5,0));
   while (input(PIN_B0));} // shifted out when RB0 change from LOW to HIGH
   }
/*This shifts 40 bits out Pin_A4, LSB first.*//*This shifts 40 bits
out Pin_A4, LSB first.*/
// ___---___---___---___---____
           // LSB ......................... MSB

           main() {
           port_b_pullups(TRUE);
           setup_counters(RTCC_INTERNAL,RTCC_DIV_2);
           setup_port_a(ALL_ANALOG);
           setup_adc(ADC_CLOCK_INTERNAL);
while(1){
  while(input(PIN_B0));//wait High to Low trigger read signal from C-52EVB
  read_analog();
  read_portB();
  send_data_out(); // send 40 bits in buffer array to PIN_A4

}

Best Link

 

 

Lesson 1:
T o o l
1.1. Programmer
1.2.
Edsim 51
1.3. MIDE-51
1.4. ATMEL ISP

Lesson 2:
Input Output
2.1.LED
2.2.Swicht
2.3.7 Segmen
2.4.LCD Character
2.5.ADC
2.6.DAC
2.7.Motor Stepper
2.8.Keypad

Lesson 3:

Timer Counter

3.1.Basic
3.2.Mode 0
3.3.Mode 1
3.4.Mode 2
3.5.Mode 3

Lesson 4:

Serial Comm.

4.1.Basic
4.2.LED
4.3.Rotate LED
4.2 ADC
4.3.LCD

Lesson 5:
Interuption

5.1.Basic
5.2.Timer
5.2.External