Thread: toggle switch
View Single Post
  #28   Spotlight this post!  
Unread 27-01-2006, 20:31
Windward's Avatar
Windward Windward is offline
Registered User
FRC #1452
Team Role: Programmer
 
Join Date: Nov 2005
Rookie Year: 2004
Location: So Cal
Posts: 88
Windward is an unknown quantity at this point
Re: toggle switch

Quote:
Originally Posted by KenWittlief
check the electrical section of the pneumatics manual. You only need one spike per cylinder. The two valves can be controlled by the FWD and REV outputs off the spike, using battery ground for the return.

or you can use two diodes, so that FWD powers one valve, and REV (reversed voltage) powers the other valve.

remember the spike has three output states: forward, reverse, and off.
I tried writing some code to get make it so when I press p1 trigger the piston will close, then wait a little then open, then allow it to be "fired" again.

But when the second wait() comes up the computer either crashes, and with it commented it, it doesn't work. What's wrong.

void wait(void)
{
time = 0;
count = 0;
for (count=0; count <10000; count++)
{
for (time=0; time < 50; time++)
{
prev = 1;
}
time = 0;
}
count = 0;
time = 0;
}
void fire(void)
{
printf("Piston Forward\r");
relay1_rev = 0;
relay1_fwd = 1;
wait();
printf("Piston Back\r");
relay1_fwd = 0;
relay1_rev = 1;
// wait();
printf("Firing done!\r");
prev = 0;
}
if (p1_sw_trig == 1 && prev == 0)
{
prev =1;
fire();
}