Dc motor speed control

eclectic

Moderator
OK, my turn to ask

Are you using your real motor?

If you are, please post

The real schematic

A couple of high quality photographs.

People here want to see what you are talking about. :)

e
 

arg733

Senior Member
OK, my turn to ask

Are you using your real motor?

If you are, please post

The real schematic

A couple of high quality photographs.

People here want to see what you are talking about. :)

e
My motor is across town right now. I will be able to do the tests and post some photos if you want in a couple of days.
 

BeanieBots

Moderator
Trust me, so far it's been easy. The hard work will start when you do it for real and need to fine tune.
Then you will understand why everyone has been asking the questions they've asked and why everyone wanted DATA.
We all look forward to your real-life test results.
 

arg733

Senior Member
At 17.41 (British time), you said it was working.


At 19.49 , it's "across town"

Are you a Taxi driver? :)

e
:D no I don't try it on the actual motor i use 2 frequency generators 1 to simulate the hall and 1 to set the frequency (when i don't use the adc command of course :) ) and i am counting the picaxe's output with a frequency counter.
It would be nice if a 16 years old could get a driving license (I drive better than my mom :D but am i going a little off topic? )
 

eclectic

Moderator
:D no I don't try it on the actual motor i use 2 frequency generators 1 to simulate the hall and 1 to set the frequency (when i don't use the adc command of course :) ) and i am counting the picaxe's output with a frequency counter.
It would be nice if a 16 years old could get a driving license (I drive better than my mom :D but am i going a little off topic? )
PLEASE, in future

say if you are using

Simulation

or

a REAL MOTOR

It is VERY difficult to know how to help you otherwise.
 

arg733

Senior Member
PLEASE, in future

say if you are using

Simulation

or

a REAL MOTOR

It is VERY difficult to know how to help you otherwise.
But i said that all the tests i am doing are not on the actual motor unless i say that they are done on the motor :) (post #129)
 

Goeytex

Senior Member
This is analysis of the last posted circuit diagram that can be found HERE

@arg733

Circuit Analysis:

The use of 10K Resistors on the PMOS Drains means the FET are only getting abot 500 microamps to 1 miliamp of switching current. This means that ALL of the FETS are peforming poorly and inefficiently. The switching signals will not be clean square waves. In fact, this is partly why PWM frequency is changing the speed of motor at the speeds you are seeing. The FETs cannot turn on fast enough because of inadequate drive current. They are staying in the the linear region too long. The PWM control is working to control speed ... not by design, but rather by accident due to poor design. Change R1 - R4 to 220 ohms to give adequate drive current to square up the signals. Better yet, get rid of the P-FETS and keep reading. There are much better ways.

Due to its relatively high drive requirements, the IRF530 FET is a poor choice for driving the coil unless you are using dedicated MOSFET Driver. With your proposed circuit the rise time in the order about 10us on a resistive load. It will be worse on an inductive load. This means that your PWM is not doing what you think it is doing. But since you don't have a scope you can't see the waveforms. A 100V Logic Level FET with lower drive requirement will work much better. Or even better, use a normal level Power MOSFET and a dedicated FET Driver. You should also consider a clamp on the FET to protect it from back EMF.

It is a waste of components and money to use the 16 amp rated P-FETS for small signal logic functions such as inverting and as an AND/NAND gate. Small bipolar transistors will work better and will cost less. That being said, a single $1.00 74HC Logic IC will replace all of the P-FETS, many of the resistors and offer reduced current while providing clean square signals. It will do the exact same thing as all of your P-FETs, except much better.
 

arg733

Senior Member
This is analysis of the last posted circuit diagram that can be found HERE

@arg733

Circuit Analysis:

The use of 10K Resistors on the PMOS Drains means the FET are only getting abot 500 microamps to 1 miliamp of switching current. This means that ALL of the FETS are peforming poorly and inefficiently. The switching signals will not be clean square waves. In fact, this is partly why PWM frequency is changing the speed of motor at the speeds you are seeing. The FETs cannot turn on fast enough because of inadequate drive current. They are staying in the the linear region too long. The PWM control is working to control speed ... not by design, but rather by accident due to poor design. Change R1 - R4 to 220 ohms to give adequate drive current to square up the signals. Better yet, get rid of the P-FETS and keep reading. There are much better ways.

Due to its relatively high drive requirements, the IRF530 FET is a poor choice for driving the coil unless you are using dedicated MOSFET Driver. With your proposed circuit the rise time in the order about 10us on a resistive load. It will be worse on an inductive load. This means that your PWM is not doing what you think it is doing. But since you don't have a scope you can't see the waveforms. A 100V Logic Level FET with lower drive requirement will work much better. Or even better, use a normal level Power MOSFET and a dedicated FET Driver. You should also consider a clamp on the FET to protect it from back EMF.

It is a waste of components and money to use the 16 amp rated P-FETS for small signal logic functions such as inverting and as an AND/NAND gate. Small bipolar transistors will work better and will cost less. That being said, a single $1.00 74HC Logic IC will replace all of the P-FETS, many of the resistors and offer reduced current while providing clean square signals. It will do the exact same thing as all of your P-FETs, except much better.

Correct me if i'm wrong but,:

1.Mosfet's and BJTs are very different as mosfet are voltage switched whereas BJTs are current switched
2.10k resistors are not in series with the gate so even if the gate needs some current to charge the capacitance it does not preventing it to do so. The resistors are only there to pull down the gate and discharge it's capacitance when the 9540 is no longer sending a signal. If i change the resistors to a lower voltage i will in fact have a voltage and current drop.
3.I use 9540 because i have about 40 of them.



Thanks
 

Dippy

Moderator
"Mosfet's and BJTs are very different as mosfet are voltage switched whereas BJTs are current switched"
- as a 'one sentence' description that is true.
BUT there is a lot more to it if you want to make it actually work properly.
You must not think of a MOSFET as a 'magic' switch.

The MOSFET driving section makes little design sense to me.
You need to get a greater understanding of switching, particularly the aspect of Gate voltage Vgs and it's requirements.
And, when considering MOSFETs (big ones in particular), imagine a capacitor between Gate and source.
Imagine that you have remove that charge to get the volts down and shove some coulombs in to get the volts up.

As geotex has said, your P MOSFETs current will be weedy.
And look at your final section driving the 540 N type.
A pretty weak pseudo push-pull with a P chan one way and a 10K the other way.
Result: (if it works at all) the efficieny will be poor with limited PWM speed.
Just spend some time looking at the surrent flows at the Gate of the 540.
Then you'll understand what he means.

The other trouble is that reducing R4 may affect the driving ability from Q4.
For anything reasonably efficient I think the phrase 'back to the drawing board' applies.
Anyway, I'm going to stay out of it as you'll get some great advice here.
I suggest you listen to it.
 

Goeytex

Senior Member
Correct me if i'm wrong but,:

1.Mosfet's and BJTs are very different as mosfet are voltage switched whereas BJTs are current switched
2.10k resistors are not in series with the gate so even if the gate needs some current to charge the capacitance it does not preventing it to do so. The resistors are only there to pull down the gate and discharge it's capacitance when the 9540 is no longer sending a signal. If i change the resistors to a lower voltage i will in fact have a voltage and current drop.
3.I use 9540 because i have about 40 of them. Thanks

1. True but not the complete story.

2. While MOSFETS are indeed voltage switched, it takes time to overcome the gate resistance & gate capacitance. This time is a function of available current. You PFETS actually have enough current to switch ok, but since the are only operating at 500 microamps source to drain (the 10K resistor) the PWM from the PICAXE is feeding back throughout out the system. The reason for this is the crappy PFET logic gate formed by Q2 and Q3. Reducing Pull down resistors to 200 compensates for this poor design and eliminates most of this noise. The main problem is the way the Motor FET (IRF540) is driven). The Gate can only source or sink about 2 ma of current meaning the rise and fall times of the drain current will be awful.

3. I have some spare boat anchors in my yard. I think i am going to use them to control the speed of my car. I have them attached to a long cable. I keep the accelerator always at half throttle. To slow down I throw anchors out the window and drag them down the road until I get to the speed I want. To speed up I pull some back in.

ll I need now is a Picaxe based speed PID control to operate a winch to drag the anchors in and out of the auto. And don't tell me this won't work. And and don't ask for a mechanical drawing or vehicle weight or anchor weight, or engine horsepower. These don't matter will only confuse you. Just give me the code. OK ?
 

arg733

Senior Member
"Mosfet's and BJTs are very different as mosfet are voltage switched whereas BJTs are current switched"
- as a 'one sentence' description that is true.


What geotex stated (that I need to reduce the resistance) is completely false, in fact if I want more current flow I need to increase the resistance so the current going from the 9540 is not drained by the ground. But the loss current by the resistor will be only 1mA (ohm's law) so let's do the math: 19A (9540's datasheet) - 0.001A = 18,999A so the gate of the 540 can draw 18A as there is no series resistance!!! So would you say that 18A is not enough to charge the gate's capacitance...
The datasheet does not mentions gate current it only mentions VOLTAGE Vgs and Vgs(th).
Anyway I am open to suggestions if it would help me to do what I need with less money (AFTER I KNOW THAT EVERYTHING WORKS FINE WITH THE PICAXE, THIS IS NOT MY FINAL CIRCUIT. I intend to add many protections particularly for the picaxe after I know that everything works fine.)

I am open to suggestions after this experimental temporary circuit works out.
Thank you.
 

Dippy

Moderator
Back to some basics.
With your unusual circuit , tell me, what voltages are at the gates driving Q3 and Q4?
Now study the Data Sheet for that device.
What current would Q4 allow through at that voltage?

Do you really understand the significance of Vgs and gate charge and capacitance?

OK, let's get into fantasy world and assume your magic Q4 allows 19 Amps through.
What happens when Q4 switches off?
The IRF540 gate discharges via the 10k R4.
What current will that allow?
Your discharge/charge is hugely imbalanced and you will have a crap PWM signal which would greatly restricted in terms of frequency and power handling.

With respect, you really need to start understanding the basic operation before criticising more experience contributors.

Have a read and have a careful think rather than a simple 'knee jerk' response.
 

arg733

Senior Member
Back to some basics.
With your unusual circuit , tell me, what voltages are at the gates driving Q3 and Q4?
Now study the Data Sheet for that device.
What current would Q4 allow through at that voltage?

Do you really understand the significance of Vgs and gate charge and capacitance?

OK, let's get into fantasy world and assume your magic Q4 allows 19 Amps through.
What happens when Q4 switches off?
The IRF540 gate discharges via the 10k R4.
What current will that allow?
Your discharge/charge is hugely imbalanced and you will have a crap PWM signal which would greatly restricted in terms of frequency and power handling.

With respect, you really need to start understanding the basic operation before criticising more experience contributors.

Have a read and have a careful think rather than a simple 'knee jerk' response.
Ok don't insist if you both say so, but i don't want to spend 2 days (1 to find the necessary components and 1 to make the pcb) on changing an experimental circuit that may not work anyway. I even thought of testing it on the breadboard but i cant program the picaxe on the breadboard. IF it works i will ask how to make my circuit better and change it to work properly.

Thank you.
 

arg733

Senior Member
1. True but not the complete story.

2. While MOSFETS are indeed voltage switched, it takes time to overcome the gate resistance & gate capacitance. This time is a function of available current. You PFETS actually have enough current to switch ok, but since the are only operating at 500 microamps source to drain (the 10K resistor) the PWM from the PICAXE is feeding back throughout out the system. The reason for this is the crappy PFET logic gate formed by Q2 and Q3. Reducing Pull down resistors to 200 compensates for this poor design and eliminates most of this noise. The main problem is the way the Motor FET (IRF540) is driven). The Gate can only source or sink about 2 ma of current meaning the rise and fall times of the drain current will be awful.

3. I have some spare boat anchors in my yard. I think i am going to use them to control the speed of my car. I have them attached to a long cable. I keep the accelerator always at half throttle. To slow down I throw anchors out the window and drag them down the road until I get to the speed I want. To speed up I pull some back in.

ll I need now is a Picaxe based speed PID control to operate a winch to drag the anchors in and out of the auto. And don't tell me this won't work. And and don't ask for a mechanical drawing or vehicle weight or anchor weight, or engine horsepower. These don't matter will only confuse you. Just give me the code. OK ?
I still don't understand where you see a resistor that is not allowing the gate to take more than 500uA? This could only be the case if i had the 10k in series with the gate which would obviously not work.
 

russbow

Senior Member
Perhaps you didn't know that FETs have a capacitive element, now you do know, because you have learnt it here.

Have a look at this picture. The nice blue trace is you square wave (PWM) input. Nice isn't it. Very fast rise time - that's the bit from from 0volts to max.
Very nice and stable at the +ve value and then a quick fall to zero.

Now study the lower trace. This is what the FET actually gets because of the capacitance. Nothing like what you think you are applying to the gate is it.

rc10.gif

Now maybe you know about 1-e ^-t/cr but you might find this link useful

http://www.electronics-tutorials.ws/rc/rc_3.html

My two pennorth, now I'm out
 
Last edited:

JimPerry

Senior Member
You don't have to program the Picaxe on the breadboard - program it then put it on the breadboad - have you programmed ANY Picaxes yet? :confused:
 

RexLan

Senior Member
Ok don't insist if you both say so, but i don't want to spend 2 days (1 to find the necessary components and 1 to make the pcb) on changing an experimental circuit that may not work anyway. I even thought of testing it on the breadboard but i cant program the picaxe on the breadboard. IF it works i will ask how to make my circuit better and change it to work properly.

Thank you.
I don't believe it will work (for many reasons) so have no fear ... and, you may be "all-out" of asking for help. You have scolded too many VERY talented and knowledgeable folks.

I doubt he has a Picaxe or has programmed a Picaxe.
 

premelec

Senior Member
Yep Rex - I'm afraid arg733 means 733 arguments and we're only up to 223 posts... :) -- however I've not read most of them and do get the feeling that arg733 would actually like to learn some things and doesn't quite know how to do it - arg773 I hope you will get an actual PICAXE starter kit and try some stuff before trying to accomplish big high current goals. We all start somewhere often with confusion and excess 'knowledge' which doesn't - in practice - work. I recall a lady coming into a parts store asking for 1/2 a 12AU7 [you old timers can appreciate the joke...] as one triode half of the vacuum tube had died. Anyhow arg733 keep studying up on electronics and get some parts [take apart an old VCR or TV etc.] and try some stuff. Start simple - eventually you can get into high power drivers and such [I'm suspecting electric vehicles might be your intent...]. There are a whole lot of details and pitfalls but it can be done - enjoy the learning! Don't be afraid to not know much or to learn more... I've been at it 60+ years and still learn from this forum and other places.
 

arg733

Senior Member
I don't program it on the breadboard because the serial connector's pins are to near and don't fit in to the breadboard's holes. I also don't like the idea of taking the picaxe of it's programming board and put it on the breadboard and back again as i think that i may break the picaxe's pins.
Thank you.
 

Dippy

Moderator
One tip is to get a few cheap IC sockets of the right size, then pop your PICAXE into a socket and move the whole 'unit'.
Then if you break a leg on the ic socket just pop the PICAXE out and put it in a new socket.

On the MOSFET subject I don't notice any comment from you when others have mentioned MOSFET parameters e.g. Vgs.
You seem to have simply read the 'headlines' on the Data Sheet and skim-read posted replies..
You MUST search and read about MOSFET function as you don't appear to understand the basics e.g. push-pulling the gate.
We'll help if you get stuck - but most of us here (free time volunteers) haven't got the time to do it all for you.
(That's how your posts read, sorry).
 

arg733

Senior Member
One tip is to get a few cheap IC sockets of the right size, then pop your PICAXE into a socket and move the whole 'unit'.
Then if you break a leg on the ic socket just pop the PICAXE out and put it in a new socket.

On the MOSFET subject I don't notice any comment from you when others have mentioned MOSFET parameters e.g. Vgs.
You seem to have simply read the 'headlines' on the Data Sheet and skim-read posted replies..
You MUST search and read about MOSFET function as you don't appear to understand the basics e.g. push-pulling the gate.
We'll help if you get stuck - but most of us here (free time volunteers) haven't got the time to do it all for you.
(That's how your posts read, sorry).
But i have the socket soldered on the pcb! So how can i do what you suggest?

I know that i should use totem pole (push pull) drivers but i will do it on the new board that i will make after i see that the picaxe works properly. Sorry that i can't do that right now , i realize that you guys are right about mosfet driving but the nearest hardware shop that i can by electronics from is about 32 Miles away so i will loose at least 2 days if i want to make a new good circuit and i cant afford that much time. So as you see i am stuck with this crappy circuit, at least for the time being.
Thank you.
 

cactusface

Senior Member
PID What? Pelvic inflammatory disease, shows what I know!! I can't believe it! Oh no that's that other chap on the telly. I can't believe that so many post on this one item, I came across an old posting the other day, and despite forum members trying to help, he just called us a lot of unhelpful idiots, etc... We don't know all the answers (well I don't) but we offer our time and help for the better of all who come this way. I do at times think people post here for us to do all the work for them, even homework or collage projects.

Sometimes you just have to get down to it! Build it, even if it don't work for a start! That's how you learn in electronics and life.....

Regards
Mel.
 

JimPerry

Senior Member
But i have the socket soldered on the pcb! So how can i do what you suggest?
You have the socket or the Picaxe soldered to PCB? If socket then just use an extra socket, between Picaxe and socket, as suggested - if the Picaxe is already soldered direct then you are in deep smelly stuff ...:rolleyes:
 

arg733

Senior Member
You have the socket or the Picaxe soldered to PCB? If socket then just use an extra socket, between Picaxe and socket, as suggested - if the Picaxe is already soldered direct then you are in deep smelly stuff ...:rolleyes:
Hah! nice trick never thought of that thanks!!! I don't have the picaxe soldered so putting another socket wont be a problem
 

JimPerry

Senior Member
Hah! nice trick never thought of that thanks!!! I don't have the picaxe soldered so putting another socket wont be a problem
It's what Dippy said a few posts ago - I just explained it slightly differently - on another note: Cactusface never said you called anyone anything - but in an old post someone else did.

Read the replies carefully - don't just skim them - most of the older Picaxe Forum members can be very precise and even pedantic - but they really do want to help people.
 

arg733

Senior Member
It's what Dippy said a few posts ago - I just explained it slightly differently - on another note: Cactusface never said you called anyone anything - but in an old post someone else did.

Read the replies carefully - don't just skim them - most of the older Picaxe Forum members can be very precise and even pedantic - but they really do want to help people.
Ok sorry then i misunderstood him. See? my English is not that perfect.
 

BeanieBots

Moderator
..... so i will loose at least 2 days if i want to make a new good circuit and i cant afford that much time......
That has to be one of funniest things I've read on this forum. Thanks for making me laugh so much, it made my day.
For the sake of others who might not have the time to read the entire thread, remind us when you started this and give details about your progress so far. Good luck with your circuit.
 

hippy

Technical Support
Staff member
Okay; let's not rip into arg733 too much. I'm sure we all remember when we were younger and had ideas and ambitions and there's nothing wrong with, even ideas that can be sometimes be overly ambitious.

Arg733 - If you are happy with where you are heading then just go for it and see where it takes you. If you hit problems then hopefully things that have been said in this thread may be of some help to you, may make more sense once you've moved forward with your project.
 

boriz

Senior Member
Another alternative idea for torque control (simpler):

Since all the coils are energized at the same time (4 coils, 4 magnets), you could drive each coil with it's own MOSFET and change the number of coils that are active to change the torque.

EG: Full power = 4 active coils.Threequarter power = 3 active coils. Half power = 2 active coils. Quarter power = 1 active coil.

The coils are driven basically exactly as they are right now. But each can be 'gated' by a logic signal provided by the Picaxe.

So the Picaxe measures the difference between the required RPM and the actual RPM, then changes one of 4 digital outputs to gate the MOSFETS to increase or decrease the power as required.

If quarter power is still too fast, then you will need switch it off for one rev, then on again. A bit like 50% PWM of quarter power, IE 1/8th power.
 
Last edited:

boriz

Senior Member
Or simpler still. (And I think someone else suggested much the same thing earlier in the thread). To lower the power, just turn the coils off for X number of revs every Y revs.

EG:

To reduce the power by 1/8th, turn the coils off for 1 rev in every 8.
To reduce power by 1/2, turn the coils off for 1 rev in every 2.
etc..

The inertia of the rotor and the load will average the speed so the motor should still run fairly smoothly.

This is an old idea commonly found on early static internal combustion engines.
 

SAborn

Senior Member
Boriz, i still want to know how you would do this switching of the coils while still monitoring the pulsin hall sensor at the same time, because what you suggest is no longer using PWM or any backgroung function, so how can you do coil switching sequences and monitor the inputs without one function effecting the other.
Curious??
 

boriz

Senior Member
Oh. You want some code. Ok.

See post #237 :"The coils are driven basically exactly as they are right now. But each can be 'gated' by a logic signal provided by the Picaxe."

By gated, I mean logic AND with the hall signal.

One possible scheme is a counter that gets incremented every rev by an interrupt from the hall sensor. The main loop monitors the ADC and the counter, gating the MOSFET off for a certain number of counts depending on the required power setting.

So the pseudo code would look something like this:

Code:
:interrupt
inc counter
return

offrevs = 0
do
   for n=1 to 200 (*see note)
      if counter<offrevs then
          turn coils off
      else
          turn coils on
      endif
   next n
   read ADC
   compare adjusted ADC with counter
   adjust offrevs to increase or decrease power
   reset counter
loop
Note. I'm guessing this loop should run for maybe 200mS. So the power update rate is once every 200mS. A compromise between getting a long enough interval for an accurate count and getting a reasonably quick response time. The actual count number will need to be adjusted by experiment to get the required update rate.

By 'adjusted ADC' I mean the raw ADC reading is scaled so it can be compared with the counter. Thus comparing the required revs-per-interval with the actual revs-per-interval.

There's prolly other ways of doing the same thing. Just the first idea I came up with.
 
Top