DIY BLDC ESC for step control - RC Groups
Thread Tools
Jan 27, 2009, 03:52 PM
Registered User

DIY BLDC ESC for step control

Hi all
I am wanting to design a system that will use BLDC motors with step control. I have some ideas about programming but I mainly do web stuff like PHP so this is a bit over my head, anyway i've put together some semi-ish-pseudo code and tried to basic/C it up a bit.

The gist is I need step control so forwards and backwards, I also need amount of steps, possibly rpm and a 'go' signal for synchronization purposes. I'm guessing it will be best with a sensored motor but because they don't seem very abundant these days probably sensorless with DIY hall sensors.
if end0 = 0                                (end sensor)
insert code rotate backwards        (return to zero)
goto main
end if
goto signal}

if instructions exist goto move
do while signal = 0
wait for signal                           (waits for signal from PC)
end while
goto readsignal}

if signal begins with xxxx        (so that multiple controllers can be used)
read instructions into memory (direction, rpm, wait, distance)
check signal integrity
	if signal integrity is good then         (simple check)
	goto communicate(ok)
	communicate(signal error)
if not
goto signal
end if}

communicate(x as reply){
select case x = ok
signal PC ok
goto move

select case signal error
signal PC signal error
purge instructions
goto signal

select case finished
signal PC finished
purge instructions
goto signal

select case end0
signal PC end0 + distance
purge instructions
goto signal

select case end1
signal PC end1 + distance
purge instructions
goto signal}

if (distance > 0){                (use distance variable todo step control)
if (wait = 1){
wait for go signal from pc
if (direction = forwards){
distance -= 1
insert actual forwards moving code   (1 step not complete rotation)
	if (end1 = 1){                        (check end sensor)
	goto communicate(end1)}
distance -= 1
insert actual backwards moving code  (1 step not complete rotation)
	if (end0 = 1){                         (check end sensor)
	goto communicate(end0)}
goto communicate(finished)
I know it's messy and horrible but I tried. I'd be glad of any input anyone could give me

Thanks Adam
Last edited by Rufe0; Jan 28, 2009 at 12:12 PM.
Sign up now
to remove ads between posts
Jan 27, 2009, 04:01 PM
Have you considered using a stepper motor - which as its name implies, is designed to do what you want to do.
Jan 27, 2009, 05:24 PM
Registered User
quax's Avatar
Hi Adam,

what programming language is that? It's really new to me

Jan 28, 2009, 02:03 AM
Registered User
Yeah kinda my whole point in the project is to show that brushless motors could be used and would be just as good.

And yeah I'm sorry it went all wrong. It's meant to be pseudo code so anyone can understand it but it just made it even harder to read
Jan 29, 2009, 11:43 PM
Registered User
You will need more than the hall sensors for positioning. You wil need an encoder of some sort preferably a high resolution optical. Just a closed loop brushless servo!!!!!!!!

With just the hall's you will only be able to sense potision to the resolution of the # of poles. Its not likely to be done on typical hobby style brushless motors anyway, at least not with much step resolution.

BTW, you wont be proving anything, this has been done already and has been used for years in certain industry. Its just not used for applications that need holding torque such as a stepper or normal DC servo may be used, their designs just dont really allow it.

Keling sells motors and controllers pretty darn cheap.

Also, a stepper is pretty much exactly what you are trying to do anyway.

Steppers are brushless DC motors, just with many many more teeth/poles than typical "brushless DC" motors. However, they are indeed essentially the same thing. Steppers are designed for holding torque, and brushless DC for speed/ running torque.

Stepper have the benefit of not needing positional feedback in many application as they only rotate a known amount per step.

If you need such a motor/controller for something I suggest just using a stepper, it will keep you from banging your head trying to re-invent the wheel and are pretty cheap and can be extremely precise.
Jan 30, 2009, 05:37 AM
Registered User
Well actually I was planning on useing a 12pole connected to a 12:1 worm gear which would give me 144 steps or 2.5degree which is as acturate as steppers and is 10times more acurate than the device needs to be anyway
Jan 30, 2009, 05:58 AM
Registered User
earlwb's Avatar
There are two main types of stepper motors, bipolar and unipolar, they use different methods as to being driven.
Since you are wanting to use PHP that means you are using a PC. I have never heard of someone using PHP for this, PHP is a website webpage kind of programming language. But maybe that is a first. I don't remember anyone doing it yet.

Here is how to drive a small stepper motor via the parallel port:
Note the webpage uses PHP but they show how to get a Visual Basic .Net example for driving it. You would need to figure out how to get PHP to send bytes to the parallel port. I don't know if you can though. But maybe using printer commands would be possible.

This is about the simplest way here, it uses the parallel port on your PC.
But if your PC doesn't have a parallel port, then that is a problem.

The other method is to use a stepper motor driver like this here:
You can modify the kit to be driven by a PC i/o port of some type as desired.
The motorola stepper motor driver IC is pretty neat, one can hook up more powerful driver transistors on the outputs for larger stepper motors too. There are a whole slew of different stepper motor driver IC's out there. They use these chips in all sorts of things.

A PIC stepper motor controller kit with tutorial is available:
Most microprocessor companies have a similar kit or examples for driving a stepper as well.

Here are some more kits here:
They have a Visial Basic example driver program for one of the kits too.

This is a way to drive old hard drive disk motors from a PC:

Here is another example of of a stepper motor controller circuit kit:
Jan 30, 2009, 09:40 AM
Originally Posted by Rufe0
Well actually I was planning on useing a 12pole connected to a 12:1 worm gear which would give me 144 steps or 2.5degree which is as acturate as steppers and is 10times more acurate than the device needs to be anyway
While this may give similar resolution (NOT accuracy) to a typical 1.8 degree/step stepper motor, you won't get anywhere near the same accuracy when you take into consideration things like the backlash of the worm drive.

If you only need about 15 steps/rev, get one of these tiny (0.78 dia. x 0.56in.) $1.50 unipolar steppers (20 steps/rev) to play with. Driving a stepper is much simpler/cheaper than a brushless/hall combo.
Jan 30, 2009, 10:32 AM
Registered User
Very usefull earlwb thankyou

rmteo this motor will be a few watts maximum, what if you want a few hundred watts, stepper motors become very expensive
Jan 30, 2009, 10:43 AM
What torque rating do you need? More data on your application is needed to determine the most appropriate solution.
Jan 30, 2009, 12:16 PM
Registered User
Well lets say one possible combination I am looking into is 150.64oz-in at 1250 rpm
Jan 30, 2009, 12:31 PM
In your previous post you indicated that you requirement is about 15 steps/rev, so are you saying that you want to be able to do 18,750 discrete steps per second (15x1250)?
Jan 30, 2009, 12:37 PM
Originally Posted by Rufe0
Well actually I was planning on useing a 12pole connected to a 12:1 worm gear which would give me 144 steps or 2.5degree which is as acturate as steppers
As mentioned before 1.8 degrees/step is a common resolution for the stepper motors themselves, but half stepping is quite easy to do giving you twice the resolution. In fact most stepper controllers provide for even smaller microsteps - I believe the ones on my CNC machine are 10 microstep...

A 150 oz*in stepper shouldn't be too much money - but I don't know about getting that torque at 1250 rpm.
Jan 30, 2009, 01:03 PM
Registered User
rmteo the BLDC I mentioned is a 12 pole and would run at 15000rpm which would be 180,000 steps/min 3000steps/sec
Last edited by Rufe0; Jan 30, 2009 at 01:09 PM.
Jan 30, 2009, 01:16 PM
Registered User
earlwb's Avatar
Well, the real stepper motors do not run at 15,000 RPM.
A Nema34 motor turns around 100-200 rpm, but if you overload it severely, maybe 1500 rpm before it overheats.
Some small motors do quite well at 50 rpm using 1/2 step mode at 5v for example.

if you are wanting 15,000 rpm you are talking about a seriously good quality brushless RC airplane or heli motor. The little itty bitty brushless motors only turn around 7,000 to 8,000 rpm.
What specific brushless motor were you wanting to use?
You said it had 12 poles, and other information about it? Make model etc.

Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Which CPU is better for self developing ESC for BLDC chancehuang Power Systems 5 Nov 02, 2005 11:12 AM
ESC for Soarstar/Poppy sgil2001 Beginner Training Area (Aircraft-Electric) 1 Jul 04, 2001 09:31 PM
Which ESC for 2 480s? Mrstacy Electric Plane Talk 1 May 28, 2001 01:45 AM
MX-80 esc for twin HP 200/25/4 marshall Electric Ducted Fan Jet Talk 3 May 24, 2001 06:16 PM