2013-02-21 07:52 AM
Hi to everyone,
I have a brushless motor 850Kv and one ESC's . The main aim of my task is to control my motor (forward and backward) by setting in different speeds. The microcontroller which i have is the STM32F4 discovery board.If someone can help , i will really appreciated .Best RegardsMarios2013-02-21 03:08 PM
I happen to be working on the same thing (with an almost identical motor). To get started with, you'll want to learn how to use the Output Compare Registers on the timers. Basically, these will allow you to generate a PWM signal without using the processor, so the timings will be very accurate.
Take a look at the sample code for PWM out sample code. Its not exactly what you need, but it will give you an idea of how to generate the signal you need to control the esc. For the average (cheap) brushless esc, you want to generate a pulse that is 2ms long for full throttle. A 1ms pulse corresponds to 0% throttle. Values in between will yield different throttle percentages. Basically, if you set your base frequency at 1/2ms Hz and vary the duty cycle between 0% and 100%, you will have the wave you need. The problem I am running into is that you can't send these pulses to the ESC too fast. Each pulse must have some down time between it and the next pulse. This time does not have to be very long, but my research says it should be at most 400Hz. If you're using cheap ones like me, then that number needs to be more like 150-200Hz. So basically, you are sending pulses that are 1-2ms long however fast your esc will take them. Figuring out that speed is just trial and error. I hope someone else can give some insight on how to set up the timers for this. I have mine running to where the auto reload value gives a nice 1-2ms pulse, but the timer is running at 1MHz, which is way too fast for the ESC. What we need is the timer to run somewhere around 200Hz and have the auto reload value (ARR) produce the pulses. I'm having trouble figuring out what prescalers to use on that. If I get something working, I'll post my code. I hope this helps.2013-02-23 12:23 PM
Hi my friend,
Thanks for your answer and the quick response. So if understand your problem is about the frequency, how you can reduce the frequency , right?2013-02-23 02:13 PM
Generating PWM of assort frequency is a game of setting the prescaler and period, each are 16-bit for most counters.
For a 72 MHz clock, a 72-1 prescaler will get a 1 MHz timebase, 36000-1 a 2 KHz timebase. With a 2 KHz timebase, a 2000 - 1 period will get you 1 Hz, a pulse of 1000 will get you a 50/50 duty. Motor aren't my thing so you need to be explicit about the frequency and duty you're looking for.2013-02-24 05:15 AM
2013-02-24 06:34 AM
There should be PWM samples in the various ST firmware library examples.
See also [DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Discovery/Example%20PWM%20on%20STM32-Discovery%20Blue%20LED&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F¤tviews=4384]https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2FSTM32Discovery%2FExample%20PWM%20on%20STM32-Discovery%20Blue%20LED&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F¤tviews=43842013-02-24 06:47 AM
Hi clive 1,
Thanks a lot of your quick response.About the first link , i already have it , is the project on peripherals provided from the STM32Fxx. But my question is ... the Electronic Speed Controller of the motor has only 3 wires ( black red & white) black and red are the 5 volt and ground , the remaining wire (white) is the wire which is responsible to send the pulses, the C code says about for 4 pins, i can't understand where i can connect the white wire in order to send pulses on the motor.Thanks a lot.2013-02-24 07:16 AM
I'm not a motor guy, but you're likely to need drivers capable of supplying voltages and currents at suitable levels.
May be you can find someone you work with who has more experience in the area you wish to learn?