Thread: Pneumatics Code
View Single Post
  #2   Spotlight this post!  
Unread 10-10-2009, 10:25
Lord_Jeremy's Avatar
Lord_Jeremy Lord_Jeremy is offline
Lord_Jeremy the Procrastinator
AKA: Jeremy Agostino
FRC #1546 (Chaos Inc.)
Team Role: Electrical
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Baldwin, New York
Posts: 45
Lord_Jeremy is an unknown quantity at this point
Send a message via ICQ to Lord_Jeremy Send a message via AIM to Lord_Jeremy Send a message via MSN to Lord_Jeremy Send a message via Yahoo to Lord_Jeremy
Re: Pneumatics Code

Hey. Admittedly I don't have too much experience programming for the new control system (I was delegated to electronics this past year), but a couple things look kind of fishy. First of all, I don't think you're supposed to be disabling the Watchdog like that. From what I remember of the documentation and example code, you should be Feed()ing it. Also, I don't think doing
Code:
turret.Set(1)
and then
Code:
turret.Set(0)
on the next line will make it fire. The way I see it, there are a couple ways to get this to do what you want. The first way would be to just do
Code:
turret.Set(manipulator.GetRawButton(1))
so that it fires the solenoid when you press the button. I'm assuming you're using a Festo single-solenoid valve, of course. The other way would be to write it so that when you press the button, it sets the solenoid to 1 and then starts a counter. Then, when the counter reaches 0, it sets the solenoid to 0. It could probably look like this
Code:
int shootercounter

void Pneumatics()
{
	if( shootercounter > 0 )
		shootercounter--	//decrement the counter
	else
		turret.Set(0);	//close the valve

	if( manipulator.GetRawButton(1) )
	{
		//open the valve for 200 cycles
		shootercounter = 200;
		turret.Set(1);
	}
}
Though there's definitely a better way to do it with timers, I'm not sure how to use timers in the new system.
__________________
Compiling...
Compiling...

Last edited by Lord_Jeremy : 10-10-2009 at 10:28.
Reply With Quote