View Single Post
  #2   Spotlight this post!  
Unread 18-02-2005, 00:49
JoelP JoelP is offline
whats the P for? Pazhayampallil
FRC #1155 (Bronx Science Sciborgs)
Team Role: Leadership
 
Join Date: Dec 2004
Rookie Year: 2005
Location: bronx, new york
Posts: 62
JoelP is a jewel in the roughJoelP is a jewel in the roughJoelP is a jewel in the rough
Send a message via AIM to JoelP
Re: Programming of Pneumatics

What you have to do in the code is put in an if statement that will switch between the 2 positions on the pneumatics, but since the loop executes every 26ms(approx.) you'll also need to include a latch to prevent this.

The following code is similar to what my team did for this:
Code:
  if(p1_sw_top == 1 && button_latch==0) //button_latch is a variable to
// prevent the code from rapidly cycling through piston positions
  {
	if(relay1_rev==1)//if the relay is reversed it will switch to forward
	{
	  relay1_fwd=1;
	  relay1_rev=0;
	  button_latch=1;
	}
	else          //and vice versa
	{
	  relay1_fwd=0;
	  relay1_rev=1;
	  button_latch=1;//latches to prevent cycling
	}
  }
  else if(p1_sw_top == 0 && button_latch==1)
  {
	button_latch=0;//resets latch when you let go of the button
  }

Last edited by JoelP : 18-02-2005 at 00:52.