Sunday, March 29, 2015

How to Design a Transformer less Power Supply / How Do Chinese Torch Lights Work / How to Charge Ni-Cd Batteries

The below Circuit is same and Suitable for Ni-Cd Battery Chargers, China Torch Battery Chargers, and Transformer less Power Supplies.
The theory is very simple and you simply want to understand Ohms Law,.

Let’s see how we can design and tweak the Circuit as per our requirement.



Design Data required:
1. Input voltage = 230Volts
2.Output voltage = 12Volts
3. Load Current = 32mA

Formula to calculate value of Capacitor and resistor:

For optimum performance and efficiency of the circuit always select R = 100 ohms.

where, units of 
capacitor is in nano farads,
Vin and Vout in Volts,
I(load) = Load Current in Amperes,
R = resistance in ohms,
f = frequency in Hz

By appliying our input and output data in the above formula we get,

C = 477.781nf
Since 470nf is the nearby Standard Capacitor Value we use 470nf for the above circuit.

For Charging Ni-Cd Cells and small Lead Acid batteries in Chinese Torch lights we can use constant voltage charge method and this circuit can be altered to the required voltage and current by using the above formula.
This Circuit is used in Chinese Torch Lights for Charging the battery.

Ask your doubt or clarification in comments. 

Saturday, March 28, 2015

How to Calculate Base Resistance required for the Transistor / How to Drive a relay or a High Current Load using a Transistor


Driving a relay or a High Current Load using a Transistor may sometimes be confusing like, what value of resistor to use to drive the Transistor's Base.

Once I had a problem while toggling a relay using BC547. My relay contacts have got welded due to lack of Holding Current. Due to that I made 3 relays useless. So, Then I read some basics and know how to calculate the base resistance of the transistor required to Switch the load successfully.
 

So, heres how i got this to work.
1.      Determine which transistor will be suitable.
As shown in Figure Relay rated Voltage = 12Volts,
                                             Relay resistance = 200 ohms
                                             Relay's holding Current = 12v/200 ohms = 60mA
So, we can use BC547 for switching the relay which has Icmax = 100mA and Vcemax = 45V

Switch any load by driving the transistor in Saturation mode will makes sure the load gets its rated current, Holding Current in case the Load is a Relay.
2.      How to drive BC547 or any Transistor into Saturation mode:
We want to find the Base Current(Ibase) required to drive bc547 into saturation mode(Ic in this mode will be greater than relay's holding current i.e >60mA)
we cannot calculate Ibase by using beta of bc547, because beta value is varying with Ic and Vce.

So, we can see the Vce(sat) voltage on the datasheet of BC547. There we can find the Ibase(max) of BC547. see the screnshoot of datasheet below.click to see enlarged image.


From  the above fig. IC=100mA(max), therefore Ib = 5mA(max).
So BC547 can withstand upto 5mA Base Current
Set Ibase just 10 to 20% lower for safety.(80% of 5mA = 4mA, actually we are Overdriving the transistor just to put it in Saturation mode)

So  Rbase(RB) = [5V(Logic High From uC)]/4mA

Therefore Rbase(RB)            =  1.25kohms ~= 1.2kohms

That’s all ..we are ready to drive a relay. Similarly we can find RB required for any Transistor.







                                             

Sunday, January 12, 2014

Interfacing a 2x16 Alpha Numeric LCD Using PIC Microcontroller to Display ADC Value.

circuit diagram for interfacing LCD with PIC 16F870 Microcontroller.



Interfacing LCD with a micro controller is often necessary when you are doing a project or some expriement. So lets see how to do this in this tutorial.

The micro controller we are going to use for this purpose is PIC 16F870 manufactured by Microchip Inc.
It is a 28 Pin IC available in DIP package also.

The compiler used is PIC CCS C and here is the source code below:

#include <16f870.h>
#use delay(clock=4000000)
int a,b,c,value;

void lcd_cmd()                       ////////function to execute command to LCD
{
      output_low(pin_b1);
      output_high(pin_b0);
      delay_us(50);
      output_low(pin_b0);
}
void lcd_data()                         ///////function to display data
{
      output_high(pin_b1);
      output_high(pin_b0);
      delay_us(50);
      output_low(pin_b0);
}
void lcd_init()                          ///////function to initialize LCD
{
      output_c(0x38);
      lcd_cmd();
      output_c(0x0c);
      lcd_cmd();
      output_c(0x80);
      lcd_cmd();
      output_c(0x06);
      lcd_cmd();
      output_c(0x01);
      lcd_cmd();
      delay_ms(50);
}
void lcd_clr()                                   //////////clear LCD
{
      output_c(0x01);
      lcd_cmd();
}
void split_disp()                             /////// split and display in LCD
{
   a=(value/100) | 0x30;
   output_c(0xc0);
   lcd_cmd();
   output_c(a);
   lcd_data();

   b=((value%100)/10) | 0x30;
   output_c(b);
   lcd_data();

   c=((value%100)%10) | 0x30;
   output_c(c);
   lcd_data();
}
void main()
{
   setup_adc_ports(RA0_ANALOG);                   ///all analog pins
   setup_adc(ADC_CLOCK_INTERNAL);         ///adc clock internal
   set_adc_channel(0);                                           ////select adc channel
   lcd_init();                                                           ////initialize LCD
   delay_ms(100);
   while(true)
   {
      delay_ms(200);                                              ///////delay for adc conversion
      value=read_adc();                                          //////read adc value
      split_disp();                                                    ///////call to display
   }
}

Just assemble the above circuit and compile the program to use. I had checked the program and its working.