April 20, 2012

Frequency control of inverter (Proteus simulation)

Hello folks,
       Here is the post about Frequency control of Inverter with Avr microcontroller.
There are two method to control output power of inverter they are
1)PWM control (read this post)
2)Frequency control

   Que:     "How power of inverter is controlled by frequency control?"
    Ans:  This method is for series or parallel resonant circuit connected as load to the inverter.
resonance curve graph plot series parallel
LC Resonance curve
as you can see in the graph that maximum current flows at resonance frequency. if the frequency is above or below that the current decreases and power can be controlled with variation in frequency.

so, now you know why you need frequency control of inverter for power control in L-C tank circuits.
But, how to do that with AVR?
We can use timers in AVR microcontroller  to produce frequency whatever we want.(sounds so easy, yes it is so easy!!!)
But,that's not all we just don't have to make a pulse from microcontroller we have to make two non-overlapping pulses for full bridge inverter
H-bridge configuration
Full bridge full controlled inverter
as you can see from the fig we have to trigger S1 and S4 at same time and S2 and S3 at same time but pulses P1(for S1 and S4) and P2(S2and S3) should be non overlapping!!!

that has been taken care in the programming. We have inserted approx 6uS guard time for two pulses.

this is the specifications of below written BASCOM-code
1)Guard time of 6uS
2)Frequency display on LCD
3)2.1kHz to 10.8kHz frequency range
--------------------------------------------------------------------------------------------------------
'author:keyuracharya.blogspot.com
$regfile = "m8535.dat"                                      ' specify the used micro

$crystal = 16000000                                         ' used crystal frequency

'$baud = 9600                                                ' use baud rate

'$hwstack = 32                                               ' default use 32 for the hardware stack

'$swstack = 10                                               ' default use 10 for the SW stack

'$framesize = 40


Config Lcdpin = Pin , Db4 = Portc.4 , Db5 = Portc.5 , Db6 = Portc.6 , Db7 = Portc.7 , E = Portc.2 , Rs = Portc.0
Config Lcd = 16 * 2
Cursor Off

Dim Mybit1 As Bit
Dim Timer1_val As Byte
Dim Freq As Single
Dim T1 As Integer
Dim Diff As Byte
Dim S1 As String * 16



Mybit1 = 1
Timer1_val = 150

Config Portb.3 = Output
Config Portd.7 = Output
Ddra = 0
Porta = 255

Declare Sub Feequency_display
Locate 1 , 1
Lcd "Freq.control"

Enable Interrupts
Enable Compare2
Config Timer2 = Timer , Prescale = 32
On Compare2 Overflow_timer2


       Call Feequency_display

    Do

       If Pina.4 = 0 Then

         If Timer1_val < 240 Then
           Incr Timer1_val
           Call Feequency_display
         End If

       End If

       If Pina.5 = 0 Then
         If Timer1_val > 150 Then
            Decr Timer1_val
            Call Feequency_display
         End If
       End If

    Loop

End


Overflow_timer2:
  Portb.3 = 0
  Portd.7 = 0

  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  Portb.3 = Mybit1
  Toggle Mybit1
  Portd.7 = Mybit1
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  Timer2 = Timer1_val
  Return

  Sub Feequency_display
      Waitms 100
      Diff = 255 - Timer1_val
           T1 = 4 * Diff
           T1 = T1 + 32
           Freq = 1000 / T1
           S1 = Fusing(freq , "#.##")
           Locate 2 , 1
           Lcd S1 ; "kHz "

  End Sub
-------------------------------------------------------------------------------------------------
frequency generated from microcontroller
the output of this code is shown in figure above

Here "VSM counter timer" is used to measure frequency produced by AVR.
and you can see two non overlapping pulses generated from AVR.

the connection diagram is  shown below.
Frequency control of inverter

yet this is only the pulse generated from microcontroller,we have to apply them to MOSFET like IRF640 or IRFZ44,for that opto coupler like MCT2E can be used.you can read this post to see how to isolate the microcontroller from High power circuit.
Read more ...

April 09, 2012

Connect Proteus Virtual Serial Port with Windows Terminal . . .

To connect proteus virtual terminal with windows terminal first off remove vterm from your proteus design if you are using and replace it with compim DB-9 connector.

compim interfacing with microcontroller
Compim proteus

>>Connect Rx to Rx & Tx to Tx only. Don't make cross connection here.
>>If you want to just try it out then no need to create proteus circuit. Just connect one virtual terminal with                                  compim as shown in below figure.

compim connection
compim with terminal

>>Now open properties of compim. In it select physical port, physical baud rate & virtual baud rate.


>>Now get virtual serial port driver & install it in your system.
>>Then run this tool & create a virtal ports pair.

Virtual comport connector
virtual comport connector

>>Then open any terminal client. Open the paired port in virtual serial port driver.


>>That's it. Now your proteus Tx Rx & windows Tx Rx are cross connected.
>>If you have any doubts about this tutorial then feel free to comment.

Proteus virtual port driver
proteus virtual terminal
Download link : 

Posted by :
Read more ...

April 07, 2012

varying scr firing angle with Avr microcontroller(Proteus simulation)

        Hi friends here is the post about changing SCR firing angle control with the help of AVR microcontroller.
        You might be aware of basics of firing angle and its variation.So in a basic Firing angle variation mechanism you will need two things:  
                                                           1)ZERO CROSSING DETECTION  
                                                           2)FIRING SCR  AT DIFFERENT ANGLE
          First stage Zero crossing with AVR is damn easy thing as avr hardware supports zero-crossing detection. that means you can detect zero of 230 VAC with directly avr microcontroller and no additional hardware.
you can refer Avr's official application note to know more about zero crossing by microcontroller itself!!!! (Huh!!!!  QUESTION: How can avr tolerate 230 volts directly?
Answer: 1M resistor limits the current and internal avr diodes are used like clamper circuit.... to convert 230 volts to 5 volts that is accessible by micro-controller.)


zero crossing detection and firing angle control with avr
Zero crossing in avr with internal diodes
             now once you are through with 230v detection and generating an interrupt with the help of zero crossing, you are good to go for varying firing angle of scr.




 


After varying the firing angle you will be able to see the pulses as shown below



proteus scr firing angle
Firing angle


here is the source code to generate scr triggering pulse from microcontroller and varying it with 2 push buttons(i.e. increase or decrease firing angle) push buttons are connected to  PINA.6 and PINA.7 additionally a stop button is also used to stop SCR firing..
Stop button is connected to PINA.3 Here is the source code for that --------------------------------------------------------------------------------------------
#include"avr/io.h"
#include"delay.h" 
unsigned char stop=0;
unsigned long scrangle=0;
ISR(INT0_vect)
{
if (stop==0)
        {
        delayus(scrangle);
        PORTB=PORTB|0x01;
        delayus(1000);
        PORTB=PORTB &0xFE;
        }
}  void main()
   
     SREG=SREG|0x80;        //global interrupt enable  
     PORTA=0xFF;            // configuering the PORTA in pullup mode.
     DDRA=0x00;                // Port A data direction configuration as input port. 
    MCUCR=MCUCR|0x01;        // logic change  in pin generates an interrupt(hardware interrupt 0) 
    GICR=GICR|0x40;            //enable the interrupt 0 
        if((PINA & 0x80)==0x00)  //decrease firing angle
        {
            if(scrangle>0)
            {
                scrangle=scrangle-100;
            }
        }
        if ((PINA & 0x40)==0x00)    //increase firing angle
         {
            if(scrangle<8000)
            {
                scrangle=scrangle+100;
            }
           
         }
        if((PINA & 0x08)==0x00)    //reset pin to stop
            {
            stop=1;
            }
     } 
} 
 ------------------------------------------------------------------------------------------------------
Here is the output waveforms you can see a pulse generated by micro-controller on zero-crossing detection..

zero crossing with micro-controller
Pulse generated by Micro-controller on zero-crossing.


Thats all I have to say.
But remember some points guys...

1)You are playing with Mains power supply so be very very careful.
2)Ground of microcontroller and mains are not good isolated.
3)This is only pulse generation by microcontroller if you need to apply this pulse to SCR you have to put some conditioning circuit.
Read more ...
Related Posts Plugin for WordPress, Blogger...