cancel
Showing results for 
Search instead for 
Did you mean: 

To develop Command for Servo MOTOR (motion control)

euphoria
Associate II
Posted on July 29, 2016 at 17:13

Hi,

I am new in STM32.

I want to develop controller with 2 independent pulse train or specific amount of pulse output with 50% fixed duty cycle. In project i want all the command to be added which in dspin project same type command to develop.

command like :-

MOVE, ACCEL, DECEL, SPEED. POSITION, MARK, MARK POSITION same all as in dspin.

Need help in PWM control, like want to send 2K pulse and then PWM to stop.

Min pulse 1 Hz to Max pulse 1 Mhz.

Kindly guide me, i any one is having any reference code.

I am using STM32F discovery board.

Thanks and Regards,

Pankaj
5 REPLIES 5
slimen
Senior
Posted on July 29, 2016 at 17:25

Hi,

Could you precise which Firmware are you using ?

I recommend  you start with PWMOutput example within your firmware package (STM32CubeXX)

As example, this application in 

http://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32cube-embedded-software/stm32cubef4.html

 package:

STM32Cube_FW_F4_V1.12.0\Projects\STM32F412G-Discovery\Examples\TIM\TIM_PWMOutput

Regards

euphoria
Associate II
Posted on July 29, 2016 at 17:33

Hi,

Thanks for reply.

But i have already did the work with PWM using STM32F3 examples, and able to generate PWM from 1 Khz to 1 Mhz.

But want to have control on PWM, should stop after certain pulse to send. And make command as are in dspin, mentioned above.

Regards,

Pankaj

Posted on July 29, 2016 at 18:51

You are likely to have to develop your own code.

For longer pulse trains I tend to prefer the Advanced Timers, and use the Repetition Counter (8-bit). PWM output can be turned off by setting the CCRx pulse width to zero. So you'd want to count off Update interrupts, decimate with the Repetition Counter, and then turn off the output when the desired number of pulses have occured.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
euphoria
Associate II
Posted on July 30, 2016 at 16:02

Hi,

Thanks for reply.

I have understood the point, but problem is i am totally new to STM32. If you or anyone else can guide me more on it, with come example code, will be more helpfull.

Regards,

Pankaj

Posted on July 31, 2016 at 02:44

The DSP/SPL library, and STM32F3-DISCO library, both have examples of TIM PWM and TIM IRQ, you will need to review those and experiment. Specifically modulating the pulse width, or period, and counting cycles (updates). For speed control, you'd presumably want to define an envelope where it accelerates, holds, decelerates, etc. at rates and speeds desired.

I know I've posted dozens of useable examples here, use Google/Bing, and review those too.

There are some examples of using PWM with the repetition counter, and triggering with other timers.

[DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Stop%20PWM%20output%20after%20N%20steps&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=3937]https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2Fcortex_mx_stm32%2FStop%20PWM%20output%20after%20N%20steps&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B¤tviews=3937

All these should be view with respect to the timer documentation in the reference manual.

The processor is not going to be able to interrupt at MHz rates, so methods you choose need to decimate the loading, and do as much as possible in the hardware domain.

There is only so much guiding I'm willing to do, you'd need to carry some of your own weight when it comes to implementing your own code.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..