Go to Post The only dumb question is the one you don't ask. - E. Wood [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 07-02-2015, 20:17
Herbie_3633 Herbie_3633 is offline
Registered User
FRC #3633
 
Join Date: Jan 2013
Location: Albert lea
Posts: 26
Herbie_3633 is infamous around these partsHerbie_3633 is infamous around these parts
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.
  #2   Spotlight this post!  
Unread 07-02-2015, 20:22
RufflesRidge RufflesRidge is offline
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 989
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
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.)
  #3   Spotlight this post!  
Unread 07-02-2015, 20:37
Herbie_3633 Herbie_3633 is offline
Registered User
FRC #3633
 
Join Date: Jan 2013
Location: Albert lea
Posts: 26
Herbie_3633 is infamous around these partsHerbie_3633 is infamous around these parts
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.
  #4   Spotlight this post!  
Unread 07-02-2015, 20:40
RufflesRidge RufflesRidge is offline
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 989
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
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).
  #5   Spotlight this post!  
Unread 07-02-2015, 20:42
Herbie_3633 Herbie_3633 is offline
Registered User
FRC #3633
 
Join Date: Jan 2013
Location: Albert lea
Posts: 26
Herbie_3633 is infamous around these partsHerbie_3633 is infamous around these parts
Re: Potentiometer values not changing

Yes the PWM is in analog Channel 2.
  #6   Spotlight this post!  
Unread 07-02-2015, 20:56
Herbie_3633 Herbie_3633 is offline
Registered User
FRC #3633
 
Join Date: Jan 2013
Location: Albert lea
Posts: 26
Herbie_3633 is infamous around these partsHerbie_3633 is infamous around these parts
Re: Potentiometer values not changing

The change in resistance is from between ground and signal. Is this right?
  #7   Spotlight this post!  
Unread 07-02-2015, 20:22
Ty Tremblay's Avatar
Ty Tremblay Ty Tremblay is offline
Robotics Engineer
FRC #0319 (Big Bad Bob)
Team Role: Mentor
 
Join Date: Feb 2006
Rookie Year: 2004
Location: Alton NH
Posts: 832
Ty Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond repute
Re: Potentiometer values not changing

Can you post a snippet of your code?
__________________
  #8   Spotlight this post!  
Unread 07-02-2015, 20:31
Herbie_3633 Herbie_3633 is offline
Registered User
FRC #3633
 
Join Date: Jan 2013
Location: Albert lea
Posts: 26
Herbie_3633 is infamous around these partsHerbie_3633 is infamous around these parts
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.
  #9   Spotlight this post!  
Unread 07-02-2015, 20:35
RufflesRidge RufflesRidge is offline
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 989
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
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?
  #10   Spotlight this post!  
Unread 07-02-2015, 20:35
Ty Tremblay's Avatar
Ty Tremblay Ty Tremblay is offline
Robotics Engineer
FRC #0319 (Big Bad Bob)
Team Role: Mentor
 
Join Date: Feb 2006
Rookie Year: 2004
Location: Alton NH
Posts: 832
Ty Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond repute
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?
__________________

Last edited by Ty Tremblay : 07-02-2015 at 20:39.
  #11   Spotlight this post!  
Unread 07-02-2015, 20:41
Herbie_3633 Herbie_3633 is offline
Registered User
FRC #3633
 
Join Date: Jan 2013
Location: Albert lea
Posts: 26
Herbie_3633 is infamous around these partsHerbie_3633 is infamous around these parts
Re: Potentiometer values not changing

Yes the else-if is in a while loop.
  #12   Spotlight this post!  
Unread 07-02-2015, 22:45
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Potentiometer values not changing

Quote:
Originally Posted by Herbie_3633 View Post
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?
  #13   Spotlight this post!  
Unread 07-02-2015, 22:56
Herbie_3633 Herbie_3633 is offline
Registered User
FRC #3633
 
Join Date: Jan 2013
Location: Albert lea
Posts: 26
Herbie_3633 is infamous around these partsHerbie_3633 is infamous around these parts
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.
  #14   Spotlight this post!  
Unread 08-02-2015, 00:21
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
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.
  #15   Spotlight this post!  
Unread 08-02-2015, 16:00
Herbie_3633 Herbie_3633 is offline
Registered User
FRC #3633
 
Join Date: Jan 2013
Location: Albert lea
Posts: 26
Herbie_3633 is infamous around these partsHerbie_3633 is infamous around these parts
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.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


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

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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