Chief Delphi

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

Herbie_3633 07-02-2015 20:17

Potentiometer values not changing
 
We are currently trying to program our potentiometer for our linear actuator. I have verified that the pot is working through tests described in this video.https://www.youtube.com/watch?v=Eh2cQCLie5A

I'm using the ->Get() function to print the values but they stay at or around 30.2711. The PWM cable is plugged in to the analog in slot 2. The pot is the brand Bourns, and the part number is 3590S-2-201L.

Thank you for the help , team 3633.

RufflesRidge 07-02-2015 20:22

Re: Potentiometer values not changing
 
That video doesn't tell us anything about how you have wired the potentiometer or how you are using it in code. Please describe the wiring and provide more details about the code you are using (Potentiometer class or AnalogInput? If Potentiometer, what does your constructor look like? etc.)

Ty Tremblay 07-02-2015 20:22

Re: Potentiometer values not changing
 
Can you post a snippet of your code?

Herbie_3633 07-02-2015 20:31

Re: Potentiometer values not changing
 
Code:

Potentiometer*  DartPot;

public:
        Robot() {
                DartPot = new AnalogPotentiometer(2,360,30);
        }

double pot = DartPot->Get();

else if (stick->GetRawButton(11) == 1){
        std::cout<<("Pot Value: ");
        std::cout<<(pot)<<std::endl;
}

The else if is connected to an if statement in the rest of the code.

RufflesRidge 07-02-2015 20:35

Re: Potentiometer values not changing
 
That snippet doesn't help locate these items within the rest of the code. The methods there look fine, but I can't tell if the Get() call is in a location that will actually update the value.

Assuming it is, how is the pot wired?

Ty Tremblay 07-02-2015 20:35

Re: Potentiometer values not changing
 
What's shown here will only get your potentiometer value once. You need to get your potentiometer value in a loop. Is there a loop somewhere outside your snippet?

Herbie_3633 07-02-2015 20:37

Re: Potentiometer values not changing
 
The pot has 3 connections labeled 1-3. Connection 1 and 3 are connected by a wavy line. Ground is going to terminal 1, red is terminal 3, and signal is terminal 2.

RufflesRidge 07-02-2015 20:40

Re: Potentiometer values not changing
 
That sounds reasonable. Are you sure that you are connected to Analog Channel 2 (the 3rd analog channel, they start at 0).

Herbie_3633 07-02-2015 20:41

Re: Potentiometer values not changing
 
Yes the else-if is in a while loop.

Herbie_3633 07-02-2015 20:42

Re: Potentiometer values not changing
 
Yes the PWM is in analog Channel 2.

Herbie_3633 07-02-2015 20:56

Re: Potentiometer values not changing
 
The change in resistance is from between ground and signal. Is this right?

Alan Anderson 07-02-2015 22:45

Re: Potentiometer values not changing
 
Quote:

Originally Posted by Herbie_3633 (Post 1439974)
Yes the else-if is in a while loop.

That part of the code prints the value of pot. Is there anything in the loop that sets the value? Specifically, do you ever do another DartPot->Get() after you define the variable?

Herbie_3633 07-02-2015 22:56

Re: Potentiometer values not changing
 
Code:

While(IsOperatorControl()&& IsEnabled()){
                double pot = DartPot->Get();

                if(){
                   
                    }

                else if(stick->GetRawButton(1) == 1){
                      std::cout<<(pot)<<std::endl;
              }
}

The above if statement is not relevant to the pot.

Alan Anderson 08-02-2015 00:21

Re: Potentiometer values not changing
 
If I'm reading the C++ standard correctly, the variable pot will be initialized once when the loop begins. It doesn't get reinitialized every iteration of the loop. You can test this by disabling the robot and seeing if the value printed changes when you reenable the robot.

If that happens as I think it will, you should add a line pot = DartPot->Get(); to the loop somewhere before you use the value of pot.

Herbie_3633 08-02-2015 16:00

Re: Potentiometer values not changing
 
I tried putting pot = DartPot->get(); in my while loop and tried using cout to print DartPot->Get() directly (not using a variable) but neither worked.


All times are GMT -5. The time now is 01:44.

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