View Single Post
  #6   Spotlight this post!  
Unread 13-02-2013, 15:37
Omar's Avatar
Omar Omar is offline
Registered User
no team
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2008
Location: Huntsville, AL
Posts: 122
Omar is a glorious beacon of lightOmar is a glorious beacon of lightOmar is a glorious beacon of lightOmar is a glorious beacon of lightOmar is a glorious beacon of light
Re: Shooter Lifting Code

Can you tell what your Current Level is just by reading all the DIO?
Potentiometer would be better for position feed then the limit switch as it will give you continuous read on your position

No loops in Teleop
Read Distance “calculate” DesiredLevel
Read the DIOs “calculate” CurrentLevel

If CurrentLevel = DesiredLevel then write 0 out to Lift Motor
If CurrentLevel > DesiredLevel then write -20 out to Lift Motor
If CurrentLevel < DesiredLevel then write +20 out to Lift Motor
NO LOOP
The Teleop loop will loop around and you get to do it all over again.
As long as CurrentLevel < DesiredLevel the motor goes up
As long as CurrentLevel > DesiredLevel the motor goes down

Each time through Teleop you check CurrentLevel and compare it to DesiredLevel.

You can put this all in a case structure and enable or disable with the toggle I sent you earlier.

Again from my question asked early, Can you always tell your Current Level by the limit switches alone?
Or do you have positions in between

If you can not always tell your position then you will have to maintain the level in some kind of state machine.
__________________
Omar
Reply With Quote