Go Down

Topic: Controlling DC motor (transistor problems solved *Use MOSFETs* (Read 7029 times) previous topic - next topic

polishdude20


There you go :)

Code: [Select]

if  (lval < 250 && rval > 250)
{
  digitalWrite(Lm,HIGH);
  digitalWrite(Rm,LOW);
}
 
else if  (rval < 250 && lval > 250)
{
  digitalWrite(Lm,LOW);
  digitalWrite(Rm,HIGH);
}

what do you want to happen if neither condition is met? Say rval & lvan both < 250,or both >250?
You might want to add some delay to give the motors a chance to spin a little & move some before the next reading comes around.

off to bed for me ...



ok well the code looks like you copied mine from my first post! I'm looking to have the motors spin at the same speed when both sensors are at about the same value. I don't want one to be either off or on but faster and slower.

CrossRoads

500mA - maybe not.
Did you have a chance to measure the impedance of the motor, or how much current it draws?
Most motors have a stall current rating, this is the current from a dead stop of if the motor gets jammed and can't spin. Can bea couple of amps. And then need much less current once they actually get moving.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

jackrae

Quote " yes battery is 9 volts, well ive been using my 9v wall wart "

Contradictory and/or confusing statements and misleading pictures makes it kind of difficult to establish exactly what you meant.

Never the less the comment about high starting current and collapsing supply voltages still stands.

Measuring across the terminals of a DC motor to establish resistance tends to give confusing information as the brush to commutator resistance is liable to change dependent upon numerous variables including commutator stop position, cleanliness of commutator, brush pressure etc.  The stall current is also dependent upon start friction (stiction), shaft load etc

Measure the wallwart output when you are trying to run your motor but before you help them and no doubt you will see where the problem lies. 

jack

polishdude20

#18
Mar 10, 2011, 01:56 am Last Edit: Mar 10, 2011, 02:19 am by polishdude20 Reason: 1
Okay here's what I have discovered!

The forced stopped current (when my hand is preventing it from spinning) is 1.8 - 2 A
The current when I slow the motor down with my hand (simulating ground and wheel pressure?) is at around 600-700mA
The peak current that happens when the motor first starts up is at 1.3A then when it gets to normal operating speed it does about
500mA.

Now I tried this with my teachers 9 volt power supply, my wall wart which is also 9v can only provide 500mA.

I'm planning to use a 6volt battery to power the motors which makes the current a bit lower then.

Lastly,

Good news! I took apart a UPS (i think that's what it's called) and found maybe 7 MOSFETS. I brought 2 with me and this is the part number :  "IRFZ44V"   would those be good?

Oh and I still need to know if I can change the motor speed with the arduino using PWM and the MOSFET?


*Edit*

I connected the MOSFETs and it works! They don't overheat and the motors work fine on the 5v that I give them from the 5v line, it's already USB 5v so the regulator doesnt have to work as hard so t doesn't heat up either.

So now my next endeavor is to use PWM and analog write to control the speed of the motors.

CrossRoads

http://www.irf.com/product-info/datasheets/data/irfz44v.pdf

Well, may be better. Hard to say as Rds is not spec'ed with Vgs at 5V, only for 10V.
Figures 1,2,3 would seem to indicate that Vgs of 5V would allow up to 11A.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

polishdude20


http://www.irf.com/product-info/datasheets/data/irfz44v.pdf

Well, may be better. Hard to say as Rds is not spec'ed with Vgs at 5V, only for 10V.
Figures 1,2,3 would seem to indicate that Vgs of 5V would allow up to 11A.


hey crossroads since our online can you tell me how I can subtract an analog value? Basically one of my sensors gives off about 98 out of 255 and the other shows 110 in the same lighting condition. I want them to be the same so the motor speed is the same when the LDR's are the same.

Here's my code so far. (yes it needs some cleaning

Code: [Select]
/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.

  This example code is in the public domain.
*/
int Lm = 5;
int Rm = 3;
int lval = 0;
int rval = 0;
int Ls = 4;
int Rs = 5;
int lval2;
int rval2;
void setup() {               

  pinMode(Lm, OUTPUT);     
  pinMode(Rm, OUTPUT);   
Serial.begin(9600);
}

void loop() {
 
  lval = analogRead(Ls);
rval = analogRead(Rs);

lval2 = map(lval, 0, 1023, 0, 255);
rval2 = map(rval, 0, 1023, 0, 255);


analogWrite(Rm,rval2);
analogWrite(Lm,lval2);
 

 
 
 


  Serial.println(rval2);

 
 
 
 
}


CrossRoads

just simple math once you have read it in:

lval = analog Read(Ls);
lval = lval-(110-98);
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

polishdude20


just simple math once you have read it in:

lval = analog Read(Ls);
lval = lval-(110-98);



ohok yeah I new you had to subtract the difference but I didn't know how. thanks!

Go Up