3 phase brushless motor controller

Hi,
I'm trying to make a three phase motor controller. I have managed to use the timers (3,4,5) on the Mega board to provide 3 different PWM signals and their inverse at various duty cycles and frequencies using the pwm function from the timer library (arduino.cc/timer1) found online. The only problem is I am not able to get these three signals (one for each timer) to be out of phase with one another, and the delay function will not work for this, I have a feeling that the delay function (which uses timer0) does not interrupt other timer outputs, so my analog output signals from the other timers just keep coming. I am not very fluent with embedded programing so if somebody could write the code to cause the analogWrite function to create signals out of phase with eachother that would be amazing! Any help would be appreciated though, I am pretty tight for time and would greatly appreciate any insight.

Or you could just buy an ESC on Ebay for $5 free shipping.

sbright33:
Or you could just buy an ESC on Ebay for $5 free shipping.

I agree, common sense should be a part of the buy or build decision. If one is set on designing building their own ESC around an AVR chip, Atmel has several different application notes available for that application that might give one a feel for the effort required.

Lefty

There are a lot of different brushless motors, if you google it you will find a lot of examples like Brushless DC (BLDC) motor with Arduino – Part 2. Circuit and Software - Electronics Blog
If it is possible I'd use a separate driver

Say your three output signals are Out1, Out2 and Out3
Generate another pair of PWM signals (call them Out4 and Out5) running at the same frequency as your 3 phase output and synchronised to the starting time of Out1
Set Out4 at a fixed duty cycle of 33.3% and Out5 at a fixed duty cycle of 66.6%
Now take Out4 and Out5 and use them as a new pair of inputs, In4 and In5
Look at the trailing edges of In4 and in5 and use these trailing edges to trigger the start points of Out2 and Out3 so generating the required phase lags on these pair of outputs.

OK I don't know much about programming but hopefully the above is a method.

jkfromme:
I am pretty tight for time and would greatly appreciate any insight.

I don't care how tight time is. Don't cross-post please. It just gets everyone upset. Your other thread deleted.

Thanks, everyone, sorry about the double post I didn't know it wasn't aloud. So jack that would be a good idea except once your start analog write functions even if you starts them later than each other, they find a way of synchronizing themselves =( , but I think I can use the outputs as inputs and delay the reoutput of it not using a an analog write but as a digital output, then it might work. And I have no other option but to use an arduino due to the restrictions of the project at the moment so the ESC is a good idea but it wouldn't work.

So this is like a puzzle where your professor wants you to do it the hard way? You're not allowed to choose the best solution? They have overnight shipping for ESC's. It may turn out to be a very difficult project with those limitations if you want it to run at full speed.

Buy an ESC, fit it into a little box with lots of open ended wires coming through the side of the box, fill the box with opaque potting compound. Use the arduino to provide a speed control signal to the ESC. Tie the open ended wires to as many spare I/O terminals on your arduino as you can and call the box a signal conditioner, with a 'secret' piece of eprom software built in.
QED, motor control "using" an arduino.
:smiley: :smiley: :smiley: :smiley:

That's what I would do, but instead of using potting compound I would just make it difficult to identify by adding more parts around it.

Could you explain more what a ESC does, will it work with a brushless three phase DC motor (BLDC) to control both speed and torque by providing 3 phase power?

That's exactly what they are designed for. Google ESC speed controller or any such key words and you'll get more information than you care for. As an example here's one link within which you get info on both motor design and a link to ESCs Brushless DC electric motor - Wikipedia

jkfromme:
Hi,
I'm trying to make a three phase motor controller. I have managed to use the timers (3,4,5) on the Mega board to provide 3 different PWM signals and their inverse at various duty cycles and frequencies using the pwm function from the timer library (arduino.cc/timer1) found online. The only problem is I am not able to get these three signals (one for each timer) to be out of phase with one another, and the delay function will not work for this, I have a feeling that the delay function (which uses timer0) does not interrupt other timer outputs, so my analog output signals from the other timers just keep coming. I am not very fluent with embedded programing so if somebody could write the code to cause the analogWrite function to create signals out of phase with eachother that would be amazing! Any help would be appreciated though, I am pretty tight for time and would greatly appreciate any insight.

Trying to make a three phase controller is quite a generic statement!, firstly what modulation strategy will you use i.e what kind of drive are you trying to make there is quite a few ranging from difficult to crazy!

Arduinos are not really suited to high level tasks such as motor control not least because of their computational limitations, motor drives really need a DSP chip

Getting a PWM output is one thing but making PWM modulate a sine wave is quite another and being tight for time just makes it all even harder as it will take a considerable effort, the programming is tough enough but building the hardware is also quite a challenge as motor drives use all kinds of different topics all merged into one

I wouldn't try and make six outputs with three being complementary as you need dead time between complementary outputs so go for a HVIC gate drive chip which has built in dead time so you only need three signals to drive 6 IGBT/MOSFET and dead time takes care of itself

an IR21834 is a good driver chip, when I built an Arduino motor drive the lack of resources meant I had to use three arduinos and sync them together and even then I had to do a lot to speed things up like Maclaurin series to approximate inverse sine etc

Even after lots of heartache the output wasnt that good, basically building a motor drive isnt something that can be done fast unless you know exactly what you are doing and even then its always quite hard!

This project is more like an experiment, as to see what should be done in hardware and what should be done in software, the intent is for me to somehow make this possible just with the arduino.

We do have a ICR in the hardware but it tends to work well sometimes and other times not so well.

What I am most interested in is how you managed to syncronize the three arduinos?

Also someone online had an idea to make a sin wave using an array of duty cycles of equal spacing for ex
[255 2557/8, 2556/8 .... 0 .... 255] I might try that out.

jkfromme:
This project is more like an experiment, as to see what should be done in hardware and what should be done in software, the intent is for me to somehow make this possible just with the arduino.

We do have a ICR in the hardware but it tends to work well sometimes and other times not so well.

What I am most interested in is how you managed to syncronize the three arduinos?

Also someone online had an idea to make a sin wave using an array of duty cycles of equal spacing for ex
[255 2557/8, 2556/8 .... 0 .... 255] I might try that out.

Isn't it obvious what is done in hardware and what is done in software though?, the hardware is basically six IGBT's with gate drive circuitry and a current measurement stage

The software does all the work measuring and calculating the switching times etc

To synchronise three Arduinos I simply used a digital pin and wrote it high when ready, the other arduino reads the state of the pin and waits in a for loop until it detects the signal very simple

if I were you I would build a low voltage prototype to get familiar with the concepts and just drive a dummy RL load

I have blown quite a few drives up through inexperience and not using techniques like laminar bus planes to combat stray inductance so if you want to build a mains voltage prototype you need to make your own double sided PCB and be smart in the layout I would concentrate on getting the circuit and software working without having to worry about the formalities

Heres a thread on the Arduino low voltage drive

Heres my project upgraded to a 32 bit controller, its getting better all the time

http://arduino.cc/forum/index.php/topic,106477.0.html

The jump to mains voltage is the most difficult jump of all

Good luck with what ever you choose

I recently tried to make a similar controller ( http://arduino.cc/forum/index.php/topic,120703.0.html ). It worked, but was really not optimal since it was a 6 pulse system rather than a PWM one. If I was going to do something for a practical application I would buy a cheap ESC just like a few other people on this thread said.

If you want to learn more about how the devices work, rather than just run a large motor as simply as possible, I suggest reading this article and trying to construct a similar circuit: http://digitalcommons.calpoly.edu/cgi/viewcontent.cgi?article=1129&context=eesp he gave a really nice writeup for how to build one using an Arduino. If I try to build a new inverter I will try to copy his design.