Shop OBEX P1 Docs P2 Docs Learn Events
Brushless motor control : a solution — Parallax Forums

Brushless motor control : a solution

TreeLabTreeLab Posts: 138
edited 2009-03-03 19:38 in Propeller 1
Greetings All;
A coworker and I have recently finished controlling a hard-drive spindle motor using a prop, a schmitt trigger and three darlingtons. It involves attaching a marked spoke-disk (laser printed onto a plastic sheet) to the spindle, and detecting the passage with an optointerrupter. It has excellent speed control from 20-120 rotations per second, with speed fluctuations of less than 0.5 Hz. Acceleration is amazing, and it self-starts reliably. The motor and transistors all run cool even at top speed. We have been using motors with ~3 ohms/coil; we will be testing higher-speed SCSI drives soon. The prop code is in SPIN.

Would this be useful to anyone else?

Cheers!
Paul Rowntree

Comments

  • SRLMSRLM Posts: 5,045
    edited 2009-02-11 00:53
    TreeLab said...
    Would this be useful to anyone else?

    Absolutely! On of the things on my electronics To-Do list is to control a brushless motor. If you have source code and schematics, you could post them into the completed projects forum.
  • heaterheater Posts: 3,370
    edited 2009-02-11 09:35
    Oh yes please Paul!

    Driving hard drive motors has also been on my todo list for a long time, having a stack of dead drives with their motors pulled out waiting in my junk box.

    There was much discussion here a few months ago about how to do this so many others will also be interested.

    Do you have a means of riving in reverse? I always had a vision of some kind of little robot using those motors. Direct drive to the wheels which are actually the platters.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • TreeLabTreeLab Posts: 138
    edited 2009-02-11 13:47
    @Heater : WHen you say reverse is it for the two drive wheels facing in opposite directions, or would you be wanting quick reversals? Opposite direction of spin would be trivial to add, but the turn around would be very slow (the natural spin-down time is ~30 seconds from full speed, and I have no braking at this time). But 130 Hz wheel speed, running on 4" wheels, would give 130 ft/second ground speed. That would be one fast little bot! I wonder what the spindle motors would think of this unbalanced load? Only one way to find out.

    These motors have very low torque on startup, and I give it an electronic kick to get going. I do not know if being forced to move the bot would allow the start process to engage. Only one way to find out.

    I will prep the package and let you know when and where it ended up.

    Cheers!
    Paul Rowntree

    Post Edited (TreeLab) : 2/11/2009 1:53:26 PM GMT
  • heaterheater Posts: 3,370
    edited 2009-02-11 15:05
    Actually I was thinking about a little two wheel self balancing bot. Inverted pendulum. With direct drive to a hard drive platter wheel on each side. So for sure quick reversal is required. Spin down is not a problem as it would never get to any high speed.

    I did think that low speed torque would be an issue in this application but never got around to finding out what they can deliver when pushed hard. They seem to give a hefty kick last time a gave one a jolt from a battery. Perhaps they would not like that abuse for very long[noparse]:)[/noparse]

    The start up process is an issue. Basically in this application it would have to be constantly starting, stopping, reversing...

    I imagine the controller would have to have fairly accurate knowledge of the spindle angle at all times such that it can be driving the motor in approximately the correct phase for maximum torque even when stationary. So some kind of angle sensor is probably required.

    Still if that's not a possibility there must be many other uses for them with your driver.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • TreeLabTreeLab Posts: 138
    edited 2009-02-11 17:23
    My driver knows the orientation of the spindle to within 2.5 degrees at all times ... if it looses this , bad things happen, and it cannot recover without stopping and re-kicking it (electronically). My concern has been to manage high speeds (where the fear is loosing a 'spoke' in the counting); spin+1 hardware counter works to at least 130 Hz shaft speed, 72 spokes per rotation. Manipulating small, slow rotations is a different issue, and would require more thought. ALthough these things look like simple steppers, they rely on angular momentum to maintain coherence, instead of brute force and strong B-fields.

    Actually, here is an approach that I discarded because I needed high speed : instead of a spoked wheel to track rotations, you could have a grey-scale gradation that would tell the prop what the absolute angle is just by using a simple ADC like a MCP320x. Or an digital absolute shaft encoder This should control the small, slow and vaying directions

    Cheers!
    Paul Rowntree
  • Ken PetersonKen Peterson Posts: 806
    edited 2009-02-11 18:03
    If you provide speed reduction with belt-drives, it might work.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"I have always wished that my computer would be as easy to use as my telephone.· My wish has come true.· I no longer know how to use my telephone."

    - Bjarne Stroustrup
  • heaterheater Posts: 3,370
    edited 2009-02-11 21:43
    What appealed to me about hard drive platter wheels is that a)It's dead simple mechanically b) Those mirror like platters with some black rubber tread glued on would look so cool!

    TreeLab, does your driver really know the orientation of the spindle to within 2.5 degrees at all times? Even when stationary at start up?

    I imagined you have so many "spokes" on your disk to get that resolution but are relying on counting from some kind of "North" marker when turning.

    I had thought of printing a grey scale on paper and gluing it to the back of the motor side of the platter. With perhaps only five bits of resolution. We could interface two wheels directly to a Prop using 10 pins. With the magic of Grey scale one can get the position very quickly just read the 5 pins and then waitpne (to whatever value was last read). In PASM the motor will never beat you.

    Anyway that gives a pretty good angle measurement even when stationary so we can drive the thing for maximum torque in what ever position at whatever speed.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • TreeLabTreeLab Posts: 138
    edited 2009-02-12 02:36
    The secret is the start up. I slowly apply a PWM to the A coil, and increase the duty cycle so that it will slowly move to the A position when enough current is passing through the coil; by ramping up the power the spindle never gets enough angular momentum to push past the centre of the A position, then it locks to this position by the high current/B field. I then repeat this for the B coil (as much just to confirm that the coil is energizing correctly) and the rotor flips to the adjacent B position. At this point I start an edge detector counter to count transitions of the spoke passages, zero the phsb register that is counting transitions of the spoke passages, and give the C coil a mighty kick to send the wheel in motion. Since we know that it was at the B position before the kickstart, the direction of rotation caused by the C kick is assured. I call the monitoring routine immediately, and then track the number of hits on the phase register in real time, and apply power until near the end of the 'coil time', which is 6 sectors of 5 degrees each. Then repeat for the subsequent coils.

    I said 2.5 degrees, since that is half the width of any sector. It would be more honest to say that it is somewhere inside this 5 degree window. Plus, the motor has 4 equivalent coils (some motors have 3) on each pole, so again, I should be more precise to say that I know in which coil zone I am working, and the maximum uncertainty is 5 degrees. I can slow the rotor with my finger (ouch) and it seems to be able to track the perturbation (since this is slowing it down). If more speed is needed, I will go for PASM. I do not have a 'North' marker. I was thinking of an absolute position tracker with a wider spoke somewhere, but I am not sure how/if/why I would use the information. The reason that I have so many spokes is so that I know in advance when we are getting close to the next coil (6 spokes per coil) so I know if I have enough time remaining to keep energizing the current coil. The whole thing shudders to a halt if you overstep the coil boundary (it actually starts to brake I think, then gets yanked to the next one, and so on).

    They would be very cool wheels for a bot.

    Cheers!
    Paul Rowntree
  • anita1984anita1984 Posts: 23
    edited 2009-03-02 17:35
    Hello , very nice work , i would like to ask you , how can i know the coil A from B from C ? it should be special resistance between then or how?
    Thank you in advance .
  • TreeLabTreeLab Posts: 138
    edited 2009-03-02 17:52
    @anita1984
    To my knowledge, there is no distinction between the three coils inside the motor, BUT there is a sequence of windings, and the sequence determines the rotation direction.

    If you have a std 4 wire motor, then the resistance between one of them and each of the other three should be about the same (~3 ohms for std motors, 1 ohm in high speed SCSIs). This is the common lead, and the other three correspond to each of the three coils. If you measure the resistances between any two of these coil-wires, it will give about twice the resistance as from the common to the coil winding.

    You CAN figure out which is the A-B-C by turning the motor with your hand and measuring the voltage generated from the common to each of the three coils. They will be 120 degrees out of phase with each other. Or, just don't worry about it (this is my preferred route!). Hook up the motor in some known sequence of coils (e.g. drivers 1, 2 and 3 connected to coils A,B,C, and the common connected to 12 V), and if it does not turn the way you want, just reverse any two of the three coil leads (e.g. 1,2,3 --> B,A,C).

    There is another thread on this project (http://forums.parallax.com/forums/default.aspx?f=25&m=329281) that includes a description of the (big) package that is now in the Object Exchange under Motor Control, as well as some very good ideas by other Forum contributors. It is very stable, and offers good speed control and 100% assured start up behaviour without manually kicking it. I am working on an assembler version of the code that should be even more robust (less likely to get lost if you try to push to too high a speed) and perhaps a bit faster. I will modify the above-cited thread when the code is ready.

    Cheers!
    Paul Rowntree
  • anita1984anita1984 Posts: 23
    edited 2009-03-02 21:30
    Hello,
    Thank you TreeLab for this important information. This code is reliable way to get the motor going in one direction , what if we want to run it 2 directions : one Clockwise direction and after little time Anticlockwise (without interchanging any two of the three drive pin definitions) ? Is it possible ? And is it enought a power supply of 1A (12V) to spin this motor ?
    I am sorry for asking alot of questions.I like this project.
    Thank you in advance

    Cheers!
  • TreeLabTreeLab Posts: 138
    edited 2009-03-02 22:04
    @Anita1984
    If you wanted to go in either direction, it would be relatively easy to add a flag that would control the start up and run directions, but the motor would have to come to a full stop before restarting in the other sense.

    I am using a REGULATED 12 V 3.3 A supply, but depending on the speed, this is an overkill. I usually am running at about 60% duty cycle for ~60% of each coil's activation time; my speed control disables the output under these conditions about 40% of teh time at 100 Hz. So using this, I estimate that the power is being applied ~22% of the time. With a coil resistance of 3 Ohms and a 12 V supply, the coil would draw 4 amps at peak, then pehaps 0.8-0.9 A average current.

    For power supplies, oversizing is usually a good idea, and it usually avoids problems. So while 1 A will work, you will be pushing everything to the limits.

    Note that if you are using a wall-wart power supply, the above advice has a caveat : less expensive unregulated supplies will deliver higher voltages when lightly loaded, so buying an unregulated wall wart that can deliver 12 V, 3 A will probably expose the coils to higher voltages than expected, much higher instantaneous powers (P=V*V/R), and potentially more danger of overheating. My supply cost ~$10.

    Cheers!
    Paul Rowntree
  • heaterheater Posts: 3,370
    edited 2009-03-02 22:04
    There is a nice article about Gray codes on wikipedia en.wikipedia.org/wiki/Gray_code where it talks about "Single Track Gray Codes".
    With single track Gray codes there is are say 5 opto detectors spaced equally around the circle at the SAME radius. A single "track" of light/dark drawn on the circle is what they are detecting. This track has strategically placed "gaps" such that only one opto sensor changes state at a time. They give an example of 5 sensors resolving 30 positions within a rotation.

    I have never heard of "single track Gray codes", seems they were invented in 1996. Given that a hard drive platter is very reflective it would be easy to paint an intermittent dark track on it and make such a shaft encoder for the hard drive motor controller. Being cheap I want to use normal LEDs as opto detectors.

    Knowing the motor position at all times, even when stationary at start up would make slow speed control and reverse much easier.

    Just wish I had time experiment....

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • TreeLabTreeLab Posts: 138
    edited 2009-03-03 19:38
    I had never heard of this approach, but the advantages are very clear. Thanks Heater!

    Cheers!
    Paul Rowntree
Sign In or Register to comment.