We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi! I am a beginner in programming STM32f4 and that is my biggest problem, I think...
I am working now on the project where I need do profile the velocity of servo motor (i.e. trapezoidal velocity)... So I need to control the number of pulses I have sent and periodically update the frequency of signal...
So I have a question: Can I just change just: TIMx->ARR, PSC and CCRx registers in the PWM signal generator...? Or for example I must turn of timer first, and then update parameters...?
Thanks a lot for any hints, best regards,
P.S Have You any example projects of velocity profiling in C...? Or any tutorial of doing that on uC... Thanks again...
Ok.
I am working on the project of driver for 5-axies manipulator. I have three servo motors and two stepper motors but the steering method is clk, dir, enable.
I have to implement this on stm32f429 board using LCD-TFT. Already I have set Free RTOS system and menu to interface with the user - using STemWin Library.
To know the actual position I need to control pulses I have sent: I am managing this by 2 timers, for each motor, linked by wire: one in PWM Out Mode and the other in Input Capture Mode with External CLK on this pin. (I am turning on PWM and the Input Capture TIMx->CNT has the position via TIMx_IRQHandler() function and disables Timer PWM when the pulses were sent)
I said that this method has "quite good results" because when I only generate required amount of pulses I can be up to date with position of servo motor. I chacked this on servo driver display which represents position of encoder.
But where this method (or my code fails), is when I am trying to implement trapezoidal velocity profiling for each motor.
The derivative of position from Linear Segments with Parabolic Blends gave me velocity (deg/sec), which I recalculate to frequencies. (I choose to have 10% higher velocity in linear segment + two parabolic segments of: 5% * movment_time duration, each)
1) The range of frequencies I work with is: form 1 Hz to 200kHz/300kHz. But It have to work don't need to work fast so I can manipulate higher value... And update frequency using Timer 7 each 0.0021845 sec The biggest problem for me are the stepper motors: max frequency of 1.8kHz and the smalest resolution (the biggest position error)... So i.e. when I want to have 35% of max speed, the stepper motors have 630Hz. The deriviative gave me values: docs.google.com/.../edit
So the values of velocity are good, but when I turn on PWM of stepper motor, the first period is very long - 20 Hz even about 22 new updates of TIMx ARR,PSC,CCRx register values. After this first period, frequency in changing properly to the end of movment Time (measured by Tim7)... But there wasn't generated enough "falling edges" and my counter has counted every generated pulse but there was them too few. Because of this first not updated period of pulse I think.
So my question was why the 22 updates of ARR, PSC and CCRx values has no effect on output signal during first 20 Hz period...?
2) Duty cycle of PWM I just set to 50% to be sure that my servo driver detects every pulse sent.
3) I think that could be PWM first period problem... But I am not sure because I have a little experience with uC's... I've read in RM about shadow registers and don't really understand if I updated the regisrer values to shadow or active register...
If You have other questions, I will answer as good as I can...
Best regards,
Marcin