catch 22 with PE pwm components

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

catch 22 with PE pwm components

1,000 Views
daveboyle
Contributor III

I am building a 3-phase acim motor driver with a K64F using KDS 2.0.0 and Processor Expert. I need 6 pwm channels arranged as 3 complementary pairs with dead time insertion. The only PE component that provides interface for making those selections is the init_FTM. So okay fine I drop one into my project and configure it. Very nice. But now I don't have any methods for setting and changing the period and duty cycle which is kind of essential for smooth operation.

So I drop in a component that provides SetRatio methods like PWM or PWM_LDD and they auto-include a referenced component, a TimerUnit_LDD. Ooops. That component conflicts with the init_FTM and they can't live happily together. So I can either initialize my 6 channels, or I can control them, but I can't do both.

So maybe I can build one project with an initializer, then take the code and drop it into a second project that has the run time controls, or vice versa. But before I embark on yet another journey of a dozen red X's I'm posting this here. If anyone can save me from wasting more time on this I would be very grateful!

0 Kudos
9 Replies

605 Views
daveboyle
Contributor III

Hi, so I'm making progress. I have included my project so you can see where I'm at now. I have set up a PIT timer to issue an interrupt at 15.3khz. The interrupt handler starts an ADC conversion on channel 0 using AD1_MeasureChan(). When the conversion is finished I want to use GetChanValue8() to get the result. I only need 8 bits and I'm only using one ADC channel. My plan is to sample a 2 volt version of the AC line and store 255 samples in an array. Then the index wraps back to zero and overwrites the array with the next 255 samples. By reading out values from different parts of the array I can get the 120 degree phase shifts needed for 3-phase motor operation. By using the explicit channel versions of Measure and GetValue I hope to save time and be more efficient. I'm using BitIO components to generate signals that I can read on my oscilloscope and that works really well.

But Processor expert refuses to generate the AD1_MeasureChan() and GetChanValue8() methods that I need. Is there a setting or option that I'm missing? In the Methods tab of the property inspector I get a long list of select boxes but none of them allow me to choose which methods that PE will generate code for. As always thank you very much for your help!

0 Kudos

605 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello,

Please configure them as "generate code", then we can use it .

pastedImage_0.png

Best Regards,

Alice

------------------------------------------------------------------------------------------

If this post answers your question, please click the Correct Answer button.

-----------------------------------------------------------------------------------

If this post help your question, please click the helpful Answer button.

0 Kudos

605 Views
daveboyle
Contributor III

It seems to me that the conflict between the TimerUnit_LDD and init_FTM components must be resolved. Else people making motor controllers are going to have a difficult time. How does Freescale solve this problem in their tower systems? Is this problem specific to processor expert? Can I build custom pwm channels without pe? Maybe using the sdk or mqx?

Thank you in advance for your help!

0 Kudos

605 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hi Dave,

I think there is no need to care about why in the PE component have not the selection to change duty .

We can configure it through directly configure the related register , and please pay attention to

"40.4.10 Registers updated from write buffers" of the  " K64P144M120SF5RM.pdf "  .

BR

Alice

0 Kudos

605 Views
daveboyle
Contributor III

AHA! Yes I see it there, I don't know how I could have missed it the first time I read the 1800 page manual.

My first thought is to write this up as a macro but then I would need 6 of them so I think instead I'll create a class. Then I can have methods that effect the changes through the registers. I can even use the SetRatio8 method that I haven't been able to enable so far. Thanks very much for this help! I'll plug away at this and hopefully win.

0 Kudos

605 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hi Dave,

Congratulation !

You are welcome !

Best Regards,

Alice

------------------------------------------------------------------------------------------

If this post answers your question, please click the Correct Answer button.

-----------------------------------------------------------------------------------

If this post help your question, please click the helpful Answer button.

0 Kudos

605 Views
mjbcswitzerland
Specialist V

Hi Dave

Once the PWMs are initialised (with mode and a common base frequency for all channels of a single FlexTimer) further control is usually a write to a single register.

If you have used PE to do the configuration for you and it is doing what you want the rest should be this single register write and so I don't think that using code generation is necessary. You have more control (and probably much better speed) simply understanding the registers involved and doing the manipulation as required.

Regards

Mark

Kinetis: µTasker Kinetis support

K64: µTasker Kinetis FRDM-K64F support / µTasker Kinetis TWR-K64F120M support

PWM: http://www.utasker.com/docs/uTasker/uTaskerHWTimers.PDF

Hardware Timers: http://www.utasker.com/docs/uTasker/uTaskerHWTimers.PDF

For the complete "out-of-the-box" Kinetis experience and faster time to market

0 Kudos

605 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Dave,

If you want change the period and duty , i think you can set under the interrupt function .

And about the PE-PWM project ,you can refer to here : Tutorial: PWM with Processor Expert | MCU on Eclipse

it is the same with KDS .

After you checked this Tutorial , if it still can not solve your problem please tell me .


Have a great day,
Alice

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

605 Views
daveboyle
Contributor III

Yes I have read that tutorial many times. In the comments Erich Styger says: "what is this ‘complementary mode’?"

Right now I have 2 projects, one with an init_FTM component and the other with 6 PWM components. I looked under the Interrupt interfaces of both and don't see any way to change the period and duty cycle at run time.

Thank you for your help!

0 Kudos