-->
Showing posts with label PIC. Show all posts
Showing posts with label PIC. Show all posts

PIC microcontroller tutorial

By
PIC Microcontroller Tutorial

Every Microcontroller (also MCU) consists of several major units:
  • Input / Output Ports
  • Control Pins: reset, power, clock
  • Processor (CPU)
  • Memory (RAM, ROM, EEPROM)
  • Serial and parallel ports
  • Timers
  • Analog-to-digital (A/D) and digital-to-analog (D/A) converters
Microcontrollers PICmicro MCU from Microchip Company divided into 4 large families. Each family has a variety of components that provide built-in special features:
1. The first family, PIC10 (10FXXX) - is called Low End.
The PIC10FXXX devices from Microchip Technology are low-cost, high-performance, 8-bit, fully static, Flash-based CMOS microcontrollers. They employ a RISC architecture with only 33 single-word/ single-cycle instructions. The 12-bit wide instructions are highly symmetrical. The easy-to-use and easy to remember instruction set reduces development time significantly. The PIC10FXXX devices contain an 8-bit ALU and working register.

2. The second family, PIC12 (PIC12FXXX)– is called Mid-Range.
The PIC12FXXX most popular among these starter their way in this field. Mid-Range devices feature 14-bit program word architecture and are available in 8 to 64-pin packages that offer an operating voltage range of 1.8-5.5V, small package footprints, interrupt handling, an 8-level hardware stack, multiple A/D channels and EEPROM data memory. Mid-range devices offer a wide range of package options and a wide range of peripheral integration. These devices feature various serial analog and digital peripherals, such as: SPI, I2C™, USART, LCD and A/D converters.
3. The third family is PIC16(16FXXX).
With six variants ranging from 3.5K-14 Kbytes of Flash memory, up to 256 bytes of RAM and a mix of peripherals including EUSART, CCP and onboard analog comparators. These devices are well suited for designers with applications that need more code space or I/O than 14-pin variants supply, and are looking to increase system performance and code efficiency by employing hardware motor control and communications capability.
4. The fourth family is PIC 17/18(18FXXX).
The PIC18 family utilizes a 16-bit program word architecture and incorporates an advanced RISC architecture with 32 level-deep stack, 8x8 hardware multiplier, and multiple internal and external interrupts. With the highest performance in Microchip’s 8-bit portfolio, the PIC18 family provides up to 16 MIPS and linear memory. PIC18 is the most popular architecture for new 8-bit designs where customers want to program in C language

Here we are trying t the thord family exceptionally PIC16F877a

The PIC microcontroller PIC16f877a is one of the most renowned microcontrollers in the industry. This controller is very convenient to use, the coding or programming of this controller is also easier. One of the main advantages is that it can be write-erase as many times as possible because it use FLASH memory technology. It has a total number of 40 pins and there are 33 pins for input and output.

An EEPROM is also featured in it which makes it possible to store some of the information permanently like transmitter codes and receiver frequencies and some other related data. The cost of this controller is low and its handling is also easy. Its flexible and can be used in areas where microcontrollers have never been used before as in coprocessor applications and timer functions etc.


PIN CONFIGURATION AND DESCRIPTION OF PIC16F877A

As it has been mentioned before, there are 40 pins of this microcontroller IC. It consists of two 8 bit and one 16 bit timer. Capture and compare modules, serial ports, parallel ports and five input/output ports are also present in it.


PIN 1: MCLR
The first pin is the master clear pin of this IC. It resets the microcontroller and is active low, meaning that it should constantly be given a voltage of 5V and if 0 V are given then the controller is reset. Resetting the controller will bring it back to the first line of the program that has been burned into the IC.
A push button and a resistor is connected to the pin. The pin is already being supplied by constant 5V. When we want to reset the IC we just have to push the button which will bring the MCLR pin to 0 potential thereby resetting the controller.
PIN 2: RA0/AN0
PORTA consists of 6 pins, from pin 2 to pin 7, all of these are bidirectional input/output pins. Pin 2 is the first pin of this port. This pin can also be used as an analog pin AN0. It is built in analog to digital converter.
PIN 3: RA1/AN1
This can be the analog input 1.
PIN 4: RA2/AN2/Vref-
It can also act as the analog input2. Or negative analog reference voltage can be given to it.
PIN 5: RA3/AN3/Vref+
It can act as the analog input 3. Or can act as the analog positive reference voltage.
PIN 6: RA0/T0CKI
To timer0 this pin can act as the clock input pin, the type of output is open drain.
PIN 7: RA5/SS/AN4
This can be the analog input 4. There is synchronous serial port in the controller also and this pin can be used as the slave select for that port.
PIN 8: RE0/RD/AN5
PORTE starts from pin 8 to pin 10 and this is also a bidirectional input output port. It can be the analog input 5 or for parallel slave port it can act as a ‘read control’ pin which will be active low.
PIN 9: RE1/WR/AN6
It can be the analog input 6. And for the parallel slave port it can act as the ‘write control’ which will be active low.
PIN 10: RE2/CS/A7
It can be the analog input 7, or for the parallel slave port it can act as the ‘control select’ which will also be active low just like read and write control pins.
PIN 11 and 32: VDD
These two pins are the positive supply for the input/output and logic pins. Both of them should be connected to 5V.
PIN 12 and 31: VSS
These pins are the ground reference for input/output and logic pins. They should be connected to 0 potential.
PIN 13: OSC1/CLKIN
This is the oscillator input or the external clock input pin.
PIN 14: OSC2/CLKOUT
This is the oscillator output pin. A crystal resonator is connected between pin 13 and 14 to provide external clock to the microcontroller. ¼ of the frequency of OSC1 is outputted by OSC2 in case of RC mode. This indicates the instruction cycle rate.
PIN 15: RC0/T1OCO/T1CKI
PORTC consists of 8 pins. It is also a bidirectional input output port. Of them, pin 15 is the first. It can be the clock input of timer 1 or the oscillator output of timer 2.
PIN 16: RC1/T1OSI/CCP2
It can be the oscillator input of timer 1 or the capture 2 input/compare 2 output/ PWM 2 output.
PIN 17: RC2/CCP1
It can be the capture 1 input/ compare 1 output/ PWM 1 output.
PIN 18: RC3/SCK/SCL
It can be the output for SPI or I2C modes and can be the input/output for synchronous serial clock.
PIN 23: RC4/SDI/SDA
It can be the SPI data in pin. Or in I2C mode it can be data input/output pin.
PIN 24: RC5/SDO
It can be the data out of SPI in the SPI mode.
PIN 25: RC6/TX/CK
It can be the synchronous clock or USART Asynchronous transmit pin.
PIN 26: RC7/RX/DT
It can be the synchronous data pin or the USART receive pin.
PIN 19,20,21,22,27,28,29,30:
All of these pins belong to PORTD which is again a bidirectional input and output port. When the microprocessor bus is to be interfaced, it can act as the parallel slave port.
PIN 33-40: PORT B
All these pins belong to PORTB. Out of which RB0 can be used as the external interrupt pin and RB6 and RB7 can be used as in-circuit debugger pins.

HOW TO PROGRAM THE INPUT AND OUTPUT PORTS OF PIC16F877A


As we have studied 5 input and output ports namely PORTA, PORTB, PORTC, PORTD and PORTE which can be digital as well as analog. We will configure them according to our requirements. But in case of analog mode, the pins or the ports can only act as inputs. There is a built in A to D converter which is used in such cases. Multiplexer circuits are also used.

But in digital mode, there is no restriction. We can configure the ports as output or as input. This is done through programming. For PIC the preferable compiler is mikro C pro which can be downloaded from their website.

There is a register named as ‘TRIS’ which controls the direction of ports. For different ports there are different registers such as TRISA, TRISB etc.

  • If we set a bit of the TRIS register to 0, the corresponding port bit will act as the digital output.
  • If we set a bit of the TRIS register to 1, the corresponding port bit will act as the digital input.

For example to set the whole portb to output we can write the program statement as:

TRISB=0;

Now the port will act as the output port and we can send any value on the output such as

PORTB=0XFF;

FF represents all 1’s in binary i.e. FF=11111111, now all the pins of port b are high. If we connect LEDs at all the pins then they will all start glowing in this condition.

If we want to negate the values of the port b we can use the statement:

PORTB=~PORTB;

Now all the pins of the port b will be low.

CODE TO LIGHT UP A SINGLE LED/ FLASHING LED

void main()
{
TRISB.F0 = 0 // the direction of RB0 is set as output
//or TRISB = 0xFE (0xFE = 11111110)
do // setting the infinite loop
{
PORTB.F0 = 1; // setting the RB0 pin to high
Delay_ms(500); // delay of 500 milli seconds
PORTB.F0 = 0; // setting the RB0 pin to low
Delay_ms(500); // again a delay of 500 milli seconds
}while(1);
}

PIC microcontroller tutorial

By
PIC Microcontroller Tutorial

Every Microcontroller (also MCU) consists of several major units:
  • Input / Output Ports
  • Control Pins: reset, power, clock
  • Processor (CPU)
  • Memory (RAM, ROM, EEPROM)
  • Serial and parallel ports
  • Timers
  • Analog-to-digital (A/D) and digital-to-analog (D/A) converters
Microcontrollers PICmicro MCU from Microchip Company divided into 4 large families. Each family has a variety of components that provide built-in special features:
1. The first family, PIC10 (10FXXX) - is called Low End.
The PIC10FXXX devices from Microchip Technology are low-cost, high-performance, 8-bit, fully static, Flash-based CMOS microcontrollers. They employ a RISC architecture with only 33 single-word/ single-cycle instructions. The 12-bit wide instructions are highly symmetrical. The easy-to-use and easy to remember instruction set reduces development time significantly. The PIC10FXXX devices contain an 8-bit ALU and working register.

2. The second family, PIC12 (PIC12FXXX)– is called Mid-Range.
The PIC12FXXX most popular among these starter their way in this field. Mid-Range devices feature 14-bit program word architecture and are available in 8 to 64-pin packages that offer an operating voltage range of 1.8-5.5V, small package footprints, interrupt handling, an 8-level hardware stack, multiple A/D channels and EEPROM data memory. Mid-range devices offer a wide range of package options and a wide range of peripheral integration. These devices feature various serial analog and digital peripherals, such as: SPI, I2C™, USART, LCD and A/D converters.
3. The third family is PIC16(16FXXX).
With six variants ranging from 3.5K-14 Kbytes of Flash memory, up to 256 bytes of RAM and a mix of peripherals including EUSART, CCP and onboard analog comparators. These devices are well suited for designers with applications that need more code space or I/O than 14-pin variants supply, and are looking to increase system performance and code efficiency by employing hardware motor control and communications capability.
4. The fourth family is PIC 17/18(18FXXX).
The PIC18 family utilizes a 16-bit program word architecture and incorporates an advanced RISC architecture with 32 level-deep stack, 8x8 hardware multiplier, and multiple internal and external interrupts. With the highest performance in Microchip’s 8-bit portfolio, the PIC18 family provides up to 16 MIPS and linear memory. PIC18 is the most popular architecture for new 8-bit designs where customers want to program in C language

Here we are trying t the thord family exceptionally PIC16F877a

The PIC microcontroller PIC16f877a is one of the most renowned microcontrollers in the industry. This controller is very convenient to use, the coding or programming of this controller is also easier. One of the main advantages is that it can be write-erase as many times as possible because it use FLASH memory technology. It has a total number of 40 pins and there are 33 pins for input and output.

An EEPROM is also featured in it which makes it possible to store some of the information permanently like transmitter codes and receiver frequencies and some other related data. The cost of this controller is low and its handling is also easy. Its flexible and can be used in areas where microcontrollers have never been used before as in coprocessor applications and timer functions etc.


PIN CONFIGURATION AND DESCRIPTION OF PIC16F877A

As it has been mentioned before, there are 40 pins of this microcontroller IC. It consists of two 8 bit and one 16 bit timer. Capture and compare modules, serial ports, parallel ports and five input/output ports are also present in it.


PIN 1: MCLR
The first pin is the master clear pin of this IC. It resets the microcontroller and is active low, meaning that it should constantly be given a voltage of 5V and if 0 V are given then the controller is reset. Resetting the controller will bring it back to the first line of the program that has been burned into the IC.
A push button and a resistor is connected to the pin. The pin is already being supplied by constant 5V. When we want to reset the IC we just have to push the button which will bring the MCLR pin to 0 potential thereby resetting the controller.
PIN 2: RA0/AN0
PORTA consists of 6 pins, from pin 2 to pin 7, all of these are bidirectional input/output pins. Pin 2 is the first pin of this port. This pin can also be used as an analog pin AN0. It is built in analog to digital converter.
PIN 3: RA1/AN1
This can be the analog input 1.
PIN 4: RA2/AN2/Vref-
It can also act as the analog input2. Or negative analog reference voltage can be given to it.
PIN 5: RA3/AN3/Vref+
It can act as the analog input 3. Or can act as the analog positive reference voltage.
PIN 6: RA0/T0CKI
To timer0 this pin can act as the clock input pin, the type of output is open drain.
PIN 7: RA5/SS/AN4
This can be the analog input 4. There is synchronous serial port in the controller also and this pin can be used as the slave select for that port.
PIN 8: RE0/RD/AN5
PORTE starts from pin 8 to pin 10 and this is also a bidirectional input output port. It can be the analog input 5 or for parallel slave port it can act as a ‘read control’ pin which will be active low.
PIN 9: RE1/WR/AN6
It can be the analog input 6. And for the parallel slave port it can act as the ‘write control’ which will be active low.
PIN 10: RE2/CS/A7
It can be the analog input 7, or for the parallel slave port it can act as the ‘control select’ which will also be active low just like read and write control pins.
PIN 11 and 32: VDD
These two pins are the positive supply for the input/output and logic pins. Both of them should be connected to 5V.
PIN 12 and 31: VSS
These pins are the ground reference for input/output and logic pins. They should be connected to 0 potential.
PIN 13: OSC1/CLKIN
This is the oscillator input or the external clock input pin.
PIN 14: OSC2/CLKOUT
This is the oscillator output pin. A crystal resonator is connected between pin 13 and 14 to provide external clock to the microcontroller. ¼ of the frequency of OSC1 is outputted by OSC2 in case of RC mode. This indicates the instruction cycle rate.
PIN 15: RC0/T1OCO/T1CKI
PORTC consists of 8 pins. It is also a bidirectional input output port. Of them, pin 15 is the first. It can be the clock input of timer 1 or the oscillator output of timer 2.
PIN 16: RC1/T1OSI/CCP2
It can be the oscillator input of timer 1 or the capture 2 input/compare 2 output/ PWM 2 output.
PIN 17: RC2/CCP1
It can be the capture 1 input/ compare 1 output/ PWM 1 output.
PIN 18: RC3/SCK/SCL
It can be the output for SPI or I2C modes and can be the input/output for synchronous serial clock.
PIN 23: RC4/SDI/SDA
It can be the SPI data in pin. Or in I2C mode it can be data input/output pin.
PIN 24: RC5/SDO
It can be the data out of SPI in the SPI mode.
PIN 25: RC6/TX/CK
It can be the synchronous clock or USART Asynchronous transmit pin.
PIN 26: RC7/RX/DT
It can be the synchronous data pin or the USART receive pin.
PIN 19,20,21,22,27,28,29,30:
All of these pins belong to PORTD which is again a bidirectional input and output port. When the microprocessor bus is to be interfaced, it can act as the parallel slave port.
PIN 33-40: PORT B
All these pins belong to PORTB. Out of which RB0 can be used as the external interrupt pin and RB6 and RB7 can be used as in-circuit debugger pins.

HOW TO PROGRAM THE INPUT AND OUTPUT PORTS OF PIC16F877A


As we have studied 5 input and output ports namely PORTA, PORTB, PORTC, PORTD and PORTE which can be digital as well as analog. We will configure them according to our requirements. But in case of analog mode, the pins or the ports can only act as inputs. There is a built in A to D converter which is used in such cases. Multiplexer circuits are also used.

But in digital mode, there is no restriction. We can configure the ports as output or as input. This is done through programming. For PIC the preferable compiler is mikro C pro which can be downloaded from their website.

There is a register named as ‘TRIS’ which controls the direction of ports. For different ports there are different registers such as TRISA, TRISB etc.

  • If we set a bit of the TRIS register to 0, the corresponding port bit will act as the digital output.
  • If we set a bit of the TRIS register to 1, the corresponding port bit will act as the digital input.

For example to set the whole portb to output we can write the program statement as:

TRISB=0;

Now the port will act as the output port and we can send any value on the output such as

PORTB=0XFF;

FF represents all 1’s in binary i.e. FF=11111111, now all the pins of port b are high. If we connect LEDs at all the pins then they will all start glowing in this condition.

If we want to negate the values of the port b we can use the statement:

PORTB=~PORTB;

Now all the pins of the port b will be low.

CODE TO LIGHT UP A SINGLE LED/ FLASHING LED

void main()
 {
      TRISB.F0 = 0  // the direction of RB0 is set as output
                 //or TRISB = 0xFE (0xFE = 11111110)
      do // setting the infinite loop
      {
        PORTB.F0 = 1; // setting the RB0 pin to high
        Delay_ms(500); // delay of 500 milli seconds
        PORTB.F0 = 0; // setting the RB0 pin to low
        Delay_ms(500); // again a delay of 500 milli seconds
     }while(1);
 }

LED Blinking program by using Mikro C -

By
LED Blinking program  by using Mikro  (PIC 16F877)

void main() {
TRISB = 0; //Makes PORTB0 or RB0 Output Pin

while(1) //Infinite Loop
{
PORTB = 0x55; //LED ON
Delay_ms(1000); //1 Second Delay
PORTB = 0xAA; //LED OFF
Delay_ms(1000); //1 Second Delay
}
}

LED Blinking program by using Mikro C -

By
LED Blinking program  by using Mikro  (PIC 16F877)

void main() {
 TRISB = 0; //Makes PORTB0 or RB0 Output Pin

  while(1) //Infinite Loop
  {
    PORTB = 0x55; //LED ON
    Delay_ms(1000); //1 Second Delay
    PORTB = 0xAA; //LED OFF
    Delay_ms(1000); //1 Second Delay
  }
}

Smart Voltage Stabilizer Using PIC16F877A

By

Smart Voltage Stabilizer Using PIC16F877A

Voltage stabilizers are used for many appliances in homes, offices and industries. The mains supply suffers from large voltage drops due to losses on the distribution lines en route. A voltage stabilizer maintains the voltage to the appliance at the nominal value of around 220 volts even if the input mains fluctuates over a wide range.

Here is the circuit of an automatic voltage stabilizer that can be adapted to any power rating. Its intelligence lies in the program on PIC16F877A—a low-cost microcontroller that is readily available. The circuit, when used with any appliance, will maintain the voltage at around 220V even if the input mains voltage varies between 180V and 250V.


Here the circuit is shown for a 5A stabilizer. It acts within 100ms to produce a smoothly varying output whenever input mains voltage changes. (Servo stabilizers move a variable contact on a toroidal auto transformer to adjust the output when input goes up and down, which takes seconds.)

The PIC16F877A is an RISC (reduced instruction set computer) microcontroller with 35 instructions, and hence program development with it is rather tough. But, there are good support programs.

Circuit description:
The circuit is divided into two sections as it is easy to test them separately: voltage stabilizer controller and voltage stabilizer buck-boost. The sections can be joined easily.
Voltage stabilizer controller section:
This part of the circuit is built around the PIC microcontroller (see Fig. 1). The 5V supply for the microcontroller is derived from a small iron-core mains step-down transformer having 9-0-9V, 300mA rating, two diodes (1N4007) and a 1000μF capacitor followed by the 7805 regulator.


The ADC input channel 0 at port-A pin 2 of IC2 is used as shown in Fig. 1. Here potentiometer VR1 is connected to +5V and ground through a jumper connection. For the purpose of testing, you can vary VR1 to adjust the voltage from 0 to 5V. The reset circuitry at pin 1 (MCLR) has capacitor C1 and resistor R1. Pin 30 (port-D bit 7) gets a signal (marked as ‘D’) derived from the mains supply. Pins 17 and 16 (CCP1 and CCP2) provide the actual pulse output signal that helps in stabilizing the mains power. The signal is a set of equally spaced pulses at about 8 kHz for a 12MHz crystal.


The pulses from pins 16 and 17 are buffered using a pair of inverter gates of high current
driver IC ULN2003. Note that the gates in this chip need pull-up resistors Fig. 1: Circuit of voltage stabilizer controller section at the output pins. So at points marked ‘A’ and ‘B’ we get two pulse trains from the microcontroller. Synchronization with the mains supply is achieved by the square wave (50Hz mains derived) on port-D bit 7 (pin 30).


Transistor T3 (BC547) produces a rectangular pulse from the half-wave rectified low voltage (9V) from the transformer (9V-0-9V, 300mA). Using 50 Hz as reference for positive and negative half cycles of the mains supply, it produces the pulses at A and B points in turn. These pulses change in width and are hence called pulse width modulated. The width varies in accordance with the voltage to be produced for compensating the voltage from mains supply.


After wiring the circuit, program the chip with the given Assembly program. Insert the chip into the board and apply power supply. The chip has two PWM pins, 16 and 17. Adjust the shaft of pot-meter VR1 (10-kilo-ohm) to the bottom position for zero voltage. Also, ground pin D. The PWM pulse is now available from pin 17 of IC2, while pin 16 is low. If the shaft of the potmeter is moved to the top position when ‘D’ is connected to ground, pulses will be available from pin 16. Taking pin D to 5V reverses the above sequence. After checking this part of the circuit, the circuit shown in Fig. 2 may be tested.


In manual position of input selection switch S1 (Fig. 1), the analogue input voltage from pot-meter VR1 is used. In this position, the circuit functions as a variac that varies the output voltage from 180V to 250V as the pot-meter is varied.


In auto position of S1, the circuit acts as a stabilizer. For this, transformer rectified supply derived from the mains provides a proportional voltage to the ADC of the chip.

Point E in the voltage stabilizer controller circuit gives a voltage that varies with mains voltage. At exactly 220V mains, the 9V transformer (X1) gives a peak voltage of 9√2 =12.7V and subtracting 10V using zener diode ZD1 gives 2.7V at point E. It increases to 5V when the mains voltage rises to 259V and drops to zero when mains drops to 172V in effect, giving 0 to 5V over this range.


Using this voltage at point E, you can assess variation in the mains voltage and thereby control the PWM based sine voltage for adding (boost) or subtracting (buck) from mains. Point E is connected to the ADC input pin (point C) of the PIC in auto position (Fig. 1).


The buck-boost principle:
Voltage stabilizers buck (subtract) the mains voltage if it is higher than 220V and boost (add to) the mains voltage if it is lower than 220V. For this purpose, you need to produce a small voltage to do addition or subtraction. In Fig. 3, the mains voltage waveform is shown in the top left corner, with two voltages of smaller amplitude (about 30V) shown below it. One of these two voltages is in the same phase as the mains voltage, while the other is out of phase. By adding any of the two voltages, you can boost or buck the mains voltage.


For this purpose, ordinary voltage stabilizers generate a small voltage using a transformer with one or more taps. They connect the small voltage in series with the mains supply so as to add or subtract from it. A changeover relay is used to switch to buck/boost, while another relay selects between voltages from the two taps.


This method does not produce a smooth voltage change due to relay switching and the voltage from tap produces a fixed value (instead of a finely-variable voltage). In this project, the additional voltage of about 30V in phase or out of phase with the mains voltage is finely variable because of PWM. So it produces a smoothly varying output.

A typical PWM concept is shown in Fig. 4. The microcontroller produces pulse-widths, as required, for generating the voltage to be added or subtracted from the mains. The pulses from points A and B (refer Fig. 1) are fed to the transformer shown in Fig. 2. The secondary winding of this transformer gives the adding voltage. In this case, there is no relay switching; the buck or boost is done smoothly by changing the phase of the adding signal instantly. So it is a continuous voltage stabilizer. Depending on how much the input varies from 220V, pulse width is generated so as to adjust the output voltage by adding or subtracting from it. This is a feed-forward control.


Points marked ‘com’ common points in Figs 1 and 2 are not the ground and should not be connected to the neutral line.


Take care while checking the buck/boost circuit, as all the points are ‘hot’ and will give electric shock if touched, and also when interconnecting the voltage stabilizer control and buck-boost circuits.


Pulse-drive circuit and the transformer:
Fig. 2 shows the circuit to buck/boost the mains voltage using a buck-and-boost transformer. The iron core transformer used here is the same as used in voltage stabilizers. There is no tap on the secondary winding and the primary winding is center-tapped.


As with most transformers, the stampings used for this transformer are made of 4mm thick silicon steel. These are E-I type Stalloy/CRGO stampings. The size of the stampings depends on the rating. A toroidal winding transformer gives better performance and is smaller in size.


Here, we have used a 250V-0-250V, 500mA primary to 50V, 5A secondary transformer. The windings’ number of turns depends on the core size used.


Pulses from A and B of the voltage stabilizer controller circuit are fed to the gate pins of MOSFET power transistors (IRF840) via 10k series resistors. There are also 100-kilo-ohm grounding resistors connected to the transistors’ gates. The drains (D) are connected to the winding ends of transformer X2. The center tap of the primary winding is connected to the rectified DC supply from the mains. (This rectified voltage is not filtered; it is just unfiltered, rectified sine wave at point P.)


The power transistors (IRF840) switch the rectified sine voltage supply at the PWM frequency produced by the microcontroller. To smooth out the pulse switching, a 2.5μF, 400V AC fan capacitor is connected across the primary winding of transformer X2. The voltage induced in the secondary winding is a sine wave whose amplitude depends on the width of pulses at points A and B. The program changes the PWM width, and thus the amplitude of the sine wave, to adjust the mains voltage to 220V level.


We thus get a sine wave of the mains frequency. By serially adding the secondary voltage to the input mains voltage we get the stabilized voltage at the output of the unit.


On alternate half cycles, pulses at points A and B arrive to make either of the two transistors T1 and T2 conduct and allow the current to flow through the primary winding. A 2.5μF, 400V AC capacitor is required across the primary winding of transformer X2. Otherwise, only the pulses from A will pass through and buck and boost cannot be obtained.


In manual position of the switch, when potmeter VR1 is varied from bottom to top (0 to 5V), the voltage across the secondary decreases, crosses zero and then increases again. This means the secondary voltage varies with the potmeter position. Check the variation in secondary voltage by using a voltmeter, or a multimeter set to 50V AC range. The voltage should increase on either side of the mid-point of VR1. In auto position, combining the secondary output voltage of transformer X2 with the mains voltage gives you the stabilized output.

Testing:
  • First, test the controller circuit (Fig. 1) for pulse width modulated signals at points A and B. Check changeover from A to B by applying 0V and 5V at point D.

  • Check the circuit for a square wave of 5V amplitude at point D during positive half cycles of AC mains. This square wave is generated by the transistor fed with the unfiltered low voltage DC from transformer X1.
  • Vary the pot-meter in manual position of the switch. Using a CRO, you can see variation in the pulse-width (see Fig. 4).
  • As VR1 is adjusted beyond the mid position, pulses at points A and B toggle.
Note that the transistors are ‘hot’ and ‘live.’ Energize the voltage stabilizer controller circuit first but only in manual position of switch S1. Join points C and E and then switch on mains power for the buck and boost circuit.


Measure the AC voltage across the secondary output of transformer X2. Vary VR1 in the
controller section and check whether the voltage output at the secondary of X2 varies.
A CRO can be used to observe this secondary voltage. It should be 50Hz sine wave, but if
it has a break, it means the half cycles are not synchronized.


In Fig. 1, at point E, we have included a lag circuit comprising variable resistor VR2 (5 Kilo-ohm) and capacitor C5 (10μF). Adjust preset VR2 until the waveform is a smooth sine wave.


There may be small ripples in the first half of each cycle, but these do not matter and will
anyway be present due to PWM switching. Capacitor C7 (2.5μF) across the primary winding of transformer X2 filters them out.


The secondary voltage of transformer X2 should decrease and then increase as VR1 is raised from 0V position. Then check voltage regulation after changing over to auto position in Fig. 1. Adjust VR1 to the center position precisely. In the center position, there will be no pulse and therefore no adding voltage in the secondary winding. So the value of the zener diode used in the rectifier circuit should be changed in order to get 0V for 220V input. A variac is useful for varying the input voltage and checking the output.
  • Activate the buck-and-boost circuit by closing stabilizer switch S2 (Fig. 2).
Using a variac, the voltage can be varied and the stabilizer output observed on a voltmeter. If the voltage boosts up instead of bucking, reverse the secondary winding terminals connected in series to the mains.


Capacitor C6 (0.1μF) at the output terminals of X2 removes minor ripples, if any, in the waveform.


The optional input voltage display circuit consists of three common-anode, seven-segment LEDs (each LTS542) shown in Fig. 5. The seven-segment LED displays are driven from port-B of the chip in a multiplexed manner. The anode selections are made through bits 0 through 2 from port-D via transistors T4 through T6, respectively.




























































































More Posts

gElectron. Powered by Blogger.

Contributors

16x2 LCD Interfacing with STM32,STM32F103C6

 16x2 LCD  Interfacing with STM32,STM32F103C6 lcd_init(); LCD_LINE1; lcd_String(" GeElectron"); LCD_LINE2; lc...

Contact Form

Name

Email *

Message *

Contact us

Name

Email *

Message *

Follow Us

https://www.facebook.com/gElectron-393939667321867/ FBbox/https://www.facebook.com/IVYthemes

Comments

[blogger]

MKRdezign

Test

Latest

[recent][newsticker]

Technology

Top Ads

RECENT COMMENTS

Subscribe Via Email

Subscribe to our newsletter to get the latest updates to your inbox. ;-)


Your email address is safe with us!

RECENT COMMENTS