CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

PWM with dead band delay

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
aderogba



Joined: 03 Jun 2005
Posts: 8

View user's profile Send private message

PWM with dead band delay
PostPosted: Thu Aug 04, 2005 7:38 am     Reply with quote

Please I need some guidance on setting up pwm with dead band delay in half bridge mode. The pic I'm using is 18F6722.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Aug 05, 2005 3:22 pm     Reply with quote

The dead time should be set to a little bit more than the amount
of time it takes for your FETs to turn off. In your FET data sheet,
you should see values for the "turn off delay time" and "fall time".
You could add those together, but I think it's better if you measure
the turn off time with an oscilloscope. That's because you normally
have a series resistor going to the gate of your FET, and the FET has
a lot of gate capacitance, so this acts as a RC circuit and slows down
the edge of the gate drive waveform.

You didn't give the FET part number, so let's just pick a large initial
value for the dead time, say 1 us. The 18F6722 data sheet says
the dead time is controlled by the ECCPxDEL registers. The lower
7 bits set the dead time, in terms of instruction cycles. So if your
PIC is running at 20 MHz, one instruction cycle is 200 ns. So your
dead time value has a 200 ns resolution. So if you want the dead
time to be 1 us, you would set the ECCP1DEL register = 0x05.
(Bit 7 of that register is used to control the auto-shutdown feature,
but I'm not going to worry about that now.)
aderogba



Joined: 03 Jun 2005
Posts: 8

View user's profile Send private message

PostPosted: Mon Aug 08, 2005 4:13 pm     Reply with quote

Thanks for the response. Please do you know if there is ccs sample code or code snippet for this application? I'm still having problem setting the program up.
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Mon Aug 08, 2005 5:44 pm     Reply with quote

Is it possible to have PIC’s CCP generate 2 square waves out of phase? I had to generate 2 out of phase square waves with deadband at 500kHz. I ended up doing it with GAL (it was really easy).
valemike
Guest







PostPosted: Mon Aug 08, 2005 6:51 pm     Reply with quote

kender wrote:
Is it possible to have PIC’s CCP generate 2 square waves out of phase? I had to generate 2 out of phase square waves with deadband at 500kHz. I ended up doing it with GAL (it was really easy).


I figure you can do it by using ECCP and CCP and use two different timers. In the beginning you manually zero out both timers, allow some time to let the phase drift, then zero out the timer again. Now you have two timers out of phase with the same timebase (Fosc)
valemike
Guest







PostPosted: Mon Aug 08, 2005 6:58 pm     Reply with quote

aderogba wrote:
Thanks for the response. Please do you know if there is ccs sample code or code snippet for this application? I'm still having problem setting the program up.


You really have to read the PIC manual. It talks about ECCP setup which is only half a page of bullet points. Please, read it.

This example sets up ECCP as a full bridge. With 2 simple line changes you can turn it into a half bridge setup with deadtime. Again, read the manual.

My richly commented code is taken directly from the manual, so you should be able to follow it. Reading thru the code, along with reading PCM Programmer's detailed explanation, will be of more value to you than waiting for someone to code it for you and posting it.

Code:

void setup_eccp(int direction)
{
    /* Disable ECCP1/P1A, P1B, P1C and P1D */
    latd = latd | 0xF0;
    trisd = trisd | 0xF0; // set 1111 xxxx; leave x's alone   
    delay_ms(1);

    /* Set PWM period by loading PR2 register */
    PIC_PR2 = 100;
   
    /* Set the PWM duty cycle by loading the ECCPR1L register and */
    /* ECCP1CON<5:4> bits. */
    PIC_ECCPR1L = 0x00;       // this keeps it off
     
    /* Configure ECCP1 module for */
    /* 1. PWM full bridge output forward */
    /* 2. Active LOW on all four fets */

    if (direction == DIRECTION_CLOSING)
    {
        PIC_ECCP1CON = 0x4F;  // 0100 1111
        GLOBAL_motor_state = MOTOR_CLOSING;
    }

    else // direction = DIRECTION_OPENING
    {
        PIC_ECCP1CON = 0xCF;
        GLOBAL_motor_state = MOTOR_OPENING;
    }
   
    /* Configure and start timer 2. Use divide by 1 */
    /* Clear timer2 interrupt flag bit */
    PIC_PIR1 &= ~PIC_PIR1_TMR2IF;
   
    /* Set TMR2 prescale value by setting 1:0 */
    PIC_T2CON = 0x00;  /* same as por values? */
   
    /* Turn on Timer 2 */
    PIC_T2CON |= 0x04;
   
    /* Enable PWM outputs after a new cycle has started */
    /* Wait for TMR2 overflow */
    while (!(PIC_PIR1 & PIC_PIR1_TMR2IF))
    {
        /* wait */
    }
   
    /* Now clear the TRISD bits */
    trisd = trisd & 0x0F;  // clear 0000 xxxx; leave x's alone
}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group