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