Pages: [1]   Go Down
Author Topic: Is arduino fast enough to handle brushless motors commutation?!  (Read 1506 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 31
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi guys!
I`m making a BLDC motor controller and I am thinking about using Arduino to control it.
It` s very simple, depending on the digital input from 3+1 sensor it has to properly control 6 mosfets. (reads the gas potentiometer once in a while and then applies a pwm signal to 6 mosfets, depending on the readings of 3 hall sensors. Very simple process, based on a Boolean logic that relates hall imputs to phase commutations.)

The question is: Is arduino fast enough for that?!
The motor will be spinning at max 5000 rpm, wich is about 85 rpSecond.
Each mecahnical  rotation is made of 4 electrical rotation, and each rotation is made of 6 state changes. (each state change is the change of TWO pwm output status)

So, 24 commutations * 85 revolutions is 2040 operations per second. Is Arduino with its 16000000 Hertz able to handle that?

A quick math says it has something like 7500 clock cycles for each commutation, but in order not to loose sync the delay of each commutation should not be over let`s say 3%... 
That means not over 250 clock cycle to read 3 digital sensor status, perform a supereasy boolean thing and set two pwm write. Can Arduino handle that?

Thankyou so much!  smiley-kitty
Logged

0
Offline Offline
Shannon Member
****
Karma: 200
Posts: 11718
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, shouldn't be a problem.   You will however, I think, need to up the PWM frequency to higher than the commutation speed to get reasonable behaviour.  The default timer settings are about 1000Hz on timer0, 500Hz on timers 1 and 2.  Each timer controls two PWM pins - timer0 also maintains the millis() clock.  Timers have a prescaler that divides the system clock.  This can be set to divide by one, giving a maximum PWM frequency in 8 bit fast mode of  62.5kHz - plenty I think.

If you want to use all 6 pwm pins then that means you may have to give up on millis() being at all accurate - and learn how to directly set the timer prescaler settings.

[ If you want less delay in the system you can use direct access rather than digitalRead() and analagWrite() - at the expense of clarity.  It is possible to read a digital pin or set a PWM output value in a couple of cycles.... I think that  digitalRead and analogWrite are probably fast enough ]
Logged

[ I won't respond to messages, use the forum please ]

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 124
Posts: 6653
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Many of the "homebrew" Brushless motor controllers used in the RC hobby area use an ATmega8 CPU, which is the same CPU  used on the original Arduino (the newer CPUs are essentially the same speed, but have more program memory.)
http://www.radetzki.info/html/sbl_micro_e.html is an example.
(many commercial controllers use the same CPU, and there are assorted instructions out there for reprogramming some of the inexpensive imported ESCs with alternative software.)
Logged

0
Offline Offline
Shannon Member
****
Karma: 200
Posts: 11718
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

And don't underestimate the important of monitoring current to such a low-resistance motor - overdrive it and it will take all the current you can throw at it till something melts...  RC brushless motors are typically 0.1 ohms or so winding resistance.
Logged

[ I won't respond to messages, use the forum please ]

0
Offline Offline
Full Member
***
Karma: 0
Posts: 112
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Why not use this?

http://www.nxp.com/documents/data_sheet/TDA5140A.pdf

Works for me...
Logged

No trees were harmed by the transmission of this message. However a few million electrons were temporarily inconvenienced.

Portugal
Offline Offline
God Member
*****
Karma: 6
Posts: 962
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The C compiler might not be able to create code that fits in the 250 cycle space, because all the ESC's that have open source code are coded in assembly, also almost all ESC's use atmega8's as said and running at only 8Mhz using the internal oscillator, so 16Mhz is a lot more time.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 31
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What about connecting the arduino pwms to the mosfet? I was thinking of useing a "pre-amp" stages made with transistor in order to keep the arduino away from the mosfets` gate saturation current (very high on 400A mosfets) and make a quicker switch. Am I on the right path?


In order to pick the right components i`ll refer to some datasheets and guides from national rectifiers and others.

I have some "ideal assembly" knowledge (part of a college exam), reading datasheets etc i may be able to write the code/part of it in assembler.
If needed i`ll get into it and, eventually, ask for help on the forum if i won't manage to figure it out myself

Logged

0
Offline Offline
Shannon Member
****
Karma: 200
Posts: 11718
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Typically a specialised driver chip(s) is needed - both to handle the high currents, boost the gate voltage to 10--12V and drive a charge pump to provide gate voltage for high-side n-channel MOSFETs.  IIRC one 3-phase driver chip is the HIP4086.

Be aware that high current MOSFET circuits are totally unforgiving of error - always limit the current during testing and development till you are sure all is well.  If you don't something will melt or explode.  Start with 100mA load, then 1A, then 5A, checking all the time for unexpected behaviour or overheating.

This is not an easy project.
Logged

[ I won't respond to messages, use the forum please ]

Portugal
Offline Offline
God Member
*****
Karma: 6
Posts: 962
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Some handy links:
http://www.rcgroups.com/forums/showthread.php?t=1384442
http://www.rcgroups.com/forums/showthread.php?t=1378680
http://www.rcgroups.com/forums/showthread.php?t=766589

The first two links have zip files and pdf files, they have both schematics and source code, there is also a fully designed i2c controled ESC based in a pic30f ou 33 dont remember correctly.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 31
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

tnks guys smiley
Tnks for the link also, they refer to great technical works but are pretty different from my goal, I want to make a sensored controller to use on a ebike. I used to run it on a sensorless rc controller, it worked great but with the (big) limit that I had to run it at about 10mph before the back emf was strong enough to make a sensorless controller work.

Is there any ic that can help me connecting a logic pin (arduino output) to the mosfet gate?
 I think I could solve this issue using logic level gate mosfets, but seems I`m wrong  smiley-sad
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 112
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Did you look at the data-sheet I posted?

Pin 1, 3 and 16 run the 3 phase and pin 17 does the sensing. Pin 4 can be used to control the outputs, Check Page 11.

Logged

No trees were harmed by the transmission of this message. However a few million electrons were temporarily inconvenienced.

Offline Offline
Newbie
*
Karma: 0
Posts: 31
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yep I checked the datasheet and it`s for sensorless commutations, if fact it says something like "you`ll save 3 hall sensors with this lol".

I can already read the sensors and control some outputs on Ardu (in my automation engineering class in Italy we sometimes refer to it as God Ardu, who watches you  smiley-lol), my "only issues" were about speed of the whole system, seems there is enough, and how to connect the Ardu`s output to the mosfets.

I am reading http://focus.ti.com/lit/ml/slup169/slup169.pdf wich is great theory explanation about mosfets.
Still, i don`t understant why logic level gate mosfets arent the right solution to "make it easy.. this is the datasheet of those i was looking at... http://www.irf.com/product-info/datasheets/data/irls3036-7ppbf.pdf
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 112
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You will need to enlighten me because I'm lost here.

What is Pin 17 for? I have done both the sensing EMF from all 3 phases with a 10k resistor and also using the 4'th connector on the brushless DC motor on which cases it both uses sensing to decide the next step against it's internal EMF comparators. How is this none sensing?
Logged

No trees were harmed by the transmission of this message. However a few million electrons were temporarily inconvenienced.

Offline Offline
Newbie
*
Karma: 0
Posts: 31
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don`t know, anyway looking with the search function in the datasheet I want able to find the word sensor without the word less near to it.
Of course, I may be wrong (and prabably I am!), but I am not really interested in understanding how that ic works, since my main point right now is to understand the principles of how to drive high power mosfets from Ardu and how to choose the mosfets (i can say that the thing about logic level gates in my last post is the main point for me right now). Anyway, thankyou for posting me that datasheet! :-)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 31
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


I can already read the sensors and control some outputs on Ardu (in my automation engineering class in Italy we sometimes refer to it as God Ardu, who watches you  smiley-lol), my "only issues" were about speed of the whole system, seems there is enough, and how to connect the Ardu`s output to the mosfets.

I am reading http://focus.ti.com/lit/ml/slup169/slup169.pdf wich is great theory explanation about mosfets.
Still, i don`t understant why logic level gate mosfets arent the right solution to "make it easy.. this is the datasheet of those i was looking at... http://www.irf.com/product-info/datasheets/data/irls3036-7ppbf.pdf

Help please  smiley-lol
Logged

Pages: [1]   Go Up
Jump to: