|
|
View previous topic :: View next topic |
Author |
Message |
PICnMIX Guest
|
PWM on 18f1230/1330 |
Posted: Sun Mar 15, 2009 5:35 am |
|
|
Hi
I am trying to use 18f1x30 to produce 3 PWM sinusoidal signals to control the speed of a motor.
I have selected the 8Mhz internal oscillator and centre aligned PWM with 250us period. I need to initiate a PWM interrupt every period to update the duty cycle registers.
Can anyone tell me how this is achieved? At present the MPLAB simulator indicates that PTMR registers are counting down only with no setting of the PTIE bit when it counts through 0.
Incidentally, can anyone explain the significance of setting the initial value of the timebase in setup_power_pwm(). I have seen examples which set this to 0 but the C Compiler manual gives an example of 10000.
Thanks very much. |
|
|
Sydney
Joined: 13 Feb 2009 Posts: 71
|
|
Posted: Sun Mar 15, 2009 9:45 am |
|
|
Presumably you want the 3 pwms 90° out of phase, and I dont think that can be done. |
|
|
Ttelmah Guest
|
|
Posted: Sun Mar 15, 2009 4:03 pm |
|
|
You'd normally want 120 degree phases, not 90 degree....
Yes, the power control PWM, can do this, the topology needed, will depend on the wiring of your phases. Simplest using H bridge drive, with a star layout. Obviously not a a true sine wave (PWM _simulating_ the effect of a sine wave). You will have problems with some parts of the code, the interrupt update rate in particular is easier handled in assembler, or requires very careful coding (see my notes in the past about using the 'fast' interrupt option, and writing a handler for this). A lot will depend on just what frequencies you want to generate?.
What is your interrupt postscaler set to?.
Post the setup you are using for the PWM, and your compiler version. Not all versions setup the register 'right', and when the interrupt occurs, depends on how you have the PWM setup...
The initial timebase value, is just what it says. The value fed into the PTMR register(s) on setup.
Your arithmetic is going to get complex, if you are synthesising the three phases, and adjusting frequency as well. You might want to consider a lookup table for the synthesis, and then perform an integer scaling of the values.
Best Wishes |
|
|
Sydney
Joined: 13 Feb 2009 Posts: 71
|
|
Posted: Mon Mar 16, 2009 12:05 am |
|
|
Ttelmah wrote: | You'd normally want 120 degree phases, not 90 degree.... |
Yeah thats what I meant |
|
|
Guest
|
|
Posted: Mon Mar 16, 2009 3:45 pm |
|
|
Thanks for replying guys
This is a split single phase motor and I am using it star connected. My phase shifts are 0, 180, 288 degrees. Provided the amplitude of all three sine waves are equal then the 180 degree phase shift between main in and auxilliary in will give the 90degree phase shift between main and auxiulliary regardless of the phase of the (common) star point - basic geometry! The choice of common phase depends upon the motor turns ratio.
I am using a look up table and scaling to obtain pwm duty values and have a routine which reliably reads the correct values in the correct order into the duty cycle registers.
My problem comes when I try to initiate an interrupt each period (250us)
to load the next three values.
I am using centre aligned pwm (continuous up down count) PTCON0 = 0x02, except that when I try to simulate operation on MPLAB sim, although PTCON1 contains 0x80 (count up), PTMRx actually counts down to 0, rolls over to 0xFF and continues counting down. The PTIF interrupt trigger just ignores everything and stays set at 0.
As far as the pwm time base initial value is concerned, maybe my question should not be what but why? |
|
|
|
|
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
|