Go to Post Just so you don't spend too much time on non-clues ... now you can all go back to the real one! :D - Libby K [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 11-03-2012, 00:12
pickett pickett is offline
Registered User
FRC #0519
 
Join Date: Feb 2012
Rookie Year: 2003
Location: Michigan
Posts: 7
pickett is an unknown quantity at this point
how to creat a home button

can some on help explain how to use a potentiometer connected to turret to create a button that once press returns the turret to a set home position on and stops. or any other way that would work
Reply With Quote
  #2   Spotlight this post!  
Unread 11-03-2012, 00:33
seg9585's Avatar
seg9585 seg9585 is offline
Registered User
AKA: Eric
FRC #4276 (Surf City Vikings)
Team Role: Engineer
 
Join Date: Feb 2006
Rookie Year: 2001
Location: Boeing (Seal Beach, CA)
Posts: 520
seg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond repute
Re: how to creat a home button

Use a button on your controller to start a Routine in the Periodic Task vi. The Periodic Task routine would use a loop to check the current potentiometer value and drive the motor in the direction/speed the turret needs to move until the desired pot value is reached. This would require a PID loop, but if your turret is single-speed and you don't care about a small offset, using the potentiometer feedback just as a directional indicator would do "good enough".

To translate the above, let me describe how I would implement in code:

- In Teleop VI, use a feedback register such that when the desired button is pressed, if this is greater than the register, include within a Case Structure a global variable boolean ("TurretHomeEnabled", for example) set to True. What I described is a "WhenPressed" case.

- In Periodic Task, include an endless loop that constantly checks for your global variable. If True, check the current pot value and drive the motor accordingly. If the pot value matches your specified "Home" value with a tolerance, stop driving the motor and then set the global boolean to False.

If what I'm describing still sounds confusing, let me know and I can probably find you some example screenshots.
__________________
My FIRST legacy:

Team 204 Student 2001, 2002 (Voorhees, NJ)
Team 1493 College Mentor 2006 - 2008 (Troy, NY)
Team 2150 Intern/Professional Mentor 2007, 2009 (Palos Verdes)
Team 4123 Lead Engineering Mentor 2012 (Bellflower, CA)
Team 4276 Engineering Mentor 2012-2016 (Huntington Beach, CA)
Reply With Quote
  #3   Spotlight this post!  
Unread 11-03-2012, 00:43
pickett pickett is offline
Registered User
FRC #0519
 
Join Date: Feb 2012
Rookie Year: 2003
Location: Michigan
Posts: 7
pickett is an unknown quantity at this point
Re: how to creat a home button

Thanks I will try it tomorrow. If you could post some screen shots that would be great
Reply With Quote
  #4   Spotlight this post!  
Unread 11-03-2012, 18:49
pickett pickett is offline
Registered User
FRC #0519
 
Join Date: Feb 2012
Rookie Year: 2003
Location: Michigan
Posts: 7
pickett is an unknown quantity at this point
Re: how to creat a home button

I am having trouble getting the potentiometer to work. when I run the code the window motor hooked up to the turret runs continuously in on direction. can some on take a look at my code attached below?

I am looking to control the turrets turn radius and create a home button.
Attached Thumbnails
Click image for larger version

Name:	code for pot.PNG
Views:	34
Size:	21.8 KB
ID:	12281  
Reply With Quote
  #5   Spotlight this post!  
Unread 11-03-2012, 19:22
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,833
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: how to creat a home button

You may be running away from your setpoint if the motor and the pot are reversed and returning the opposite of what the code is expecting. Your max and min may be reversed.

You can use a probe running in debug to see if the actual pot value is getting further from the setpoint as you run.

A simple test is to reverse or negate (-x) the output of the PID icon for the motor set.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
Reply With Quote
  #6   Spotlight this post!  
Unread 12-03-2012, 20:52
seg9585's Avatar
seg9585 seg9585 is offline
Registered User
AKA: Eric
FRC #4276 (Surf City Vikings)
Team Role: Engineer
 
Join Date: Feb 2006
Rookie Year: 2001
Location: Boeing (Seal Beach, CA)
Posts: 520
seg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond repute
Re: how to creat a home button

Quote:
Originally Posted by pickett View Post
I am having trouble getting the potentiometer to work. when I run the code the window motor hooked up to the turret runs continuously in on direction. can some on take a look at my code attached below?

I am looking to control the turrets turn radius and create a home button.
I'm trying to interpret exactly what are are looking to do with Button 4 and Button 5.
As-is:
It appears that when nothing is pressed, the PID target is always 1.17 (pot min)
When Button 4 is pressed, the PID target becomes 3.9 (pot max)
When Button 5 is pressed, the PID target becomes -(3.9 - 1.17) + 1.17 = -1.56 (out of range)


For this "Home" button are you trying to drive to a mid-value?
If so, when a button is pressed, you should be setting the setpoint to [(3.9-1.17)/2]. You can just put this into a Case structure where the selected Button determines the Case, and if True, run the PID loop. If false, use your other turret logic to specify your motor power.

If this is not what you are trying to do, please describe explicitly your desired function (what you want each button to do, etc).
__________________
My FIRST legacy:

Team 204 Student 2001, 2002 (Voorhees, NJ)
Team 1493 College Mentor 2006 - 2008 (Troy, NY)
Team 2150 Intern/Professional Mentor 2007, 2009 (Palos Verdes)
Team 4123 Lead Engineering Mentor 2012 (Bellflower, CA)
Team 4276 Engineering Mentor 2012-2016 (Huntington Beach, CA)
Reply With Quote
  #7   Spotlight this post!  
Unread 12-03-2012, 21:41
pickett pickett is offline
Registered User
FRC #0519
 
Join Date: Feb 2012
Rookie Year: 2003
Location: Michigan
Posts: 7
pickett is an unknown quantity at this point
Re: how to creat a home button

Quote:
Originally Posted by seg9585 View Post
I'm trying to interpret exactly what are are looking to do with Button 4 and Button 5.
As-is:
It appears that when nothing is pressed, the PID target is always 1.17 (pot min)
When Button 4 is pressed, the PID target becomes 3.9 (pot max)
When Button 5 is pressed, the PID target becomes -(3.9 - 1.17) + 1.17 = -1.56 (out of range)


For this "Home" button are you trying to drive to a mid-value?
If so, when a button is pressed, you should be setting the setpoint to [(3.9-1.17)/2]. You can just put this into a Case structure where the selected Button determines the Case, and if True, run the PID loop. If false, use your other turret logic to specify your motor power.

If this is not what you are trying to do, please describe explicitly your desired function (what you want each button to do, etc).
What i want to do is when button 5 is pressed the turret to turn from a range 0 (0 being my home position ) to 90 degrees to the right and button 4 to do the same in the opposite direction

For the home button i want to be able to push a button and no matter were the turret is it returns to home position automatically when button is pressed.

Last edited by pickett : 12-03-2012 at 21:53.
Reply With Quote
  #8   Spotlight this post!  
Unread 13-03-2012, 03:05
seg9585's Avatar
seg9585 seg9585 is offline
Registered User
AKA: Eric
FRC #4276 (Surf City Vikings)
Team Role: Engineer
 
Join Date: Feb 2006
Rookie Year: 2001
Location: Boeing (Seal Beach, CA)
Posts: 520
seg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond repute
Re: how to creat a home button

Pickett --

See attached .vi I created which should do what you're looking for. Note that there are a lot of different ways to perform the same task in code, and the way I wrote this is just one example (the way I would write it).

First off, I am converting the voltage from your pot to an actual angle (by scaling against the min/max values). The output is a value of 0 to your turret limit. I like working with positive numbers rather than using "0" as a home position. Instead, 0 represents one limit, and the Range represents the other limit.

Then I check to see which buttons are being held down -- If button 4, set the setpoint to 0 deg. If button 5, set the setpoint to 180 deg. If button 6 ("home button"), set the setpoint to 90 deg. You would have to change these values based on your actual desired setpoints.

If no buttons are being pressed, the setpoint is your current position. That would tell the PID loop to stop moving the motor.

Remember to put all this within a loop, such as in Periodic Task (or Teleop)

Let me know if this helps...
Attached Files
File Type: vi TurretSetPoints.vi (18.5 KB, 9 views)
__________________
My FIRST legacy:

Team 204 Student 2001, 2002 (Voorhees, NJ)
Team 1493 College Mentor 2006 - 2008 (Troy, NY)
Team 2150 Intern/Professional Mentor 2007, 2009 (Palos Verdes)
Team 4123 Lead Engineering Mentor 2012 (Bellflower, CA)
Team 4276 Engineering Mentor 2012-2016 (Huntington Beach, CA)
Reply With Quote
Reply


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 22:08.

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