|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Re: PROGRAMMING PNEUMATICS
But how would you program to turn the switch on and off with the click of the trigger
Would it be if (p1_sw_trig == 1) { relay2_fwd = 1; //to go } else { relay3_fwd = 0; //to stop } would this work for having the switch be in relay2 for on and relay3 is for the switch off. Thanks |
|
#2
|
||||
|
||||
|
Re: PROGRAMMING PNEUMATICS
Quote:
|
|
#3
|
|||
|
|||
|
Re: PROGRAMMING PNEUMATICS
But if i wired a switch to the wires in the controller and bypass the trigger to replace with a switch, would that work?
|
|
#4
|
|||||
|
|||||
|
Re: PROGRAMMING PNEUMATICS
Yes, this would work.
We have a totally custom OI. Our box has 4 custom switches on it, along with an xbox port for our controller. We also have 4 different voltages on board the box for different devices. But in short, yes. Give it a try and see what happens! Let us know your results so that we can give you a hand. Jacob |
|
#5
|
||||
|
||||
|
Re: PROGRAMMING PNEUMATICS
It's actually fairly simple to have the trigger control an action with the pneumatics. What have you to do is declare some variable like handstate.
Then when your trigger is pressed changed the value of handstate to 1 or 0. Then when the trigger is pressed you know whether your hand is opened or closed and you can do an action based on it. Code:
int handstate;
handstate = 0; //default position for whatever your using
if (p1_sw_trig == 1 && handstate == 0)
{
relay2_fwd = 1;
handstate = 1;
}
if (p1_sw_trig == 1 && handstate == 1)
{
relay2_rev = 1;
handstate = 0;
}
Last edited by dpick1055 : 25-02-2007 at 01:09. |
|
#6
|
||||
|
||||
|
Re: PROGRAMMING PNEUMATICS
Quote:
Code:
int handstate;
handstate = 0; //default position for whatever your using
if (p1_sw_trig == 1 && handstate == 0)
{
relay2_fwd = 1;
handstate = 1;
}
if (p1_sw_trig == 0 && handstate == 1)
{
handstate = 2;
}
if (p1_sw_trig == 1 && handstate == 2)
{
relay2_fwd = 1;
handstate = 3;
}
if (p1_sw_trig == 0 && handstate == 3)
{
handstate = 0;
}
|
|
#7
|
||||
|
||||
|
Re: PROGRAMMING PNEUMATICS
Oops. Sorry I think it should be
Code:
int handstate;
handstate = 0; //default position for whatever your using
if (p1_sw_trig == 1 && handstate == 0)
{
relay2_fwd = 1;
handstate = 1;
}
else if (p1_sw_trig == 1 && handstate == 1)
{
relay2_rev = 1;
handstate = 0;
}
|
|
#8
|
|||
|
|||
|
Re: PROGRAMMING PNEUMATICS
the code will work, but you would need a timer or something, because if this code is evaluated more that once while the button is held down, the state would alternate very rapidly
|
|
#9
|
|||
|
|||
|
Re: PROGRAMMING PNEUMATICS
I had a similar issue when programming the pneumatics for our upper/lower claws, wrist, extension, and lateral drive. Let me show you how I solved the issue.
Code:
if (CLAW1IN == 1 && clawTimer < 3)
{
clawTimer++;
}
else if (CLAW1IN == 1 && clawTimer >= 3 && clawTest == 0)
{
CLAWFWD = !CLAWFWD;
CLAWREV = !CLAWREV;
clawTest = 1;
}
else if (CLAW1IN == 0 && clawTimer >= 3)
{
clawTimer = 0;
clawTest = 0;
}
EDIT: Oops, forgot to fill in for the definitions. Code:
#define CLAW1IN p1_sw_aux1 #define CLAWFWD relay2_fwd #define CLAWREV relay2_rev |
|
#10
|
|||
|
|||
|
Re: PROGRAMMING PNEUMATICS
If you need an edge trigger rather than level trigger, do something like this - assuming that variable 'buttons' holds the state of the joystick(s) buttons, and 'old_buttons' keeps track of the previous state of the buttons:
Code:
if(buttons!=old_buttons)
{
if((buttons&0x1)==0) /* example - bit 0 is the button to react to */
{
do_something_here(); /* execute once per button push */
}
}
old_buttons=buttons;
|
|
#11
|
||||
|
||||
|
Re: PROGRAMMING PNEUMATICS
Hi,
I have seen teams with a board of switches that they have created themselves that controll things like pnunmatics. I would just like to know how we should wire the joystick port with the switches and then use them in the programming. Thanks! |
|
#12
|
|||||
|
|||||
|
Re: PROGRAMMING PNEUMATICS
Wiring/programming for the joystick ports is detailed in
http://www.ifirobotics.com/docs/oi-ref-guide-5-8-07.pdf starting on page 7. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| programming the pneumatics | Armando | Programming | 2 | 17-02-2007 21:47 |
| Programming Pneumatics? | itzrobz | Programming | 2 | 20-01-2007 00:30 |
| Programming of Pneumatics | Ben Piecuch | Programming | 3 | 18-02-2005 02:39 |
| Pneumatics Programming | KWalsh | Programming | 8 | 19-02-2004 09:17 |
| Programming PBASIC for pneumatics | archiver | 2001 | 2 | 23-06-2002 23:58 |