View Single Post
  #4   Spotlight this post!  
Unread 04-02-2009, 15:51
Dave Scheck's Avatar
Dave Scheck Dave Scheck is offline
Registered User
FRC #0111 (WildStang)
Team Role: Engineer
 
Join Date: Feb 2003
Rookie Year: 2002
Location: Arlington Heights, IL
Posts: 574
Dave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond repute
Re: Limit Switchers Logic Problem

The problem that you're describing is more complex and probably shouldn't be done the way your code is laid out. The reason I say this is that you have 3 blocks that are affecting the same output. In order to do what you want the program to do, you'll need to look at the 3 buttons and 2 switches and make a decision on what to do to the output.

I think this is the logic that you want to use. Note that based on the inputs we calculate a state and store it into a persistent variable called state. Then at the end, we look at state and write the output.
Code:
IF left is pressed
    IF left limit switch is pressed
        state = MOVE_STOP
    else
        state = MOVE_LEFT
ELSE IF right is pressed
    IF right limit switch is pressed
        state = MOVE_STOP
    else
        state = MOVE_RIGHT
ELSE IF stop is pressed
    state = MOVE_STOP
ELSE
    // No change to state

IF state is MOVE_LEFT
    output = MOVE_LEFT_SPEED
ELSE IF state is MOVE_RIGHT
    output = MOVE_RIGHT_SPEED
ELSE
    output = 0
I work predominantly in C and C++, so my Labview terminology and logic isn't the best. I'm sure there are people around that can help you with the implementation side of things. I would suggest reading through the logic and understanding what it does. Only then should you try to implement something like that.