Motor speed control

Jeremy Leach

Senior Member
I'm wondering how to accurately control the speed of a solar motor and thought I'd see if anyone had any tips :confused:

My requirements are: Speed variable from very slow to max speed (0 to 400 speed units). Motor reversible. No step changes in speed, but still needs to be pretty responsive and reach an accurate stable speed quickly (I know this is a bit vague!). The motor will have very little load and the load it does have will be pretty much constant.

So, my thinking is: PWM to L293 motor driver. Then optical slotted disc for feedback. Then use either Count command or Pulsin to measure the actual speed (although pulsin could be a bit ropey due to tolerance of slots in disc). Then ideally some form of simple PID control in code.

One thing I'm unsure about is whether I'd need two-sensor gray coded feedback from the slotted disc (to avoid glitches at the transitions) or whether I could just go for a single sensor tacho approach and have a low pass filter to remove glitches??

Also, overall I'm not sure if a current sense solution would be simpler?

So really, I'm just after people's advice/experiences for making a simpler but accurate speed controller/ESC :)

Oh, and I'm ALSO interested in anyone's plans to take advantage of the X2 higher clockrate with motor control - incremental encoders with counters etc !
 

BeanieBots

Moderator
OK, here's my contraversial answer. No PICAXE involved.
Solar motor implies low(ish) current.
You could use a power op-amp (eg LM77000) for bidirectional control.
Speed is proportional to back emf.
You can't measure back emf directly because of coil resistance and I.
However, you can meaure I and you KNOW R.

V across motor = emf + I.R
Hence, emf = Vmotor - I.R

The op-amp can measure the IR direct and add it to the voltage applied.
Voila, simple and easy speed controller which maintains speed irrespective of load.
Use a pot to set the IR compensation gain. If it's too high, it will oscillate violently, if it's too low, it will have sloppy control.

It's actaully an ancient control method but I used it the other day so it was on my mind when you posted. The same priciple can be used to determine the speed of wind generators without the need for any extra sensors etc.

PID to control low inertia motor speed with PICAXE using encoder feedback? Good luck. Might be possible with X2 but pushing the boundaries.
I'd love to be proved wrong on this one.

To get a 'feel' for if a controller is fast enough, consider what happens to the device you want to control when full power is applied. Can the controller make a reasonable plot of how it responded?
Putting a massive flywheel on the motor would make life a lot easier.
 

Dippy

Moderator
How controversial :)

Couldn't you do a 'baby' PID where your feedback adjustment step is a function of the difference? I did that with a rough SMPS design once and it worked a treat.

Will your sensor need to feedback direction and speed or just speed?

I'll be interested to see how this pans out.
 

BeanieBots

Moderator
Something like:-
If it's a long way off, add a lot. If it's not far off, add a little.
If it keeps getting worse, keep adding more.
If it's getting there quickly, pull back.

Doh... that's PID!
 

Jeremy Leach

Senior Member
Thanks BB, that's a tempting solution because of it's simplicity. Optical slotted disc is all a bit fiddly so I like this idea. However I need a picaxe to set the target speed value, so I guess I could generate a feed voltage into the Op-Amp using pwm ... Hmmm.

I was thinking about the feedback and whether I needed the direction too. If I simply counted pulses then I wouldn't have direction, but I don't think it would matter - it's a small load on the motor and I think when the code changes the motor direction the motor will reverse pretty quickly, especially since the requested speed change will always be relatively small.

I can see PID needs to be faster than even an X2 is likely to be able to supply. I've yet to post my PID routine that does full P, I and D (waiting for the ** issue in the sim to be fixed so I can test it!) but I doubt it will be any where near fast enough!!

The one good thing with my requirement is that the speed value only needs to change quite slowly. One idea I had was to have a hybrid open / closed loop approach: If I used PWM drive and then optical pulse count feedback, the picaxe system could initally go through a 'learning' process:
- Select a range of PWM values
- For each PWM value, keep the value constant, allow the motor to settle at steady speed, obtain the actual speed reading by counting pulses. Store in lookup. So this is open loop lookup.

Once this learning process is complete this lookup can be used to set a good starting PWM value, and then can use closed loop feedback ???
 
Last edited:

BeanieBots

Moderator
Jez,
What you are suggesting regarding a learning hybrid system would actually be more complex than PID. I've something similar with digital hardware using binary-rate-multipliers and synchronous up/down counters but it takes a lot of chips if you want anything other than four bit accuracy.

IMHO, your best bet is the idea you suggested of using the PICAXE to supply the demand signal for an analogue control loop. I've often doen such loops. Gives you the best of both worlds. Digital settings, menus, buttons, LCD etc etc with a lightning fast control loop. Remember, the PWM is only 10 bit and also only when at its slowest.

You've not really said much about the load or required accuracy.
What happens (could happen) while you are counting pulses?
How long will it take to count enough pulses to get the accuracy you require?

Please DO stick with your PID system for PICAXE.
It comes up quite a lot and a well documented reference would be very handy to refer people to. Also, knowing the way you work, it will be cut to it's limit and optimised for speed. Whilst you're in the mind for software that learns, you could do an auto-tune PID:D
Now that would be a nice project for a 28X2:cool:
 

BeanieBots

Moderator
I'll eat Dippy's strawberry if that's using profiled PID speed control:p
(PICone uses 18X plus 28X1).
 
Last edited:

bgrabowski

Senior Member
That was a new prototype being trialled. It definitely only used one Picaxe 28X2. It may well not be PID, I do not know any details of how the programme works. Perhaps Technical could let us know how the speed control was implemented in the original version.
 

Jeremy Leach

Senior Member
Yep bgrabowski, the picone looks very impressive. I've not seen the code - I guess it counts rotation in Basic software rather than internal hardware (set-timer)??

I'm torn between the back-emf solution and PWM Drive/Tacho feedback solution though:

For the backemf solution ...
Yep I understand about PWM duty only being 10bit for lowest freq, but that should be ok. So my picaxe could generate the control voltage using PWM into a RC stage.

I've also been thinking how to make your backemf soltion Bi-directional. One method I can think of would be to have one end of the motor held at a midpoint voltage (of the supply), using an op-amp buffer (or dual rail supply), then use another op-amp to sum the IR and control voltages ?? The motor would be off if the control voltage was midpoint. Seems to be feasible I think. Not sure about PWM control signal though if dual rail. Might get messy. L165V op-amp looks suitable (couldn't find one you mentioned BB).

A large slotted disc with lots of slots per rev, using count command feedback and PWM drive is tempting too though, but the problem is the responsiveness.

I could also use a freq to voltage converter (e.g LM331) and then use ADC input.
:confused:
 
Last edited:

manuka

Senior Member
Such so called solar motors (at least the ones I've used), have ~10-30mA lightly loaded current drain at just a few Volts supply, & of course are traditionally "H" bridge controlled. What exactly are you wanting to do with such a tiddly device & at what rpm speeds?

Have you considered bypassing brushed DC types & using a nifty low current drain stepper instead? Brush-less DC motors are of course now exceedingly well established, & PICAXE control overall may be easier- although at lower top speeds. Check the ~US$1 bipolar G14197B offering ( ~20mA draw) from Electronics Goldmine => www.goldmine-elec.com .
 

Attachments

Last edited:

BeanieBots

Moderator
Jez,
LM27000 http://www.national.com/ds/LM/LM759.pdf
Or any old op-amp with a bootstrap on its output.

You would indeed need dual rail for a bi-directional version of what I suggested.
However, if control at close to stopped is not required, you could use single rail and a reversing relay.
Or, as you say a second power op-amp (or cut down transistor equivalent) to supply a "mid rail" and a bit of extra thought for the feedback/demand voltages.

Manuka makes a good point about using a stepper.
No speed control (as such) required. Just an assumption that no pulses get skipped.
 

manuka

Senior Member
Splutter - you're right- no shipping outside certain specified countries! To ease their US$50 P&P, a bunch of us here in "friendly" NZ regularly order a great stash of EG goodies. I'm not anticipating on going forwarding offers, BUT you may be able to perhaps join our next order, & we'll then re post to UK ?
 

eclectic

Moderator
Splutter - you're right- no shipping outside certain specified countries! To ease their US$50 P&P, a bunch of us here in "friendly" NZ regularly order a great stash of EG goodies. I'm not anticipating on going forwarding offers, BUT you may be able to perhaps join our next order, & we'll then re post to UK ?
Many thanks for the offer Stan, but,
I'm sure that the economic advantages would
be overwhelmed by the Postage/ Delivery disadvantages.

A genuine "Market-Place" question.
Many here, have ordered items from all over the World.

I wonder why Goldmine are isolating themselves from Europe?

Or, if I were in a coarser frame of mind , .......
"If they can't be bothered to accept my money,
then ......... 'em!"

Lots of other places to buy from!

e
 

Jeremy Leach

Senior Member
That stepper looks perfect actually Stan ... yep I've realised they don't ship to UK too :eek:. I've actually done a lot of browsing of stepper suppliers recently and can't find anything like that. The fact that you can drive it directly from an 08M would be great.

Does anyone know of a supplier to UK of similar steppers??:rolleyes:

My app is actually a two motor XY platform, but more to do with velocity than absolute position, but having absolute position would be a real bonus too.

Thanks BB. Been thinking - isn't one downside of the backemf solution the low motor voltage at low speed and therefore difficulty in overcoming friction of even a light load? That's why PWM is so good ??

Another factor I haven't mentioned - I'd like this motor to be as silent as possible ... doesn't PWM whine sometimes (although I suppose that's fixed by choosing an inaudible freq) ?
 
Last edited:

Andrew Cowan

Senior Member
I've got big piles of small steppers. Sources:
Floppy disk drives have tiny (1.5cm dia) steppers.
Printers (esp photo printers) often have tiny steppers.

Keep recycling!
 

manuka

Senior Member
Jeremy: A couple you say? I've a good stash of them here,& with another 100 up order in the wings may well be your fairy godmother. In the spirit of the colonies supplying the mother country, I'll swap you for something from Blighty. Either that or you shout a few pints to a destitute backpacking Kiwi next time you spot one - it may well be one of my kids! Check your PM. Stan
 
Last edited:

BeanieBots

Moderator
@Jez,
The low volts at low speed is no different to any other control method at low speed. Low encoder count, low tacho voltage, whatever.
A PID loop will use the integral term to ramp up drive and the derivative term to cut it back as soon as 'stiction' is overcome. You can even tighten it right up to give the same effect as low frequency PWM if you want.

PWM can APPEAR to work better by moving the motor in small steps. This may or may not be a problem in certain cases but if PID analogue control at low speed REALLY is a problem, then PWM stepping would also be a problem.
The issue to understand is that motor speed asciated with each PWM pulse is NOT under servo control. Only the overall speed is controlled.
Bottom line, if you can't control with analogue, you deffinitely can't with digital. It's all about resolution and quantising.

PWM drive can have advantages with OPEN LOOP control but NOT in CLOSED loop.

Don't just take my word for it. Try it out.
Build yourself a simple PID motor controller using op-amps.
It shouldn't take more than an hour. Then try it with PWM.
Load the motor (maybe by holding with fingers) and see the effect.

@Andrew, there are creams you can get for those big piles you've got;)
 

Jeremy Leach

Senior Member
BB, I can see what you mean about closed loop analogue and the control ramping up to overcome stiction as you say ;) but the backemf solution is open loop so I was just thinking that PWM might have an advantage - it gives a short blast of torque that will overcome stiction, rather than a constant lower torque that won't. I've seen a PID circuit using op-amps that looks quite do-able ...

But, Stan's small stepper solution seems good ....

I've had an idea about steppers: Assuming it's a small load and steps are aways taken and NEVER missed, then I was wondering if the step counter values could be saved in EEPROM just before power down, using some sort of power down detection/interrupt code. Then at power up there is no need to initialise the X and Y drive. So ....has anyone done this, and what power down circuit?? Off the top of my head I think could simply check voltage on the 'power source' side of a big Cap across the supply. When this voltage drops then interrupt and store counter values in EEPROM.

I can see this approach might still lose steps though (lose registration I think is the term?) if power down mid step etc. Just an idea though.
 

BeanieBots

Moderator
Jez,
The backemf method isn't really open loop.
It converts a real life motor into an ideal one with no winding resistance.

If there is no rotation, the backemf is zero.
From then on, it's down to your control method. The most basic method being a 'P' only using an ideal tacho. 'P' can be set VERY high as the only lag in the system is coil inductance and twisting of the motor shaft. This method was very popular in the old 'keyboard' type portable tape recorders.

You're right about the short blast with PWM which is itself of course open loop. Fast 'I' & 'D' terms would have the same effect in an analogue system.
No reason you couldn't combine the two methods but IMHO you won't see any REAL advantage. Like I say, try it!

Only you can say if a stepper motor method would be suitable for your application.
However, you should think VERY carefully about assuming no steps will be lost during power up & down. Don't forget, there is no holding torgue with an unpowered stepper. Also, what happens with the drive electronics during power up/down. Is there zero chance of any glitches causing an extra step with whatever method you will be using? Does the odd step here and there matter?

Many stepper driven systems don't bother with a 'home' sensor, they simply drive into a hard stop, stall, and then resume from there. Reminds me of a four pen plotter I once designed. No less than fourteen logic chips, A2D chip and twelve transistors. I was very proud of how simple the design was. Could all be done with an 08M and 2803 now:eek:
 

Jeremy Leach

Senior Member
@Rick .... thanks, but not as tempting as the NZ import ;)

I'm already thinking of the code for a single 28X2-3V (or 20x2) 64MHz acting as dual axis stepper driver chip (maybe driving through buffers), receiving commands from a master picaxe. My ideal plan would be to loop every 4ms ...
Code:
DO
   Decide whether to step X and/or Y and update XY abs position counters
   Check for new XY speed commands from master and handle command 
   Wait for 4ms period to be over (wait for timer flag)
LOOP
The 4ms is just what I think I'd need for maximum stepper speed.
The command from the master would be received serially in the background.

I'm just not sure yet if this would be possible !! I need to order a 28X2 to find out ;)

@BB .... I'll have to think about if missed steps a problem !! Designed 4 pen-plotter ....respect !!
 

Rickharris

Senior Member
By using a second motor as a voltage source i.e connected with a common shaft you can get a motor to run very slow indeed and reliably. Even without any microprocessor involvement.
 

Wrenow

Senior Member
Back to the original question - the simple solution for that motor (USD$10) is the VEX Robotics Motor Controller http://www.vexrobotics.com/vex-logic-products.shtml (penultimate product on the page at present, just above the LEDs). It is an ESC for low draw motors that is used in their servo-lke motor unit. It can only handle about 1A continuous, but the Solar Motor 02 draws less than that, so you are good.It gets motor power from the Radio Control servo lead, not a separate battery connection like most ESCs, simplifying connections for most users, and used standard old hobby RC signals - thue you can run it with the Servo command (or sut up your own Pulsout routine, of course) - won't get quite 400 steps of speed, more like 200-250 (actually, in working witht he output curve of signal to RPM, it tops out in both directions a little below RC "full throttle", so, perhaps 180 steps of speed from full reverse to full forward.

Depending on how slow you want, if you are willing to go to a lower speed range, you might get better low speed granularity with a geared motor like the little low-draw geared motors from http://www.pololu.com/catalog/product/1100 The one shown in the link I gave is similar characteristics to the Solar Motor 02 in speed, draw, etc. They also have others with higher gear ratios.

Cheers,

Wreno
 

BeanieBots

Moderator
Correct me if I'm wrong Wrenow, but that is an open loop controller.
RC PWM to full range PWM converter. (plus 1A driver)
No better than open loop PWM speed control from a PICAXE.
 

gbrusseau

Senior Member
About 10 years ago I built a Back-EMF ESC and was very pleased with its performance. You could even set the motor to STOP and if you tried to manually turn the motor shaft, the circuit would send power to the motor to resist any attempt to manually turn the motor shaft.
 

Attachments

BeanieBots

Moderator
Absolutely gbrusseau.
People often get speed control and torque control mixed up.
A speed controller controls... well... speed.
Zero is a perfectly valid speed, so a speed controller should be able to control to zero speed even if something wants to make it move. A back-emf contoller can do that. Applying 0v or 0% duty cannot.

Varying the voltage or PWM on a motor is effectively only torgue control with speed limit. If loaded, it slows down.

EDIT:
Jez, note the simple two transistor bootstrap on the output of the 'drive' op-amp.
It really is that easy to convert a regular op-amp into a power op-amp. No need to get a 'special' one if you don't have one to hand.
 
Last edited:

Technical

Technical Support
Staff member
I'll eat Dippy's strawberry if that's using profiled PID speed control:p
(PICone uses 18X plus 28X1).
All is explained here:
http://www.rev-ed.co.uk/docs/kit110.pdf

The 28X1 controls the speed of the two motors via 2x pwmout and then counting motor revolutions. The two chips are used simply so that the 18X can calculate the route whilst the mouse is still moving (when the 28x1 is still busy counting revolutions and checking for walls).

When migrating to a 28X2 this dual processor system can be replaced by the one chip due to the larger RAM and increased processing speeds (40MHz).
 

Jeremy Leach

Senior Member
Aha, understand bootstrap now BB, thanks. gbrusseau that looks a very good circuit.

I'm going down the stepper route I think - it feels a shame now, because these analogue circuits are much more nteresting !! But I'm after simplicity and low chip count if possible.
 

Wrenow

Senior Member
Correct me if I'm wrong Wrenow, but that is an open loop controller.
RC PWM to full range PWM converter. (plus 1A driver)
No better than open loop PWM speed control from a PICAXE.
As I understand it, you are correct. There is no feedback, it is just like any other hobby RC ESC. But, given a specific input, the output under the constant light load mentioned should be pretty consistent and repeatable.

If a closed loop system is required, some of the ESCs from http://www.robotpower.com have quadrature encoden feedback. The Dalf unit appears to be specifically designed for a closed loop system. A tad dear for me at USD$250, but might be worth it for someone who needs it.

Cheers,

Wreno
 

BeanieBots

Moderator
Jez, by all means use steppers for this app, but DO have a go at the analogue stuff when you've finished it.

Also, don't forget that many op-amps come in 14 pin packages with four amps in each one. You can also get 8 pin chips with two op-amps. It's all the resistors that usually put people off.
 
Top