![]() |
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. |
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.)
|
Re: Potentiometer values not changing
Can you post a snippet of your code?
|
Re: Potentiometer values not changing
Code:
Potentiometer* DartPot; |
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? |
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?
|
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.
|
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).
|
Re: Potentiometer values not changing
Yes the else-if is in a while loop.
|
Re: Potentiometer values not changing
Yes the PWM is in analog Channel 2.
|
Re: Potentiometer values not changing
The change in resistance is from between ground and signal. Is this right?
|
Re: Potentiometer values not changing
Quote:
|
Re: Potentiometer values not changing
Code:
While(IsOperatorControl()&& IsEnabled()){ |
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. |
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 02:15. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi