K22F ramp up frequency slope with FTM

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

K22F ramp up frequency slope with FTM

Jump to solution
899 Views
kent_gu
Contributor III

hi,

hi,

I am using MK22FN1M0AVLH12, want to create one ramp up frequency slop with FTM as attached picture, its profile is start frequency is1k, end frequency is 8k; step frequency is 200HZ;send out 20 pluse at every frequency step. My goal is that create ramp up frequency slope wave to drivestep motor. My question is that:

Frequency_Slope_.jpg

#1, If can use FTM to realize the ramp up frequency wave as attached picture?

#2, When switch 2 frequency, FTM ouput will stop for a little? Because I am not sure if need to wait a little time after FTM timer settting? Or just when last plus send out at one special frequency, and new set FTM timing set in FTM interrupt ISR, and mcu send out the new special frequency wave after the FTM interrupt ISR?

#3, Do you have the FW about step motor ramp up frequency slope as attached file to share?

Best Regards,

Kent

Tags (2)
0 Kudos
1 Solution
619 Views
xiangjunrong
Contributor IV

Hi, Kent,

Regarding your question, let me answer it one by one.

#1, If can use FTM to realize the ramp up frequency wave as attached picture?

>>>First of all, the FTM can  implement the ramp up frequency as attached picture. FTM can generate PWM signal with 50% duty cycle. You can enable the FTM Timer Overflow Interrupt by setting "Timer Overflow Interrupt Enable" bit in the FTMx_SC register. in the ISR, you can declare a static or global variable to count the pulse  times, when it reach up to the predefined times for example 5, you can change the PWM frequency by decreasing the FTMx_MOD register value and corresponding FTMx_CnV register value, then write the FTMx_PWMLOAD to make the change valid.

Regarding the code, I think you can refer to an5142, which describes how to generate PWM signal, how to change the PWM parameter in the ISR, and it has the code.

http://tinyurl.com/zzbppws

#2, When switch 2 frequency, FTM ouput will stop for a little? Because I am not sure if need to wait a little time after FTM timer settting? Or just when last plus send out at one special frequency, and new set FTM timing set in FTM interrupt ISR, and mcu send out the new special frequency wave after the FTM interrupt ISR?

>>>>>>when switch 2 frequency, the FTM continue to work, you do not need wait for a little time, because the core execute instructions very quickly and the PWM signal is slow.

#3, Do you have the FW about step motor ramp up frequency slope as attached file to share?

>>>>>Unfortunately, we have not the code to implement the scheme for stepper motor, as you know, the stepper motor control signal is dependent on the layout of power stage board, controlling method you required.

Hope it can help you.

BR

Xiangjun rong

View solution in original post

0 Kudos
2 Replies
619 Views
mjbcswitzerland
Specialist V

Hi

For best performance you can use a fixed curve in memory representing the ramp as a sequence of frequency values. Using a base timer (such as PIT) you can then transfer the frequency values to the FTM via DMA so that you have a single interrupt at the end of the ramp, confirming that it has completed.

See http://www.utasker.com/docs/uTasker/uTaskerADC.pdf for general details of generating such waveforms (example in chapter 4 for DAC output and modification for PWM/FTM output in appendix A-c).

Since the FTM's HW controls the changes of the frequencies (using an intermediate buffer to change only on complete cycles) there are no gitches etc.

Regards

Mark

0 Kudos
620 Views
xiangjunrong
Contributor IV

Hi, Kent,

Regarding your question, let me answer it one by one.

#1, If can use FTM to realize the ramp up frequency wave as attached picture?

>>>First of all, the FTM can  implement the ramp up frequency as attached picture. FTM can generate PWM signal with 50% duty cycle. You can enable the FTM Timer Overflow Interrupt by setting "Timer Overflow Interrupt Enable" bit in the FTMx_SC register. in the ISR, you can declare a static or global variable to count the pulse  times, when it reach up to the predefined times for example 5, you can change the PWM frequency by decreasing the FTMx_MOD register value and corresponding FTMx_CnV register value, then write the FTMx_PWMLOAD to make the change valid.

Regarding the code, I think you can refer to an5142, which describes how to generate PWM signal, how to change the PWM parameter in the ISR, and it has the code.

http://tinyurl.com/zzbppws

#2, When switch 2 frequency, FTM ouput will stop for a little? Because I am not sure if need to wait a little time after FTM timer settting? Or just when last plus send out at one special frequency, and new set FTM timing set in FTM interrupt ISR, and mcu send out the new special frequency wave after the FTM interrupt ISR?

>>>>>>when switch 2 frequency, the FTM continue to work, you do not need wait for a little time, because the core execute instructions very quickly and the PWM signal is slow.

#3, Do you have the FW about step motor ramp up frequency slope as attached file to share?

>>>>>Unfortunately, we have not the code to implement the scheme for stepper motor, as you know, the stepper motor control signal is dependent on the layout of power stage board, controlling method you required.

Hope it can help you.

BR

Xiangjun rong

0 Kudos