• AVR Freaks

Helpful ReplyHot!Half- bridge 50hz UPS with center-taped transformer

Page: 12 > Showing page 1 of 2
Author
MOHAEGY
Starting Member
  • Total Posts : 76
  • Reward points : 0
  • Joined: 2020/05/27 11:33:24
  • Location: 0
  • Status: offline
2020/07/25 17:42:19 (permalink)
0

Half- bridge 50hz UPS with center-taped transformer

hello everyone 
i have a project to add an option to control card work by PIC16F877A and crystal 12Mhz the option which required is a UPS circuit similar to which i attached now my problem 
i know that i can't generate a PWM with 50hz from PWM module So, i decided to implement  a software PWM  but now every pin of the two pins which used to drive MOSFET must have 50hz frequancy to get a 50hz waveform from the transformer output or what?
Another question can i use the PWM comparator and timer1 to generate my 50hz square wave how can i do that?
 

Attached Image(s)

#1
ric
Super Member
  • Total Posts : 28011
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: Half- bridge 50hz UPS with center-taped transformer 2020/07/25 18:14:28 (permalink)
+2 (2)
Robotics011
hello everyone 
i have a project to add an option to control card work by PIC16F877A and crystal 12Mhz the option which required is a UPS circuit similar to which i attached now my problem

Do you really have to use a PIC16F877A?
This 20 year old chip really is getting antiquated now.
There are cheaper, faster, more reliable PIC16F devices you can get in the same package.
 

i know that i can't generate a PWM with 50hz from PWM module

That all depends upon how fast you run the PIC.

So, i decided to implement  a software PWM  but now every pin of the two pins which used to drive MOSFET must have 50hz frequancy to get a 50hz waveform from the transformer output or what?

Yes. 50Hz is easy to implement on a PIC if it's running at 8-20 MHz.
You do have to be very careful of read-modify-write effects on your output pins though, when working with these old PICs that lack LATx registers.
 

Another question can i use the PWM comparator and timer1 to generate my 50hz square wave how can i do that?

You can use the CCP peripheral to generate a 20ms timer. You use it in "compare mode", not "PWM mode".
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#2
Bob White
Super Member
  • Total Posts : 336
  • Reward points : 0
  • Joined: 2010/11/06 19:52:38
  • Location: Denver, Colorado
  • Status: offline
Re: Half- bridge 50hz UPS with center-taped transformer 2020/07/25 18:47:10 (permalink)
0
You need to go back to electronics-DIY.com and re-read the description on this this circuit works.  See especially the first oscilloscope trace photo.
 
#3
PStechPaul
Super Member
  • Total Posts : 2814
  • Reward points : 0
  • Joined: 2006/06/27 16:11:32
  • Location: Cockeysville, MD, USA
  • Status: offline
Re: Half- bridge 50hz UPS with center-taped transformer 2020/07/25 21:12:28 (permalink)
+2 (2)
You should try a simulation before building this. A true modified sine wave for 240 VAC 50 Hz consists of pulses of 300 VDC and about 5-7 mSec wide, which results in 240 volts RMS. A typical cheap 12V automotive type inverter will first create a DC bus link of about 280-320 VDC, and then use an H-bridge to create the requisite waveform. Here is a circuit that should work, and you can see that it is not so simple:
 
http://danyk.cz/menic230_6_en.html
 
Here are other ideas, but I think they may have problems:
 
https://www.brighthubengi...sine-wave-equivalents/
 
https://electronics-proje...wave-inverter-circuit/
 
Here is my simulation. As you can see, the gate drive waveform is correct, but the output is not:
 

 
 
 
 
 
 

Attached Image(s)


 
#4
PStechPaul
Super Member
  • Total Posts : 2814
  • Reward points : 0
  • Joined: 2006/06/27 16:11:32
  • Location: Cockeysville, MD, USA
  • Status: offline
Re: Half- bridge 50hz UPS with center-taped transformer 2020/07/25 22:00:26 (permalink)
0
You can get a good square wave AC output using a center tapped transformer, and that may work OK for many things. But to get a modified sine wave you must use a bridge circuit, as shown in the simulation below:

 
#5
PStechPaul
Super Member
  • Total Posts : 2814
  • Reward points : 0
  • Joined: 2006/06/27 16:11:32
  • Location: Cockeysville, MD, USA
  • Status: offline
Re: Half- bridge 50hz UPS with center-taped transformer 2020/07/25 22:05:22 (permalink)
0

Attached Image(s)


 
#6
MOHAEGY
Starting Member
  • Total Posts : 76
  • Reward points : 0
  • Joined: 2020/05/27 11:33:24
  • Location: 0
  • Status: offline
Re: Half- bridge 50hz UPS with center-taped transformer 2020/07/26 16:59:33 (permalink)
0
Firstly, Thanks to every one who replay to me and help me 
With my sorry RIC i understand that this device is very old one this also an old control card but this we here just add option as the customer needs this old control card work with PIC16F877A with external oscillator 12 MHz 
*- we have 48v dc batteries voltage from batteries ( 12v/7AH)
*- No we don't need to got a modified sine wave we just need square wave with dead band off-course where the output of this UPS just operate some contactors and a motor brake 
 
Now i still disturbed about how to implement this 50hz frequency  because:-
1- is i will generate one 50hz squre wave feed to the high side MOSFET with complement of it feed to low side MOSFET or i must generate two square wave every one have 25hz 
2- 
 
 
#7
davea
Super Member
  • Total Posts : 278
  • Reward points : 0
  • Joined: 2016/01/28 13:12:13
  • Location: Tampa Bay FL USA
  • Status: offline
Re: Half- bridge 50hz UPS with center-taped transformer 2020/07/26 17:15:29 (permalink)
0
@Paul
what are your settings on V2 and V3
ie: duty cycle and phase shift ?
 
MOSFET or i must generate two square wave every one have 25hz
you need a 10ms timer to toggle the outputs NOP for dead time
and the RMS of a square wave is 1.4 times that of a sine
be careful not to overheat the solenoids   
post edited by davea - 2020/07/26 17:30:25
#8
PStechPaul
Super Member
  • Total Posts : 2814
  • Reward points : 0
  • Joined: 2006/06/27 16:11:32
  • Location: Cockeysville, MD, USA
  • Status: offline
Re: Half- bridge 50hz UPS with center-taped transformer 2020/07/26 17:34:03 (permalink)
+1 (1)
The pulse generator V2 has a delay of 5 mSec and a pulse width of 5 mSec, with period of 20 mSec. V3 is the same except it has a delay of 15 mSec. I have actually built this circuit using a PIC12F1822, using very simple code. I am using 12 VDC and a 25.2V center tapped transformer to get a 270 volt P-P square wave at 100 Hz, with which I am driving a CFL circuit and a 6 watt T5 fluorescent bulb.
 
// PIC12F1822 Configuration Bit Settings

// 'C' source line config statements

// CONFIG1
#pragma config FOSC = INTOSC    // Oscillator Selection (INTOSC oscillator: I/O function on CLKIN pin)
#pragma config WDTE = OFF       // Watchdog Timer Enable (WDT disabled)
#pragma config PWRTE = ON       // Power-up Timer Enable (PWRT enabled)
#pragma config MCLRE = ON       // MCLR Pin Function Select (MCLR/VPP pin function is digital input)
#pragma config CP = OFF         // Flash Program Memory Code Protection (Program memory code protection is disabled)
#pragma config CPD = OFF        // Data Memory Code Protection (Data memory code protection is disabled)
#pragma config BOREN = ON       // Brown-out Reset Enable (Brown-out Reset enabled)
#pragma config CLKOUTEN = OFF   // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin)
#pragma config IESO = ON        // Internal/External Switchover (Internal/External Switchover mode is enabled)
#pragma config FCMEN = ON       // Fail-Safe Clock Monitor Enable (Fail-Safe Clock Monitor is enabled)

// CONFIG2
#pragma config WRT = OFF        // Flash Memory Self-Write Protection (Write protection off)
#pragma config PLLEN = ON       // PLL Enable (4x PLL enabled)
#pragma config STVREN = ON      // Stack Overflow/Underflow Reset Enable (Stack Overflow or Underflow will cause a Reset)
#pragma config BORV = LO        // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (Vbor), low trip point selected.)
#pragma config LVP = OFF         // Low-Voltage Programming Enable (Low-voltage programming enabled)

// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.

#include <xc.h>

#define _XTAL_FREQ 4000000

#define    ADCON0SET    0b00001100    //<6:2>CHSEL: 00011=AN3, <1>GO/DONE, <0>ADON

#define    ADCON1SET    0b01010011    //<7>ADFM 0=left, <6:4>ADCS 101=Fosc/16, <3:2>N/A, <1:0>ADPREF 11=FVR

#define    ANSELASET    0b00000000    //<0,1,2,4>=ANSA0, ANSA1, ANSA2, ANSA4

#define    FVRCONSET    0b10000010    //<7>FVREN, <6>FVRRDY, <5>TSEN, <4>TSRNG, <3:2>CDAFVR, <1:0>10=2.048VREF

#define    OPTIONSET    0b10000011    //<7>WPU, <6>INTEDG, <5>TMR0CS 0=Fosc/4, <3>PSA 0=TMR0,
                                //<2:0>PS 000=1:2, 011=1:16, 111=1:256

#define    OSCCONSET    0b01101111    //<7>SPLLEN, <6:3>IRCF 1101=4MHz, <2>N/A, <1:0>11=IntOsc

#define T1CONSET    0b00001000  // <7:6>CS: 00-fOsc/4, 01=fOsc <5:4>Prescale: 00=1, <3>1=enable, <2:1>N/A, <0>1=ON

#define    T2CONSET    0b01111001    // <6:3> Postscale 1111=> 16, <0:1> Prescale 01=> 4, 10=> 16 11=> 64

#define    TRISASET    0b00000000    // Set <0:6> as output
#define    INTCONSET    0b00000000    // Setup INTCON 7:GEIE, 6:PEIE, 5:TMR0IE, 4:INTE, 3:IOCIE, 2:TMR0IF, 1:INTF, 0:IOCIF
#define    PIE1SET        0b00000000    // <7>TMR1GIE, <6>ADIE, <5>RCIE, <4>TXIE, <3>SSP1IE, <2>CCP1IE, <1>TMR2IE, <0>TMR1IE
#define    PIR1SET        0b00000000    // <7>TMR1GIF, <6>ADIF, <5>RCIF, <4>TXIF, <3>SSP1IF, <2>CCP1IF, <1>TMR2IF, <0>TMR1IF

void    Initialize(void)    {
    OSCCON = OSCCONSET;
    OPTION_REG = OPTIONSET;
    INTCON = INTCONSET;
    TRISA = TRISASET;
    ANSELA = ANSELASET;
    
    T2CON = T2CONSET;
    PR2 = 49;                  //
    PIE1bits.TMR2IE =1;
    T2CONbits.TMR2ON =1;
    INTCONbits.PEIE = 1;    //Turn on Peripheral Interrupts
    INTCONbits.GIE = 1;        //Turn on Global Interrupts
}
volatile unsigned char mode = 0b00100000;

void    __interrupt()   HighIntCode(void)    // for XC8 compiler
    {
    if( PIR1bits.TMR2IF ) {    
            LATAbits.LATA2 ^= 1;    // Red/Green LEDs flash
            mode ^= 0b00110000;
            LATA &= 0b00001111;     // Clear outputs
            LATA |= mode;
            PIR1bits.TMR2IF = 0;
        }
    else if(PIR1bits.ADIF ) {
//        ADCresult = ADRESH;
        PIR1bits.ADIF = 0;
        }
    else if(PIR1bits.CCP1IF) {
        PIR1bits.CCP1IF = 0;
        }
    }

int counter=0;
void main(void)
{
    Initialize();
    while(1)
    {
    counter++;    
    }
}


 
#9
PStechPaul
Super Member
  • Total Posts : 2814
  • Reward points : 0
  • Joined: 2006/06/27 16:11:32
  • Location: Cockeysville, MD, USA
  • Status: offline
Re: Half- bridge 50hz UPS with center-taped transformer 2020/07/26 17:35:55 (permalink)
0
I'll try to post an image of the waveform here:
 

 

Attached Image(s)


 
#10
MOHAEGY
Starting Member
  • Total Posts : 76
  • Reward points : 0
  • Joined: 2020/05/27 11:33:24
  • Location: 0
  • Status: offline
Re: Half- bridge 50hz UPS with center-taped transformer 2020/07/26 17:49:56 (permalink)
0
 RMS of a square wave is 1.4 times that of a sine
be careful not to overheat the solenoids   
i don't understand that so i must decrease the duty cycle to say 45%  to overcome this or what?
#11
PStechPaul
Super Member
  • Total Posts : 2814
  • Reward points : 0
  • Joined: 2006/06/27 16:11:32
  • Location: Cockeysville, MD, USA
  • Status: offline
Re: Half- bridge 50hz UPS with center-taped transformer 2020/07/26 18:06:11 (permalink)
+2 (2)
For a simple square wave inverter using a center tapped transformer, the output voltage will be determined by the input voltage and the turns ratio of the transformer. The waveform I show is 135 volts peak and also 135 volts RMS. For my purpose, this is fine, because it is driving the input of a CFL circuit, which is a switching power supply that rectifies the incoming waveform and that will charge the filter capacitor to the P-P voltage of 270 VDC. A 120 VAC sine wave has peak voltage of 170 volts so the capacitor will charge to a maximum of 340 VDC, but because of current drain it will be an average of around 250-300 VDC.
 
If you are driving an inductive load, such as AC solenoids, the current will depend on both amplitude and frequency. So if the voltage is too high at 50 Hz, you could increase the frequency to decrease the current. You really can't change the duty cycle to adjust the effective output voltage unless you use a full bridge driver instead of a push-pull drive to a center tapped transformer.

 
#12
ric
Super Member
  • Total Posts : 28011
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: Half- bridge 50hz UPS with center-taped transformer 2020/07/26 18:19:54 (permalink)
+2 (2)
I get nervous when users with minimal knowledge of AC properties ask how to work with mains voltages...
 
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#13
Bob White
Super Member
  • Total Posts : 336
  • Reward points : 0
  • Joined: 2010/11/06 19:52:38
  • Location: Denver, Colorado
  • Status: offline
Re: Half- bridge 50hz UPS with center-taped transformer 2020/07/26 18:25:11 (permalink) ☄ Helpfulby MOHAEGY 2020/07/27 08:00:17
+1 (1)
Robotics011
Now i still disturbed about how to implement this 50hz frequency  because:-
1- is i will generate one 50hz squre wave feed to the high side MOSFET with complement of it feed to low side MOSFET or i must generate two square wave every one have 25hz 



Did you not go back to the original web page and see what was done there?
 
You need two outputs from the PIC, one for each MOSFET gate.  We will call the MOSFETs Q1 and Q2.  What you need is the following sequence where each interval in 5 ms long.
 
Interval 1: Q1 off, Q2 off
Interval 2: Q1 on, Q2 off
Interval 3: Q1 off, Q2 off
Interval 4: Q1 off, Q2 on
Repeat
 
Look at the scope trace on the DIY-eletronics web page to see this in action.
 
And, by the way, the title of this post is wrong.  The power converter topology shown on the DIY-electronics webpage is not a half-bridge, it is a push-pull.
 
post edited by Bob White - 2020/07/26 19:19:24
#14
MOHAEGY
Starting Member
  • Total Posts : 76
  • Reward points : 0
  • Joined: 2020/05/27 11:33:24
  • Location: 0
  • Status: offline
Re: Half- bridge 50hz UPS with center-taped transformer 2020/07/26 19:18:45 (permalink)
0
It's OK thanks to all but now the hardware design section give me the hardware which i attached i have more one question which is 
Is the two capacitors here work as switches so here we have a full bridge where i see that the capacitors will complete the bridge ?? or just they work as LC tank here[image]D:\EMcard\220UPS[/image] ?

Attached Image(s)

#15
Bob White
Super Member
  • Total Posts : 336
  • Reward points : 0
  • Joined: 2010/11/06 19:52:38
  • Location: Denver, Colorado
  • Status: offline
Re: Half- bridge 50hz UPS with center-taped transformer 2020/07/26 19:40:32 (permalink)
+1 (1)
Robotics011
It's OK thanks to all but now the hardware design section give me the hardware which i attached i have more one question which is 
Is the two capacitors here work as switches so here we have a full bridge where i see that the capacitors will complete the bridge ?? or just they work as LC tank here[image]D:\EMcard\220UPS[/image] ?



I am not sure where you got that schematic but if you think that circuit is correct I have some advice for you:
 
STOP!  You have no idea what you are doing.  You are working with voltages and currents that can kill you.  find somebody local who can help you and teach you before you get hurt, destroy equipment, or start a fire.
#16
MOHAEGY
Starting Member
  • Total Posts : 76
  • Reward points : 0
  • Joined: 2020/05/27 11:33:24
  • Location: 0
  • Status: offline
Re: Half- bridge 50hz UPS with center-taped transformer 2020/07/26 21:54:34 (permalink)
-1 (1)
For Bob thanks for your advice i contact the person who give me the hardware and we find rong connection i modified it and attached it and he told me that circuit i a practical one from a product its picture also attached 
Now i just do it with Proteus not in practical yet so, don't afraid dear Bub 
i will write the code and test it by see the waveform on every stage and on output  let's we see 
thanks and any advice will be welcome here iam just learn and wanted to learn 
 
 

Attached Image(s)

#17
davea
Super Member
  • Total Posts : 278
  • Reward points : 0
  • Joined: 2016/01/28 13:12:13
  • Location: Tampa Bay FL USA
  • Status: offline
Re: Half- bridge 50hz UPS with center-taped transformer 2020/07/26 22:13:18 (permalink)
0
this may be slightly off topic 
but I need a good answer...
I use a technique that that shorts the off time in the full bridge
so that inductive loads do not ring and use 60 deg phase shift (+180)
and i have just noticed at 12Vdc the AC voltage is 9.8 where as at 90 deg is
8.48 Vac (12/1.414) what it should be..
i have searched the internet and found examples from 60 to 90 deg without shorting state
my question is the most efficient phase shift in deg and has the least harmonics (with LCL T filter) 
this is done at 125 Khz to transmit magnetic field at 15 Watts (loop wire coil tuned)
and what do you think about the shorting state
sorry about my babble it late..
davea
post edited by davea - 2020/07/27 09:17:42

Attached Image(s)

#18
PStechPaul
Super Member
  • Total Posts : 2814
  • Reward points : 0
  • Joined: 2006/06/27 16:11:32
  • Location: Cockeysville, MD, USA
  • Status: offline
Re: Half- bridge 50hz UPS with center-taped transformer 2020/07/26 22:36:44 (permalink) ☄ Helpfulby MOHAEGY 2020/07/27 07:59:51
+3 (3)

You really should use proper MOSFET drivers instead of what you show. The MOSFETs will turn off quickly, but turn-on will depend on the pull-up resistors on the NPN transistors. But an even greater problem is that when the MOSFETs are turned on, they will quickly (and perhaps destructively) discharge the associated capacitors.

 
#19
PStechPaul
Super Member
  • Total Posts : 2814
  • Reward points : 0
  • Joined: 2006/06/27 16:11:32
  • Location: Cockeysville, MD, USA
  • Status: offline
Re: Half- bridge 50hz UPS with center-taped transformer 2020/07/26 22:50:10 (permalink)
0

This is a full bridge implementation of a modified sine wave converter. Of course, you would need to use a MOSFET full bridge circuit with appropriate Hi-Lo drivers to make it work. If the peak voltage is 160 volts, as it is in my simulation in post #6, a 50% duty cycle on each half-cycle will have an RMS value of 113 VRMS, which is 160/sqrt(2). So that is an ideal modified sine wave.
 
But if you have the hardware and firmware to do this, you might as well go with a full PWM implementation, and get essentially a pure sine wave (after appropriate filtering).
 

 
#20
Page: 12 > Showing page 1 of 2
Jump to:
© 2020 APG vNext Commercial Version 4.5