View Single Post
  #6   Spotlight this post!  
Unread 23-02-2009, 12:19
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,112
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: Moving Camera Servos With Joystick Button

Quote:
Originally Posted by Luke Pike View Post
I would check the time and only do the servo code when a certain amount of time has passed.
It might be easier to learn how to use a feedback node to remember what the state of the joystick button was the previous time through the code. I don't have a copy of LabVIEW available, so I'll see what I can do to describe a good way to react just once to a joystick button being pressed.

Wire the Joystick Get "Buttons" output to an "Unbundle by name" and select the desired button from the unbundle's popup menu.
Wire the unbundle's boolean output to one input of a boolean And gate, and also to the input to a feedback node.
Wire the output of the feedback node to a boolean Not.
Wire the output of the boolean Not to the other input of the boolean And.

The output of the boolan And will be true only during the single loop when the joystick button has changed from false to true.

You can use that single-time signal as the select input to a Case structure which passes a numeric input straight through to its output when false, and increments it by one when true.

Duplicate this entire process for another joystick input and another Case that decrements the numeric value.

Wire a numeric value through both Case structures and a shift register on the surrounding While loop. That way the joystick buttons will bump the value up or down by one each time one gets pressed. Use that value as the input to the Servo Set Angle. If you feel like it, run the value through a range check and coerce on its way through the process so that it never exceeds the proper range for a servo angle.
Reply With Quote