View Single Post
  #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