• AVR Freaks

Hot!dsPIC33EP256MU806 PWM Behavior

Author
ASICAlex
Starting Member
  • Total Posts : 43
  • Reward points : 0
  • Joined: 2018/02/27 15:40:02
  • Location: 0
  • Status: offline
2019/08/13 14:16:36 (permalink)
0

dsPIC33EP256MU806 PWM Behavior

I am using the dsPIC33EP256MU806 PWM's to drive a 3 phase BLDC motor with the common H bridge.  I am running at 60MIPS and running the PWM in edge aligned, master time base and duty cycle, and complementary mode.  Using a small 4 pole test motor, it runs fine.  Now we are using the real motor(that is 8 pole) that will be used in the product and the motor is stopping randomly.  Can be minutes or sometimes hours.  When the motor is stopped, the high side PWM of the positive phase has stopped outputting (the low PWM signal is still there).  This is weird since they should be generated from the same source and be complementary of each other.  Also if I pause the code it looks like the PWMCON registers get reset.  Lastly, if I pause the code and then continue to run the PWM, the high side comes back and the motor continues to run.  I have been unable to see anything obvious in my code, but perhaps I am setting something up wrong?  I have included my initialization routine.  If anyone has any ideas, I would be forever grateful. 
 
void PWM_Initialize (void)
{
    // PCLKDIV 2;
    PTCON2 = 0x1;
    // PTPER 3000;
    PTPER = 0xBB8;
    // SEVTCMP 1248; Special Event Trigger Period (compares to PTPER value for trigger to ADC)
    SEVTCMP = 500;
    // MDC 1500;
    MDC = 0xA00;
    // CHOPCLK 0; CHPCLKEN disabled;
    CHOP = 0x0;
    // PWMKEY 0;
    //PWMKEY = 0x0;
    // MDCS Master; FLTIEN disabled; CAM Edge Aligned; DTC Positive dead time for all Output modes; TRGIEN disabled; XPRES disabled; ITB Master; IUE enabled; CLIEN disabled; MTBS disabled; DTCP disabled;
    PWMCON1 = 0x101;
    // MDCS Master; FLTIEN disabled; CAM Edge Aligned; DTC Positive dead time for all Output modes; TRGIEN disabled; XPRES disabled; ITB Master; IUE enabled; CLIEN disabled; MTBS disabled; DTCP disabled;
    PWMCON2 = 0x101;
    // MDCS Master; FLTIEN disabled; CAM Edge Aligned; DTC Positive dead time for all Output modes; TRGIEN disabled; XPRES disabled; ITB Master; IUE enabled; CLIEN disabled; MTBS disabled; DTCP disabled;
    PWMCON3 = 0x101;
    //FLTDAT PWM1L Low, PWM1H Low; SWAP disabled; OVRENH disabled; PENL enabled; PMOD Complementary Output Mode; OVRENL disabled; OSYNC disabled; POLL disabled; PENH enabled; CLDAT PWM1L Low, PWM1H Low; OVRDAT PWM1L Low, PWM1H Low; POLH disabled;
    IOCON1=0xC000;
    //FLTDAT PWM2L Low, PWM2H Low; SWAP disabled; OVRENH disabled; PENL enabled; PMOD Complementary Output Mode; OVRENL disabled; OSYNC disabled; POLL disabled; PENH enabled; CLDAT PWM2L Low, PWM2H Low; OVRDAT PWM2L Low, PWM2H Low; POLH disabled;
    IOCON2=0xC000;
    //FLTDAT PWM3L Low, PWM3H Low; SWAP disabled; OVRENH disabled; PENL enabled; PMOD Complementary Output Mode; OVRENL disabled; OSYNC disabled; POLL disabled; PENH enabled; CLDAT PWM3L Low, PWM3H Low; OVRDAT PWM3L Low, PWM3H Low; POLH disabled;
    IOCON3=0xC000;
    //FLTPOL disabled; CLPOL disabled; CLSRC FLT1; CLMOD disabled; FLTMOD PWM1H, PWM1L pins to FLTDAT values- Latched; FLTSRC FLT32;
    FCLCON1= 0xFB;
    //FLTPOL disabled; CLPOL disabled; CLSRC FLT1; CLMOD disabled; FLTMOD PWM2H, PWM2L pins to FLTDAT values- Latched; FLTSRC FLT32;
    FCLCON2=0xFB;
    //FLTPOL disabled; CLPOL disabled; CLSRC FLT1; CLMOD disabled; FLTMOD PWM3H, PWM3L pins to FLTDAT values- Latched; FLTSRC FLT32;
    FCLCON3= 0xFB;
    // PDC1 0;
    PDC1 = 0x0;
    // PDC2 0;
    PDC2 = 0x0;
    // PDC3 0;
    PDC3 = 0x0;
    // PHASE1 0;
    PHASE1 = 0x0;
    // PHASE2 0;
    PHASE2 = 0x0;
    // PHASE3 0;
    PHASE3 = 0x0;
    // DTR1 1us; See equation 14-7 in PWM datasheet
    DTR1 = 0x3C;
    // DTR2 1us;
    DTR2 = 0x3C;
    // DTR3 1us;
    DTR3 = 0x3C;
    // ALTDTR1 0;
    ALTDTR1 = 0x3C;
    // ALTDTR2 0;
    ALTDTR2 = 0x3C;
    // ALTDTR3 0;
    ALTDTR3 = 0x3C;
    // TRGCMP 0;
    TRIG1 = 0x0;
    // TRGCMP 0;
    TRIG2 = 0x0;
    // TRGCMP 0;
    TRIG3 = 0x0;
    // TRGDIV 1; TRGSTRT 0;
    TRGCON1 = 0x0;
    // TRGDIV 1; TRGSTRT 0;
    TRGCON2 = 0x0;
    // TRGDIV 1; TRGSTRT 0;
    TRGCON3 = 0x0;
    // BPLL disabled; BPHH disabled; BPLH disabled; BCH disabled; FLTLEBEN disabled; PLR disabled; CLLEBEN disabled; BCL disabled; PLF disabled; PHR disabled; BPHL disabled; PHF disabled;
    LEBCON1 = 0x0;
    // BPLL disabled; BPHH disabled; BPLH disabled; BCH disabled; FLTLEBEN disabled; PLR disabled; CLLEBEN disabled; BCL disabled; PLF disabled; PHR disabled; BPHL disabled; PHF disabled;
    LEBCON2 = 0x0;
    // BPLL disabled; BPHH disabled; BPLH disabled; BCH disabled; FLTLEBEN disabled; PLR disabled; CLLEBEN disabled; BCL disabled; PLF disabled; PHR disabled; BPHL disabled; PHF disabled;
    LEBCON3 = 0x0;
    // LEB 0;
    LEBDLY1 = 0x0;
    // LEB 0;
    LEBDLY2 = 0x0;
    // LEB 0;
    LEBDLY3 = 0x0;
    // CHOPLEN disabled; CHOPHEN disabled; BLANKSEL No state blanking; CHOPSEL No state blanking;
    AUXCON1 = 0x0;
    // CHOPLEN disabled; CHOPHEN disabled; BLANKSEL No state blanking; CHOPSEL No state blanking;
    AUXCON2 = 0x0;
    // CHOPLEN disabled; CHOPHEN disabled; BLANKSEL No state blanking; CHOPSEL No state blanking;
    AUXCON3 = 0x0;
    
    //Interrupts
    IFS5bits.PWM1IF = false;
    IEC5bits.PWM1IE = false;

    // SYNCOEN disabled; SEIEN disabled; SESTAT disabled; SEVTPS 1; SYNCSRC SYNCI1; SYNCEN disabled; PTSIDL disabled; PTEN enabled; EIPU disabled; SYNCPOL disabled;
    PTCON = 0x8000;
}


#1

3 Replies Related Threads

    mpgmike
    Super Member
    • Total Posts : 252
    • Reward points : 0
    • Joined: 2014/01/23 17:27:06
    • Location: NJ
    • Status: offline
    Re: dsPIC33EP256MU806 PWM Behavior 2019/08/14 06:49:15 (permalink)
    0
    Sounds like you're experiencing a Reset.  It might be BOR/LPBOR etc.  Electric motors are noisy.  I was experiencing random resets powering an ignition coil (also noisy) that was affecting the power supply.  I added several more caps to filter out the noise and that fixed it for me.  Try seeing if you can identify the source of your Reset to help track it down.

    I don't need the world to know my name, but I want to live a life so all my great-grandchildren proudly remember me.
    #2
    ASICAlex
    Starting Member
    • Total Posts : 43
    • Reward points : 0
    • Joined: 2018/02/27 15:40:02
    • Location: 0
    • Status: offline
    Re: dsPIC33EP256MU806 PWM Behavior 2019/08/14 16:53:38 (permalink)
    0
    Yeah, it definitely is not a microcontroller reset, as other stuff is still going on, but perhaps it could be BOR or something similar that is causing the PWM module to misbehave. I will have to look more into this.
     
    On your ignition coil unit, did you use a similar MCU?  Like I mentioned in the original post, when the motor stops and the PWM's misbehave, if I pause the code and then continue running it, the motor starts back up and everything looks as expected. Perhaps if something inside the PWM unit is getting reset, pausing and continuing in the debugger brings it out of  reset?  I think something with this particular motor is causing something bad to happen with the MCU, but I need to track that down to see if it is the noise.  We have put lots of caps on many different lines due to the switching noise.  I will try to see if I can capture the power lines right before the motor stops running. 
     
    Thanks for your reply!
    #3
    mpgmike
    Super Member
    • Total Posts : 252
    • Reward points : 0
    • Joined: 2014/01/23 17:27:06
    • Location: NJ
    • Status: offline
    Re: dsPIC33EP256MU806 PWM Behavior 2019/08/15 06:07:32 (permalink)
    0
    I was using a PIC16F18426 on the ignition controller, but the major issue was with a programmer that plugs into the controller.  It uses a Nextion display and the display would lock up.  I added extra caps to the programmer and changed from regular wires for the UART to a shielded cable.  It still acts up occasionally, but it's an R&D piece, not production.

    I don't need the world to know my name, but I want to live a life so all my great-grandchildren proudly remember me.
    #4
    Jump to:
    © 2019 APG vNext Commercial Version 4.5