DIY Brushless Speed Control - Page 7 - RC Groups
Thread Tools
Jan 27, 2004, 05:20 AM
Impossible? Hah!
KreAture's Avatar
Yes. The more I run the numbers I am sure I can get a cheap and simple controller working with a simpler solution.

If effichiency isn't the main goal, just a controller for use with the cd-rom motors, then I think I can lower my demands a lot.

For good thrust for a slowflyer / indoor 8000 rpm is a lot. If we select 10000 rpm as our max, and focus on a 12-magnet cdrom motor we would have 10000/60*4*6 = 4000 commutations pr second. This is not that much. I like the PIC controllers because of their simple nature and commandset, but they do run at 1/4 the applied clock. Even at 4 MHz/4 = 1MIPS we wtill have 250 instructions pr commutation.

By using external amps and logic to make the 0-crossing a simple pin-change event and always use 0-deg (or close to) for lead-angle, it should be quite easy making a controller using only 2 main IC's: A PIC, and a 3-phase H-bridge driver. I think Motorola has made a lot of the latter chip. This would simplify the design and especially shrink the circuitboard a lot.

I want to first design a controller that will let me utilize all those cd-rom motors I have. If I get 88% or 60% effichiency, I still get better eff than a brushed setup, and the main thing is removing the wear that we find in brushed motors.

I will try and put together a software fast to test some ideas I have as to simplifying the 0-crossing logic. If it pans out I'll see if I can set some sort of record in DIY ESC-design LOL... Wish me luck. I think I'll need it.
Sign up now
to remove ads between posts
Jan 27, 2004, 06:18 AM
Registered User
mmormota's Avatar

Have you seen Takao's new design? It is fairly simple, just a controller and a discrete H bridge. The controller is an AVR, it is faster then a PIC on a given clock speed.

If you like PICs, and need more speed, there are faster PIC members, or there is the code compatible 50 MIPS Ubicomm clone. I think the more the speed the easyer the job, and the price is not too much. Probably better to start with a fast controller, and finally lower the clock if possible.

I think that more or less easy to write a code to just run a motor, but hard to start different motors reliably, and keep good efficiency with different motors. Worth to take a look to the oscillograms of commercial controllers in startup and at different throttle and load conditions. The more similar the new code the safer the success... :-)
Jan 27, 2004, 06:39 AM
Impossible? Hah!
KreAture's Avatar
The reason I want to use a PIC is because I have many years of experience with them and they are the only ones I can get cheap. (and free as samples!) And, about speed... You really want it to go as slow as possible to avoid unnecessary current-drain. Also, noise is an issue. A 50 MHz will be very prone to noise. A 8 MHz PIC will also use less current than a 2 MHz AVR.

The main reason to use a PIC is that I have it right here. No need to get a new chip or programmer...

I do have a MGM controller and a MiniAC 1215/16. I also have a 100 MHz 4-channel scope. This should make it fairly easy to find out how to do the 0-crossing. (I know it was a great help on my 35 MHz FM receiver.)
Jan 27, 2004, 08:08 AM
Registered User
Mr DIY's Avatar
KreAture ..

The current drain of a PIC running at say 50MHz is still nothing to what the motor would be consuming. So that’s almost a non issue. I am not sure why current consumption is an issue at all. If you would care to elaborate on that, maybe we could understand your problem.

At work we have reps come in all the time keeping us up to date on Microchip, Atmel, Motorola ect. From what I can remember, PICs are good for high speed. Avr in my opinion are simply nicer, though not nearly as fast. Since moving away from PICs, I have no need to go to back to them.

Noise issues. The Atmel Mega8 device has noise reducing features that could be used. Personally I have had no need for them thus far at all, but then PCB layout should take care of most noise issues and I am only running the Mega 8 at 8MHz and at 3.3Vdc. At work I am very much involved with EMC issues and have learned how to layout correctly to minimize noise as well.

Micro Choice. Compilers for the AVR range is free … even the ‘C’ compiler. If you can write C- Builder or Delphi, you could even write you own programmer, and will be the cheapest method to get going. An ISP programmer from Atmel though, is dirt cheap (less than $30 when I purchased one) and well worth the money. But hey …the choice of micro is yours. If you want to stick by Microchip, go for it. The best policy is to stick with what you know best when tackling a project like this. Just make sure that the micro has the capabilities required. PS: Which one do you wish to use?

Mmormoto said :
I think that more or less easy to write a code to just run a motor, but hard to start different motors reliably, and keep good efficiency with different motors.
Agreed 100%. That’s were all the real software intelligence lies.
Jan 27, 2004, 08:22 AM
Birds do it, bees do it
ParkJeff's Avatar
Just out of curiosity are you guys thinking of doing the commutation by polling or using interrupt driven routines? It seems to me that using interrupts together with comparator based zero crossing detection might be an efficient way of doing it. The mcu would of course need to have the required number of interrupts.

Your thoughts?

Jan 27, 2004, 08:32 AM
Impossible? Hah!
KreAture's Avatar
It's mostly the fact that I know the PICs by hart that make me want to use them. I agree that the AVRs are lovely. I have done some AVR projects too, using the free suite and even used most of the advanced features of the AVRs such as interrupts with masking and AD. But for this project, I feel pure assembler will give me the opportunity to finetune the code better, also I will have full control of number of cycles used for every part of the control.

I already have many PIC programmers, all of wich work well and all are homebuilt. I do have 1 AVR programmer too, also homebuilt. (It's actually a lpt connector and 2 resistors LOL.)

I'll start off with the PIC and see how far that gets me.

Oh, btw... I have found the FET's I will be using
They are perfectly complementary N/P pair and 6 of them won't cost me more than $12. They can (with a heatsink) handle a whopping 20 amps, but for my use and 2-3 LiPo cell voltage they will handle 5 amps gracefully. They are also made for fast switching applications so they are quick.

MTD20P03HDL trans P-MOS =
MTD20N03HDL trans N-MOS =
(Ignore the Swedish on page 1 of the datasheets, rest is in English.)

Both are available from my local supplier Elfa ( and the DPAK packages should be good for my use.

I haven't selected the exact PIC I will be using yet, but I will be using one with a internal oscillator to avoid oscillator components that are quite fragile.

For opamps I will have to look around a bit as I want some special qualitys (seperate input and output voltage swing/supply for directly interfacing the motor +/- voltages to the PIC TTL levels.) This is also to save on extra components. (The board will be 2-sided and I will try to keep all power logic on one side and control on the other. This should minimize number of vias required.

This really seems doable...
Jan 27, 2004, 08:39 AM
homo ludens modellisticus
Ron van Sommeren's Avatar
Originally posted by KreAture
... CD-ROM motors with the regular 3 sets of coils and 12 magnets make for a gearing of 4:1 thus needing a commutation rate 4 times higher to achieve same rpm.
Field/shaft speed ratio is 6:1, commutation rate is six times higher.

Met vriendelijke groet Ron van Sommeren
diy brushless e-motor homebuilders discussion.
Electric fly-in & lrk meet, June 27th, 2004, Nijmegen, the Netherlands.
Jan 27, 2004, 08:40 AM
Impossible? Hah!
KreAture's Avatar
Yes, interrupt on rising edge or falling edge is what I had in mind... Most of the PICs time would be spent decoding PPM and generating PWM at high frequency. (like 30kHz for better 0-crossing detection)
Jan 27, 2004, 08:51 AM
Impossible? Hah!
KreAture's Avatar
Oh, and I have been pondering about using on-board comparators that are fed a composite signal of the 3 phases made to fit 0-5v with a voltage divider then letting the circuit use it's internal reference to select the 0-crossing point. This would allow it to adjust it's timing based on a ADC reading of the voltage on a current-shunt. Minimizing voltage over the shunt for same pwm range should be a good way of making it rather effichient. Also, it can store values it reaches for the different pwm-ranges for faster adaptation when speed is changed. (I'e it would be a bit ineffichient when u set it at 50% throttle, untill it can have a look at the numbers and learn. Then it would go straight to that lead-angle next time it was set at 50%. Untill power is turned off, and chip is reset that is...)
Jan 27, 2004, 09:04 AM
Impossible? Hah!
KreAture's Avatar
Thanks Ron van Sommeren
How was the formula for gearing again ?

A 3-stator, 2 magnet motor is 1:1
A 3-stator, 6 magnet motor is 3:1 ???

A 9-stator, 2 magnet motor is ?
A 9-stator, 6 magnet motor is ?
A 9-stator, 12 magnet motor is 6:1 (as you say?)
Jan 27, 2004, 09:14 AM
Registered User
Mr DIY's Avatar
ParkJeff. … I use both although, I do not use the interrupt to look for crossing feedback though. After doing some basic background chores, the micro is put into a loop monitoring a single pin that has all feedback signals streamed to it. On acquiring that signal, it then processes all the information, loads timers, ect before once again returning to a pin polling routine.


Bad news for you. The FETs you have in mind are no good at all. The on-resistance is way WAY to high. (N channel 35 and P channel 100 milli ohms ... ooh how about those losses as well) You will probably not even be able to get 3 or 4 Amps out of them. (with heatsinks and we do not want heavy heatsinks) It worth doing a search for some manuals for commercial controllers and noting the on resistance they specify. . (I found a TMM manual that lists the on resistance for each controller) For instance, even for only 10 Amps, your FETs must have an on resistance of less than 10 milli ohms each. The specs sheets for FETs are quite misleading in a way, and you must be careful in selecting the right devices. Also consider going only N channel. Things get more complicated this way, but you can get more amps at the end of the day. for 10 Amps, I found a Dpak device On-Semi MTD3302 that I could test with. Take a look at its specs. to get a feel for a FET that will only give you about 10Amps.

I have currently orded some IRF7822 that should work OK for 10 Amps for an SO8 package.
Jan 27, 2004, 09:16 AM
homo ludens modellisticus
Ron van Sommeren's Avatar
It's not about gearing. All you do is count the number of magnets that passes a stator pole in one revolution.
Jan 27, 2004, 09:23 AM
Impossible? Hah!
KreAture's Avatar
Wonder if I can stuff this system in a PIC16F88 ?
It has:
- 8x8mm footprint!
- 16 IO ports
- 7 ADC channels (utterly useless to have that many)
- 8 MHz internal oscillator
- max 20 MHz clock
- 1 PWM module
- 2 comparators (400 ns response time <= 4 instructions at 8 MHz)
- 2-pin ICSP
- 3 timers and a WDT

I will order some samples...
Jan 27, 2004, 09:27 AM
Impossible? Hah!
KreAture's Avatar
Ron van Sommeren
Then how do you get 6 on a 12 pole ? Ah, because you divide by 2 for n/S pair ?

So a x pole motor with 6 magnets have 3:1 "gearing" and a 12 mag has 6:1. I get it

Then for a 12 magnet motor (highest torque for DD of a slowflyer prop) I get 166 instructions pr commutation at 10,000 rpm running at 4 MHz... Sounds doable.
Jan 27, 2004, 09:33 AM
Registered User
anfarol's Avatar
I work with AVR and PIC.
It is True, Pic takes 4 clks, meanwhile AVR takes 1 clk per instruction.
But some AVR instructions takes 2 or 3 cycles, so efficiency isn't 4x than PIC.
Working on a AC 3phase, in the past, driving 6 SCR (2 per phase), I've seen that AVR code is 2x faster then PIC.
If you use an ATMEGA8 @16Mhz, you'll have a bullet (16Mips), but using a PIC18 will be even better (40/4=10Mips, but x 2 if you compare to AVR)

I'm starting work to my controller and it's really a time critical application....
we'll see.

bye, anfarol
Last edited by anfarol; Jan 27, 2004 at 09:36 AM.