View Single Post
  #2   Spotlight this post!  
Unread 11-04-2009, 17:18
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,751
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Momentary On/Off

From what I understand, you want a button press to trigger an action of turning on the motor for x seconds. It will stay there until the button is released, then a new action will run to negate the other movement. The reason I review is that a short click and release will then go through both actions with nothing in between? No canceling the first movement? You also need to decide what happens when the driver clicks and releases multiple times rapidly -- one movement or N movements, one for each click.

If my understanding is reasonably close to what you want, look up LabVIEW examples for state machines. I'll name the motor positions home and engaged. You state machine has states of Home, Engaging, Engaged, Disengaging.

From home, a button press moves to Engaging. Time moves from Engaging to Engaging. A button release or pending one moved from Engaged to Disengaging. Time moves from DisEngaging to Home.

I'd set up a periodic task that runs the motor for time and contains the state variable. You can read the joystick button state in that loop at a given rate, or you can leave it in your teleop code and update a local or global that indicates the position of the button, up or down.

Hopefully this helps you think about how to approach the problem. I'll leave the rest to you.
Greg McKaskle
Reply With Quote