|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Programming of Pneumatics
I searched and found a couple threads related to this, but no one gave any solid answers. Therefore...
We are trying to use a momentary switch on our control board, to control a pneumatic cylinder. We have tried both single and double solenoids, so far with no luck. What we are attempting to do is this. The cylinder is in one position (extended or compressed.) The driver hits the momentary switch once, and the cylinder changes position to the opposite extreme and holds. To bring the cylinder back, the driver hits the momentary switch once again, and the cylinder returns and holds. Pretty simple, but we have run into several issues including hysteresis, the cylinder not returning on the 2nd press of the button, etc... Unfortunately, I'm not the programmer, so I don't have the actual code we've been working with. Does someone out there have a simple way to execute this command? Thanks, Bengineer GUS, Team 228 |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
||||
|
||||
|
Re: Programming of Pneumatics
Ah, the latch part is what we're missing. I couldn't figure out a way to implement something like that. However, your code is exactly what we're looking for. I'll try to 1st thing Friday afternoon, thanks!
Bengineer GUS, Team 228 |
|
#4
|
|||
|
|||
|
Re: Programming of Pneumatics
You will need to make 'latch' a static variable if you are defining it inside a function so that it will retain its value between calls to the function. If you declare it outside a function (global to the file), it is by default static. I would assume you would declare 'latch' inside the function, though.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Programming - Getting Started | Mark McLeod | Programming | 80 | 16-04-2008 23:37 |
| Robot Programming Education | phrontist | Programming | 11 | 03-05-2004 07:32 |
| Pneumatics Programming | KWalsh | Programming | 8 | 19-02-2004 09:17 |
| Programming PBASIC for pneumatics | archiver | 2001 | 2 | 23-06-2002 23:58 |
| Pneumatics electrical wiring and programming | archiver | 2001 | 1 | 23-06-2002 23:10 |