Pages: [1] 2   Go Down
Author Topic: Potentiometer Controlled Motor with Feedback  (Read 2283 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So, here's my question. I have searched the forums for topics related to what I am attempting, but I have not succeeded in finding anything. Essentially what I want to make is a potentiometer controlled servo manipulator (which I have used before), but rather than the output being a PWM signal telling a servo what to do (based on the voltage divider setup of the controlling potentiometer into an analog pin), I want the output instead to be a fwd/rev output at two pins which in turn control a motor through an H-bridge. The shaft of the motor would be hooked up to a feedback pot. which is set up much like the original controlling pot, but serves as a reference for the Arduino to measure against so it can match the input pot. with the output pot., which in turn matches the angle of the input with the angle of the output, thereby making the Arduino act as a high power servo. Any suggestions or code that you guys can come up with would be great, as I am just beginning to experiment with coding.

-Betelgeuse150
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26490
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Have you looked at the examples in the Playground?
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Malaysia
Offline Offline
Sr. Member
****
Karma: 7
Posts: 393
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am really interested in your project. well from what i can say is that your now trying to make a diy servo with a dc motor and a potentiometer?
urm what kind of circuit are you using rite now? i really like to see that for me to know what kind of control u would need. but if i may i would like to suggest to you this kind of circuit

http://www.societyofrobots.com/member_tutorials/book/export/html/159

use the one in the middle of the page call

3.1 - 600mA DC motor controller, up to 36v

that circuit only use 2 pin to control a motor.


ouh wait when i read your post again it means that your already about tri state H brige.

so could you explain abit more about your project
Logged

Malaysia
Offline Offline
Sr. Member
****
Karma: 7
Posts: 393
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i dont really get about your project description
i mean i get that you have one Hbridge circuit, 1 motor and 2 potentiometer. and arduino rite
i know that your set up is so that the arduino will give the signal to the h bridge to move the motor,
and by hooking up one of the pot to a output shaft of the motor, you are essentially making a close loop control to the motor where by the the output of the potentiometer is being monitored by the arduino.
what is the purpose of the second potentiometer?
Logged

Malaysia
Offline Offline
Sr. Member
****
Karma: 7
Posts: 393
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ok now i understand. basically you want to make the second potentiometer as a knob you would control this making is almost like the knob example like the one that the arduino IDE gave in its servo sample. Am i correct about this?

well if this what you one i am gonna give you some hints...
1)set the middle value of both pot.
2)determine which part of the value will make the motor turn clockwise or anticlockwise
3) compare the value of both pot
4) the difference between the pot could be use as to determine the speed
5) decide on what type of breaking you want to use
6) if both pot is the same value then the motor should stop.
7) if you could use PID control /fuzzy control would be great.
please keep me updated with your progress..
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you ash901226, I think your suggestion will help. I have attached a drawing describing what it is I am making.


* Drawing.png (102.27 KB, 1104x1235 - viewed 99 times.)
« Last Edit: November 22, 2012, 01:53:44 am by Betelgeuse150 » Logged

Malaysia
Offline Offline
Sr. Member
****
Karma: 7
Posts: 393
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

well ok, your drawing is consistent with my imagination of your project...
urm.. does your motor need to have a speed control with it or just a simple full speed ahead kinda thing?
Logged

Malaysia
Offline Offline
Sr. Member
****
Karma: 7
Posts: 393
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You know since i read about your post, it got me thinking about how to make the project. it seem to me that the electronic side of it you may or may not have got it covered but what im trying to do now is to make the code side.

urm the way i see it is that first both pot value must be known. actually in my lasted opinion now is that you do not need to know the center for the pot. but what we are truly interested is by how much the position differ...

urm maybe be it could be like this

Code:
int I  =analogRead(POT1);
int K  =analogRead(POT2);
if ( I==K )
{
 //fill in how you would want to stop your motor.
}
else
 {
   if ( I > K )
{
  // maybe turn your motor clockwise
}
   if ( I<K)
{//maybe turn your motor anticlockwise
}
}

the code above is just an example. how ever this assume that the motor would be driven at full speed in either direction. this setup will make the motor overshoot but over time it will reach a stable position.

try to minimize this overshoot with PID control or even fuzzy control.
You know when i think about its a simple speed ramp control might just do the trick... urm maybe a trapezoidal speed ramp?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, the motor would be a low-RPM motor, possibly around 40 or so, so that the setup would be more stable. For the steps for the code, I was planning something along the lines of this:
1) Read input pot value
2) Read output pot value
3) If different: proceed. If similar, delay ~10 ms and then repeat.
4) Output to fwd pin, delay ~10 ms
5) Read pot. values.
6) If pots similar, stop, delay ~10 ms, then go back to beginning. If different, proceed.
7) If difference in pot. values has decreased, continue with fwd output, delay ~10 ms, then go back to beginning. If increase in difference, proceed.
8 ) Stop output to fwd pin, read input and output pot. values.
9) Output to reverse pin. Delay ~10 ms.
10) Read pot. values.
11) If values similar, stop, go back to beginning. If values different, proceed.
12) If difference has decreased since the most recent read, proceed. If the difference has increased, go back to beginning.
13) Output to rev. pin. Delay ~10 ms, then go back to 10.

Would something like this work? I am attempting to write the code such that the code wouldn't have to know specific directions for the motor, so that if one motor turns one way from a fwd input and another motor turns the opposite way from the same input, the arduino would compensate. I understand the methodical nature of the logic behind coding things, but I have a hard time knowing what to write for the code.
« Last Edit: November 23, 2012, 12:56:19 pm by Betelgeuse150 » Logged

Malaysia
Offline Offline
Sr. Member
****
Karma: 7
Posts: 393
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

well the idea that you want to do is something that most of us, well at least the people i know would want to do. and yes the way you want to program is consistent with the behavior you would like to achieve. but way i suggest a different way?

how about in the setup area you make a code that turn the motor slightly, and monitor the changing value of the pot. for instant, if the motor rotate clockwise the value increase then some setting is set as high, and if the motor rotate clockwise but the value decrease then the some setting is set low. this way your motor will have to be calibrated only once each time the code run. thus could make your project more efficient .
Logged

Malaysia
Offline Offline
Sr. Member
****
Karma: 7
Posts: 393
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

urm maybe one of the possible code

Code:
boolean Set;
void setup()
{

  pinMode(pot1, INPUT);
  pinMode(Mtr , OUTPUT);
  int A=digitalRead(pot1);
  digitalWrite(Mtr,HIGH);
  delay (100);
  digitalWrite(Mtr, LOW);
  int B=digitalRead(pot1);
  if (A > B ) Set =HIGH;
  if (A< B) Set = LOW;
}
void loop()
 {
   if (Set == HIGH);
   {// fill your code here
    }
    if ( Set == LOW);
    { //
     }
}
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26490
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
if (Set == HIGH);
Maybe not.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Malaysia
Offline Offline
Sr. Member
****
Karma: 7
Posts: 393
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks AWOL i didnt notice that
it should have been
Code:
if (Set == HIGH)
{
}

Thanks again
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I like the idea. So only when the arduino is turned on does the motor calibrate, making everything simpler. In terms of the speed of the motor it would be good to have it slow as it approaches equilibrium. The output to the fwd. or rev. inputs of the H-Bridge would have to be PWM, so how would I go about coding the output signal such that as the difference between the two pots decreased the ratio of high to low time of the pulse decreased as well (effectively slowing the speed of the motor)?
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26490
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
how would I go about coding the output signal such that as the difference between the two pots decreased the ratio of high to low time of the pulse decreased as well (effectively slowing the speed of the motor)?
A first stab at the problem might use the map function
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Pages: [1] 2   Go Up
Jump to: