cancel
Showing results for 
Search instead for 
Did you mean: 

Brusless motor with ESC's

neophytou_m
Associate II
Posted on February 21, 2013 at 16:52

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 Regards

Marios

 
7 REPLIES 7
jdp6q5
Associate II
Posted on February 22, 2013 at 00:08

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.

neophytou_m
Associate II
Posted on February 23, 2013 at 21:23

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?

Posted on February 23, 2013 at 23:13

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
neophytou_m
Associate II
Posted on February 24, 2013 at 14:15

Hi, 

If i have a code with PWM , so i can start by playing with this code, because i'm new in microcontrollers especially in C/C++. 

Posted on February 24, 2013 at 15:34

There should be PWM samples in the various ST firmware library examples.

See also

https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/PWM%20Output%20on%20STM32F2XX&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=1974

[DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Discovery/Example%20PWM%20on%20STM32-Discovery%20Blue%20LED&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F&currentviews=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=4384

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
neophytou_m
Associate II
Posted on February 24, 2013 at 15:47

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.

Posted on February 24, 2013 at 16:16

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?
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..