Controlling Motor Speed with PICAXE

Russel Lawrence

New Member
Hi,

I'm a university student at Newcastle and I have recently purchased PICAXE software to help me with a project of mine.
I have got to be able to set up a system of two spinning wheels on seperate motors (miniature DC motors) but when one wheel is set to a higher speed a programme has to recognise this and brake the wheel untill they are rotating at the same speed.

So far I have worked out how to rig up the experiment but even though I keep trying to learn Im finding that I still dont know what programme to write that would allow a PICAXE18X chip to turn on a brake if a motor is running to fast.

Any help that anyone can give would be really appreciated becasue I am really struggling.

Thanks,
Russel
 

eclectic

Moderator
Russel.
Could you post more details (circuit/hardware specs.) of your
present setup?
There is a great deal of info on motor control on the Forum,
using transistors / H bridges / PWMout etc.

e
 

Mycroft2152

Senior Member
Russel,

Welcome to the forum!

A project is easier , if you break it down into the simple parts, get each one working, then combine them.

For your project, you need to first, be able to measure the speed of the motor. How are you doing this?

Second, be able to control the speed of the motor. How are you doing this?

Then you can compare the speeds and adjust the motors.

Myc
 

Russel Lawrence

New Member
Thanks for the quick responses,

I am actually using attactching a small fly wheel to both motors. The fly wheel has holes in them and I am using a photoelectric sensor to detect how many flashes of light pass per second. This is how Im hopefull going to measure the speed of the motors, and then I will speed one motor up (independantly of the other) and when this is detected a small solenoid will push against the fly wheel to slow it down.
I have tried to draw a daigram to explain (apologies for how bad it is)
Thanks again
 

Attachments

Andrew Cowan

Senior Member
Sounds like you need the count command, and PWM the motors.

COUNT motor A (store b1)
COUNT motor B (store b2)
If b2>b1 then
If b1<b2 then
 

InvaderZim

Senior Member
I'm not sure how well you'll be able to regulate speed using a solenoid brake; is it an on/off affair, or are you trying to vary the brake pressure by regulating the solenoid current?

Would you consider trying to control the motor speed directly? I tend to think it would be more reliable that way. The Picaxe has pulse width modulation (PWM) control, which should allow you to directly regulate the motor speed based on your feedback sensor.
 

Mycroft2152

Senior Member
Looks good to me.

Check out the BASIC commands Count and Pulsin.

You may have to reconsider the solenoid. It is either and all in or all out device. I am not sure how you will use it to adjust the speed.

Myc
 

Artie2

New Member
Actually, a solenoid is just a linear motor. Its speed and force can be controlled by voltage and/or current, the same way a rotary motor can. Current control will probably work better, but pulse modulation may work also.
 

BeanieBots

Moderator
We need NUMBERS to give the best answers.
Do you have 'scope available?
Measure the signal you get from your sensors and let us know the duration and rate of the pulses.
This will then determine if pulsin or count are the better option.

Does seem strange to control the speed by brake rather than motor drive.
Is there a special reason for doing it that way?
 

Russel Lawrence

New Member
Hi, thanks again for all the responses
Unfortunately I have to control the speed of the motor via a brake and not with the motor drive because my uni project states that the experiment must be done this way.
I don't have any numbers just yet but will try and keep up to date.
If there are any more ideas on the programming language I will be really grateful,
Thanks Russel
 

wapo54001

Senior Member
One problem with mechanical braking is the lack of useful feedback to the power controller. Normally, you would measure rpm, and adjust driving power accordingly -- reducing or increasing depending on if the motor is running too fast or too slow, until equilibrium is reached. After that, you make minor adjustments to maintain rpm.

If you control speed with a mechanical brake, how will the drive controller figure out how much drive is enough to just maintain rpm? You will constantly be 'hunting' for the right motor current.

Also, what is the time domain? Can the brake slow rpm over an extended time period, or must it be within seconds or even milliseconds? How much overspeed/underspeed is permissible?

How much freedom do you have in designing the flywheel? If there is no restriction, consider a two diameter wheel -- larger diameter to provide momentum, and use a smaller diameter in conjunction with a brake band lined with an appropriate material (felt?) to work with the solenoid. You could use the motor shaft itself for this purpose, you'll get much finer control. If braking can be relatively slow, you could use the braking requirement to calculate pwmout adjustments and eventually find equilibrium. If pwmout adjustments can be based on rpm error, you should eventually arrive at small pwmout adjustments to control rpm in a narrow band.
 
Last edited:

Rickharris

Senior Member
If you are useing or did use an L293 then making the 2 controlling inputs the same will result in what the data sheet calls fast motor stop - I guess that equates to a brake.
 

westaust55

Moderator
Thinking about how electric brakes for smaller trailers and caravans work, these use a form of pulse width modulation to apply the brakes. The longer the pulses, the more the brakes are applied.
 

westaust55

Moderator
Yes, shorting the motor terminals will give a braking effect but the projost requirement is:
Unfortunately I have to control the speed of the motor via a brake and not with the motor drive because my uni project states that the experiment must be done this way.
 
Top