• AVR Freaks

Hot!How to shifted phases in PIC18f4431

Author
geo368
New Member
  • Total Posts : 4
  • Reward points : 0
  • Joined: 2020/05/03 22:58:02
  • Location: 0
  • Status: offline
2020/05/31 02:26:53 (permalink)
0

How to shifted phases in PIC18f4431

I am trying to design a driver for a BLDC motor.
I have managed to generate 6 PWM signals with the PIC18F4431.
How I can shifted the phases?
I attach my code and the image of the PWM signals.
 
void pwm_inicialitze(void)
{
  PORTB=0x00;
  TRISBbits.TRISB0=0;
  TRISBbits.TRISB1=0;
  TRISBbits.TRISB2=0;
  TRISBbits.TRISB3=0;
  TRISBbits.TRISB5=0;
  TRISBbits.TRISB4=0;

  INTCON=0XC0;
  IPR3bits.PTIP=1;
  PIE3bits.PTIE=1;
  PIR3bits.PTIF=0;

  SEVTCMPL=0X00;
  SEVTCMPH=0X00;
  DTCON=8;
  FLTCONFIG=0X00;
  OVDCOND=0XFF;
  OVDCONS=0X00;

  PTMRL=0X00;
  PTMRH=0X00;
  PTCON0=0X00;
  PTCON1=0X80;
  PWMCON0=0X50;
  PWMCON1=0X01;
  PTPERL=124;
  PTPERH=0;

  PDC0L=60;
  PDC0H=0;
  PDC1L=60;
  PDC1H=0;
  PDC2L=60;
  PDC2H=0;
  PDC3L=60;
  PDC3H=0;

  ADCON0=0x00;
}

void main(void)
{
   ANSEL0=0X00;
   ANSEL1=0X00;
   pwm_inicialitze();
   while(1);
}

 
I want is to try to get such a shifted similar to the one in image 2.

Attached Image(s)

#1

2 Replies Related Threads

    RISC
    Super Member
    • Total Posts : 5776
    • Reward points : 0
    • Status: offline
    Re: How to shifted phases in PIC18f4431 2020/05/31 06:42:27 (permalink)
    +2 (2)
    Hi,
    PIC18F4431 is a quite old and expensive device...
    If you use more recent devices like dsPIC33EPxxxx family, you'll find lots of application notes and code examples for driving motors and you will also be able to use MCC graphical code generator. 
    dsPIC family has much more sophisticated PWM with more features.
    Regards
    #2
    JPortici
    Super Member
    • Total Posts : 1154
    • Reward points : 0
    • Joined: 2012/11/17 06:27:45
    • Location: Grappaland
    • Status: offline
    Re: How to shifted phases in PIC18f4431 2020/05/31 11:55:00 (permalink)
    +2 (2)
    moving to dsPIC will not improve a thing if you don't know what to do.
    MCC will not help if you don't know what to do with it.
    I don't understand why almost all of your replies are about moving to a newer part and using MCC when it will not solve the issue.
     
    To the OP, the idea is that you enable/disable the PWM generators in sequence.
    I assume that you are familliar with the six step commutation method?
    Using PWM to regulate the speed means that you still follow the six step commutation, but you enable/disable PWM channels instead of setting pins high and low.
    #3
    Jump to:
    © 2020 APG vNext Commercial Version 4.5