Tutorial Microcontroller MCS-51 ATMEL ISP

Microcontroller Kits
Programmer and Target 89s51

Simple Mikrokontroller 89s51 Trainer


Standart
Mikrokontroller 89s51 Trainer


Super Mikrokontroller Trainer 89s51

+

All Item Include

Programmer
Via USB

 

 

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

}

Comments, questions and discussion about this topic