Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Potentiometer PID (http://www.chiefdelphi.com/forums/showthread.php?t=51653)

Kingofl337 20-01-2007 20:39

Re: Potentiometer PID
 
Any 100K Pot will work for most arms a single turn will work. Digikey.com and Mouser.com have parts for 100K 10 turn but you loose some resolution using a 10 turn. I haven't found any 2 turn 100K pots.

DonRotolo 20-01-2007 22:56

Re: Potentiometer PID
 
We had some awful results 2 years ago with 100k pots on the robot. Last year we used 5k pots on the robot and had great success. I attibute the difference to noise and a close match to the input impedance of the ADC circuit.

Am I crazy?

Don

NextPerception 21-01-2007 02:41

Re: Potentiometer PID
 
instead of

Code:

      if ( Button1 == 1 )
      {
            Target = 200 ;
      }
      else if ( Button2 == 1 )
      {
            Target = 400 ;
      }
      else if ( Button3 == 1 )
      {
            Target = 600 ;
      }

i would do this

Code:

      if ( (Button1 * Button2) + (Button2 * Button3) + (Button3 * Button1) + ( Button1 + Button2 + Button3 ) == 1 )  //prevents crazy values if more than one button is pressed and keeps the same value if no button is pressed
      {
            Target = (Button1 * 200) + (Button2 * 400) + (Button3 * 600)
      }

this just makes more sense to me and I just post it here for any like minded people out there. I think it takes a little less cpu time too.

Joel J 21-01-2007 02:43

Re: Potentiometer PID
 
Quote:

Originally Posted by Don Rotolo (Post 561575)
We had some awful results 2 years ago with 100k pots on the robot. Last year we used 5k pots on the robot and had great success. I attibute the difference to noise and a close match to the input impedance of the ADC circuit.

Am I crazy?

Don

You aren't crazy. Those ADC inputs on the RC are rated for not much more than 2.5K. You should use a 1 or 2K pot when connecting to the RC. For the OI you'll need a 100K pot.

Bourns makes the "good stuff." Avoid radioshack's potentiometers :).

Alan Anderson 21-01-2007 11:03

Re: Potentiometer PID
 
Quote:

Originally Posted by NextPerception (Post 561706)
i would do this

Code:

      if ( (Button1 * Button2) + (Button2 * Button3) + (Button3 * Button1) + ( Button1 + Button2 + Button3 ) == 1 )  //prevents crazy values if more than one button is pressed and keeps the same value if no button is pressed
      {
            Target = (Button1 * 200) + (Button2 * 400) + (Button3 * 600)
      }

this just makes more sense to me and I just post it here for any like minded people out there. I think it takes a little less cpu time too.

It makes sense if you're averse to using procedural programming and prefer functional programming. The logic behind your code gives the same result as the one using if statements, but the reason for doing it that way is obscure to anyone encountering it cold.

And it takes a lot more time to do it your way. A few comparisons and branches are faster than many multiplications and additions. Note that the original code never does more than three comparisons and one assignment. Yours always does six multiplications, thirteen additions, and one comparison. It would be instructive to compile both alternatives and compare the generated assembly language code in the listing file.

As an aside, wouldn't it work just as well to simplify the condition to this?
Code:

if ( ( Button1 + Button2 + Button3 ) == 1 )

NextPerception 21-01-2007 16:59

Re: Potentiometer PID
 
Quote:

Originally Posted by Alan Anderson (Post 561786)
It makes sense if you're averse to using procedural programming and prefer functional programming. The logic behind your code gives the same result as the one using if statements, but the reason for doing it that way is obscure to anyone encountering it cold.

And it takes a lot more time to do it your way. A few comparisons and branches are faster than many multiplications and additions. Note that the original code never does more than three comparisons and one assignment. Yours always does six multiplications, thirteen additions, and one comparison. It would be instructive to compile both alternatives and compare the generated assembly language code in the listing file.

As an aside, wouldn't it work just as well to simplify the condition to this?
Code:

if ( ( Button1 + Button2 + Button3 ) == 1 )

hahaha
wow. this is what no sleep does to you.
thanks for that.
maybe I just think weird or something

Chris1228 09-02-2008 21:37

Re: Potentiometer PID
 
how do u get pot sensors to work on easy c?

Kingofl337 11-02-2008 13:30

Re: Potentiometer PID
 
1 Attachment(s)
The Analog Input block,

The Analog Input function block allows the user to define behavior based on signals from any analog sensor. Analog sensors provide a range of feedback with the range depending on the actual sensor being used. This generic input can be used with any Analog device of your choosing.

Tom Bottiglieri 11-02-2008 14:48

Re: Potentiometer PID
 
Quote:

Originally Posted by Joe Johnson (Post 555147)
*if you have a PID control you are living on the edge if you don't have routines in your C code called "JustEnabled" and "justDisabled" You should have those routines anyway but you REALLY need them with PID control. JJ

I can't agree more. We just call our controllers when the robot is enabled. Dead simple and works great.

Uberbots 11-02-2008 15:28

Re: Potentiometer PID
 
Quote:

Originally Posted by NextPerception (Post 561968)
hahaha
wow. this is what no sleep does to you.
thanks for that.
maybe I just think weird or something

I think the same way... and so therefore there is no official programming mentor who actually looks over my code anymore (=

i would advise against using a pot for PID control, because the pot will always be returning to the same position, and the brush inside the pot will wear down on the resistive material, which would sacrifice the signal's validity. Im not saying that something like a joystick wouldnt do this, but a joystick is a lot more replaceable than a robot.

Mike AA 15-02-2008 18:33

Re: Potentiometer PID
 
I guess I am comfused and I have been trying to get an idea on all this. I wish to be able to move the joystick to say a value of 200, then I want on the robot a motor to turn an arm until it also reads another pot at the same angle.

Example:
Joystick tilted slightly forward, thus arm tilted slightly down.

I cant figure out do I use a PID loop or do I just get creative with some other code or use a table? In the past I would just use limit switched but II want better control this year and a more varied location.

-Mike

jgannon 15-02-2008 19:05

Re: Potentiometer PID
 
Quote:

Originally Posted by Mike AA (Post 699735)
I wish to be able to move the joystick to say a value of 200, then I want on the robot a motor to turn an arm until it also reads another pot at the same angle.

Use the sample code that has been bandied about in this thread, but instead of setting Target with conditionals and hardcoded values, just set Target equal to the value coming in from your joystick axis, or some function of that value (for instance, target=p1_y*4; would give you access to the full range of the pot). Does that make sense?

Mike AA 15-02-2008 23:03

Re: Potentiometer PID
 
Do I have to use Kevin's ADC code added somewhere within my code or could I just copy the code from Dustinb_3?

Any help is greatly appreciated the robot is about done but we've been busy on that and waited til the last minute to work on completing the code.

-Mike

Uberbots 15-02-2008 23:18

Re: Potentiometer PID
 
Quote:

Originally Posted by Mike AA (Post 699735)
I guess I am comfused and I have been trying to get an idea on all this. I wish to be able to move the joystick to say a value of 200, then I want on the robot a motor to turn an arm until it also reads another pot at the same angle.

Example:
Joystick tilted slightly forward, thus arm tilted slightly down.

I cant figure out do I use a PID loop or do I just get creative with some other code or use a table? In the past I would just use limit switched but II want better control this year and a more varied location.

-Mike

Do a simple proportional control...

Code:

arm_motor = (arm_pot - p1_y) * 50;
dont multiply by 50, multiply by something that actually makes the arm move smoothly.


All times are GMT -5. The time now is 20:55.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi