lower amperage is lower speed? and more.....

hi there

quick question (s)

is it true that when you run a dc motor on lower amerage, that its spins less fast? and can it hurt the motor to do that?

and another one:

are there motorshields that make me able to control 7 pretty stong dc motors (the ones for a car window wiper) and make them move in both directions? if not, what is a good thing to do?

and the last one:

I want to control the position of the dc motor (it only has to turn around 180 degrees), is it a good idea to wire up a potentiometer to the motor to be able to read the position, and then make the motor move to the position I want it to?

that was the last one
thanx in advance....

Very roughly for DC motors: voltage controls speed, current is proportional to torque. This comes directly from the physics.

I doubt you'll find controllers that drive more than 4 motors, and 2 is usual. Several motor controller boards would be needed for 7 motors - unless you design your own board. Still google might find you one if lucky!

And for the last question you have invented the servo motor! And basically yes - sense the position and drive the motor according to the error (difference between desired and actual position).

What mark said. You will need 4 dual 5amp motor controllers. You will attach a potentiometer to each, and feed that back to an analog pin. You will then read that analog pin, which will have the resistive value of the potentiometer, in volt form, and convert that over to degrees of rotation (note: will be different for every pot). From this, you will be able to get a feedback of the position of the motor.

magnethead794:
What mark said. You will need 4 dual 5amp motor controllers. You will attach a potentiometer to each, and feed that back to an analog pin. You will then read that analog pin, which will have the resistive value of the potentiometer, in volt form, and convert that over to degrees of rotation (note: will be different for every pot). From this, you will be able to get a feedback of the position of the motor.

Also - you will need to have a "window" of values around the actual "end point"; actual servos have this, it is called the "dead band" - if your dead band is too small (or non-existant), then the motor will likely "hunt" around for the actual position, as it over and undershoots the position (or if the potentiometer used has low accuracy).

thanx you all! I knew it was a great idea to use a pot! hehhehe!

so if I am actually using big-ass servos, cant I just use the normol servo libary on my arduino?
that'll be nice!

artvantriest:
thanx you all! I knew it was a great idea to use a pot! hehhehe!

so if I am actually using big-ass servos, cant I just use the normol servo libary on my arduino?
that'll be nice!

Not quite. The servo.write() uses a value from -90 to +90 degrees (standard sweep of 180 degrees). The library converts this to the PWM signal required by the servo's onboard controller, which then determines which direction to turn the servo, and it stops when the pot reaches the dead-band for the specified location.

So in essence, you'll be doing that the long way- powering the motor until the pot reaches the dead-band for the target location.

bummer

you know of someone who allready did this?
saves me some time programming...

YES I am lazy..

thnx...

artvantriest:
bummer

you know of someone who allready did this?
saves me some time programming...

YES I am lazy..

thnx...

Actually, if I'm understanding correctly, wouldn't be too hard at all.

You'll be using a motor controlller, easiest way will be to use a PWM method of input to dictate speed and directions. Now, you didn't indicate what you will be using to control the motors.

Keep in mind that you'll still need to use analogRead to get the voltage coming out of the pot, and compare it to the dead band of where you're wanting to go.

Also, keep in mind the deadband req for the code i supply below (no working guarantees, either)

IF you're confused on the OR statements:

If the pot is less than 2.5 volts, it will be out of range. Therefore, you will want it to not be able to go further out of range, only into range. This would be the same direction of travel if it were approaching 4.25 volts.

If the pot is greater than 4.25 volts, it will be out of range. Therefore, you will only want it to be able to go further out of range, only into range. This would be the same direction of travel if it were approaching 2.5 volts.

Note that this method (the only method I can think of ATM), it will get VERY nasty when you start putting deadbands in. I can only hope somebody knows a better way.

Pseudo:

float pot1 = analogRead(voltage input for potentiometer);
float endpoint1 = 4.25; // V=IR, V= 5 volt, R = potentiometer (example is 425 ohms), I = 10mA
float endpoint2 = 2.5; // V=IR, V= 5 volt, R = potentiometer (example is 250 ohms), I = 10mA

void loop(){

if (condition that makes it rotate one direction){

if ((pot1 < endpoint1) || (pot1 < endpoint2)){ // if the pot is less than 4.25 volts OR less than 2.5 volts, motor can turn one direction only
digitalWrite(motordirectionPin, HIGH);
analogWrite(motorspeedPin, pulsewidth); //pulsewidth is from 0-255
} else {
analogWrite(motorspeedPin, 0);
} //endif deadband

} else if ((pot1 > endpoint2 || (pot1 > endpoint1)){ // if the pot is greater than 2.5 volts OR greater than 4.25 volts, motor can turn other direction only

if (we are not yet to the dead-band){
digitalWrite(motordirectionPin, LOW);
analogWrite(motorspeedPin, pulsewidth); //pulsewidth is from 0-255
} else {
analogWrite(motorspeedPin, 0);
} //endif deadband

} else { // If the unexpected happens

digitalWrite(motordirectionPin, LOW);
analogWrite(motorspeedPin, 0);

} //endif rotational direction

} // end loop()

hej magnethead, thanx for your answers

I control the motor by using 3 relais, 2 to switch poles (direction) and one to stop it from turning
I use cases to set the ouputpins on my arduino

and a pot to determine the position
wich works pretty nice

only problem is, i cant figure out how to program a deadband, is there no "between" command :slight_smile:
anybody knows how to program a deadband?

about your programming: is this for the libary or for the normal programming
I dont get the "out of range" part, I mean the pot reads from beginning till end right?
or is it to transfer to pwm, does a dcmotor actually work on pwm?

as you see, I am quite a little bit of a newbie, sorry for that

artvantriest:
only problem is, i cant figure out how to program a deadband, is there no "between" command :slight_smile:
anybody knows how to program a deadband?

Below is the basics of how to implement a "deadband" - note that this code isn't working code, it's just meant as a pseudo-code example:

deadband = 5; // adjust up to widen band, down to narrow it
pot_value = analogRead();

if (pot_value > wantedvalue - deadband) {
  motorccw(); // rotate motor counter-clockwise
}

if (pot_value < wantedvalue + deadband) {
  motorcw(); // rotate motor clockwise
}

Also - the above code would only work if the output shaft (attached to the potentiometer) is moving at a relatively low speed; in a real servo control system, you would use PWM to slow the motor down proportionally once the potentiometer reading is "in the band", and you would widen the band some, and bring the speed down (using PWM) as it approached the "wantedvalue" (which is at the center of the band). Even so, you would still need some kind of gear reduction, because otherwise you will get overshoot and oscillation.

There's also an issue with the above code with getting out of the band once inside it; there's ways around this - I'll leave it to you as an exercise... :slight_smile:

For even more precision, you could go with a PID control (which still needs tuning to prevent oscillation) - but since you are a beginner at this sort of thing, I wouldn't reccommend trying to understand PID until you understand simpler implementations like the above, and the extended version with PWM slowdown.

Note that even a basic servo control system like the pseudo-code above can be accurate enough, depending on the application...

ok i get this... this is easy...

BUT what if the potvalue falls into the deadband, what happens then, will it stand still because it does not turn right nor left?
so i need another case where the 3rd relais is activated

to get out of the deadband, you just change the direction to get into right?

I understand the pwm slowdown but I wouldnt know how to program it, and again, when using pwm, this IS exactly the same as the servo libary, so why wont use it?

PID control, I'll look into it...

It really has nothing to do with the servo library.

The fact that you can communicate with RC type servos through PWM, does not mean you can use the servo library to control DC motors with feedback.

In the case of servos you are using the width of the pulse to communicate a desired position to the servo which then decodes the information and does its own thing to get to the proper position. In the DC motor case you will be varying the duty cycle as a way to provide power to the motor directly.

In the first case you just need to know where you want to go and you ask the servo to go there.

In the second your software will need to know what power needs to be applied to the motor given a current position and desired position, like some of the code provided in this thread.

You say this is easy but I would encourage actually understanding what is going on here before really messing with PID controls, at least the I and D parts as cr0sh's pseudo code is a proportional controller of a sort I guess, just with infinite gain and physical limitations being the only restriction on the output.

artvantriest:
to get out of the deadband, you just change the direction to get into right?

One way is once you are in the "deadband", start incrementing a counter. If the counter gets over some value (before you leave the deadband), stop the motor and reset the counter. When you go to turn the motor in a different direction (because your setpoint changes), its deadband will shift with it - if this new deadband area doesn't overlap the area you're currently end, then there shouldn't be a problem; rotate the motor until in the deadband, then start incrementing again. If there is overlap, though, you would start incrementing again, and as long as your check value isn't bigger than it takes for the motor to get out of the deadband, it will stop again. Note, though, that doing something like this will introduce a margin of error in positioning. Really, the deadband shouldn't be that large anyhow (a fraction of a degree on either side of the wanted position), and as long as you shift greater than the deadband size, the motor will move.

hmm...

been a while, I am sorry, but...

I did not totally understand that...(your last post) I'm quite a newbie.... sorry

I have it working now (the dc motor, switching direction and potentiometer), but I need a deadband of 10 degrees on both sides, wich is pretty big! I am working with 3 relais to switch poles and stop the motor
isnt there a way to "brake" the motor, for example to give it a hit in the opposite direction to make it stop? have you ever done something like that?

and about the speed of the motor, I can just use a transformator to bring down the voltage (and speed) of the motor?