Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Pneumatics coding (http://www.chiefdelphi.com/forums/showthread.php?t=63837)

Nguyen 11-02-2008 21:50

Pneumatics coding
 
I'm helping out a team with no programming experience and I have basic experience but none relating to FIRST.

They are trying to code their pneumatics but don't know how to do so or even where to start.

The basic setup is as follows:

there are 3 pneumatic valves:
the first one is connected as follows: festo valve -> spike relay -> pwm8
the second is festo valve -> spike relay -> pwm12
the third is festo valve -> spike relay -> pwm16

the compressive is compressor-> spike-> relay8

the 3 valves would be independently controlled by 3 arbitrary joystick buttons

Would anyone be so kind as to point me in the right direction?

mlucas 11-02-2008 22:01

Re: Pneumatics coding
 
what program are you using?

Nguyen 11-02-2008 22:04

Re: Pneumatics coding
 
sorry about that, mplab

mlucas 11-02-2008 22:08

Re: Pneumatics coding
 
ill have to let someone else help you then, i only no easyc...srry, i would try a help menu on mplab...they are surprisingly helpful, our programmer taught himself that way...only took 2.5 months

Joohoo 11-02-2008 22:21

Re: Pneumatics coding
 
Quote:

Originally Posted by Nguyen (Post 697003)
I'm helping out a team with no programming experience and I have basic experience but none relating to FIRST.

They are trying to code their pneumatics but don't know how to do so or even where to start.

The basic setup is as follows:

there are 3 pneumatic valves:
the first one is connected as follows: festo valve -> spike relay -> pwm8
the second is festo valve -> spike relay -> pwm12
the third is festo valve -> spike relay -> pwm16

the compressive is compressor-> spike-> relay8

the 3 valves would be independently controlled by 3 arbitrary joystick buttons

Would anyone be so kind as to point me in the right direction?

ok, so first of all spike relays cannot be plugged into pwm outputs. What they do need to be plugged into are the relay outputs.

ok now that you have all the pneumatics plugged into relays and not pwms, ill go over how they work. The relays are basically 2 digital outputs slapped into a single cable, so there are two bits that you can set. relay#_fwd and relay#_rev. What this gets translated into is either +12V, -12V, 0V to the festo Valves. So in order to set them to one direction you would use this line of code

relay#_fwd = 1;
relay#_rev = 0;

this will set your festo valve to actuate your pneumatic one way and if you switch which bit is set to 1 then you actuate the pneumatic the other way. Now is for some reason you dont want any pressure in the cylinders then you set each bit to 0.

Now if you want to change these based on a button on a joystick then you can change the relay#_fwd and relay#_rev bits inside an if statment such as

if(p1_sw_top ==1)
{
relay#_fwd = 1;
relay#_rev = 0;
}

If you need any help any further feel free to pm me and I'll try to help you.

Racer26 11-02-2008 23:28

Re: Pneumatics coding
 
Quote:

Originally Posted by Joohoo (Post 697027)
ok, so first of all spike relays cannot be plugged into pwm outputs. What they do need to be plugged into are the relay outputs.

ok now that you have all the pneumatics plugged into relays and not pwms, ill go over how they work. The relays are basically 2 digital outputs slapped into a single cable, so there are two bits that you can set. relay#_fwd and relay#_rev. What this gets translated into is either +12V, -12V, 0V to the festo Valves. So in order to set them to one direction you would use this line of code

relay#_fwd = 1;
relay#_rev = 0;

this will set your festo valve to actuate your pneumatic one way and if you switch which bit is set to 1 then you actuate the pneumatic the other way. Now is for some reason you dont want any pressure in the cylinders then you set each bit to 0.

Now if you want to change these based on a button on a joystick then you can change the relay#_fwd and relay#_rev bits inside an if statment such as

if(p1_sw_top ==1)
{
relay#_fwd = 1;
relay#_rev = 0;
}

If you need any help any further feel free to pm me and I'll try to help you.

You're close, but you're not quite right.

First off, you're right about the connections to RC. Spikes MUST be plugged into the RELAY outputs on the RC. I don't know that there is a rule saying this, but its implied by the fact that they won't work if you don't.

The FESTO valves are single solenoid. I don't know what these will do with reverse polarity, but I imagine its along the lines of either a) just not do anything, or b) cease to function ever again.

Thusly, I wouldn't touch relay#_rev on those units, except to ensure its set to 0.

The FESTO valves can be simply switched using relay#_fwd = 1;, and relay#_fwd = 0;

The SMC single solenoid is the same.

The SMC Double solenoid is used in the way you describe, using relay#_fwd for one direction, and relay#_rev for the other direction, assuming you've wired the two positives to M+ and M- on your spike, and the grounds to ground.

Setting _fwd and _rev to zero on a SMC double will leave the gate in whichever direction it was last set to. We are not given "center-off" valves that would give the behavior you describe.

Inetta 12-02-2008 02:43

Re: Pneumatics coding
 
First off thanks so much to everyone that replied and helped and also thanks so much Squishy for helping me at all, I really appreciate it. <3

basically I used this line of code so far

relay2_fwd = 0;
relay2_rev = 0;

if(p4_sw_trig == 1)
{
relay2_fwd=1;
relay2_rev=0;
}
else if (p4_sw_trig == 0)
{
relay2_fwd=0;
relay2_rev=0;
}

like would that work.. or is that completely wrong?

sorry, I really don't have any experience in programming so my questions might seem pointless. So like I said, sorry ahead of time :D

Racer26 12-02-2008 08:48

Re: Pneumatics coding
 
That will work famously.

Pulling the trigger on port 4's joystick will result in the spike at relay2, and presumably, the solenoid valve attached to it, to actuate, and releasing the trigger will de-actuate the cylinder, assuming you're using the FESTO single solenoid valves (the roundish white ones with a blue lever and 4 grey ports.)

Inetta 13-02-2008 08:00

Re: Pneumatics coding
 
okay, I understand how it all works now however I'm not sure how I could write a block of coding that would allow me to toggle the buttons.. if that is possible.

Is there a code that would allow me to just press button = active;
press again = inactive?

JBotAlan 13-02-2008 08:32

Re: Pneumatics coding
 
Quote:

Originally Posted by Inetta (Post 697932)
okay, I understand how it all works now however I'm not sure how I could write a block of coding that would allow me to toggle the buttons.. if that is possible.

Is there a code that would allow me to just press button = active;
press again = inactive?

Well, you need to know some characteristics about these switches.

First off, you will need to probably de-bounce the switches. The chances that you get something like "000000100010101110111111" when the button is pressed are likely. I don't use toggles, so I don't know about code for this. While I could script it up, it would likely be horribly inefficient...

Second, you will need to have a static variable that you set to 1 when the switch is triggered; set it to 0 when the switch goes to 0. Before you set this variable, check if the switch is 1 and the variable is 0; if this condition is true, change the pneumatic, then set the variable to 1.

Let me know if you would like pseudo code, but I'd prefer not to write specific code. That should be left up to you. :D

JBot

COACHTJ1688 13-02-2008 08:53

Re: Pneumatics coding
 
We're having issues programming the compressor and pressure switch, which I thought was part of the original question, but never got answered.

Our team is using Easy C, which we're really efficient with. I believe that we lack the sufficient knowledge of the pneumatics system, due to years of the coach saying that it was a waste of time.

Well, the future is NOW! people. Team 1688 has ventured into the land of safety orange tubing, and pressure gauge happiness!

I thought that I read somewhere that input 16 was used for the pressure switch and one of the spike relays was used for the compressor? Can someone help? Or at least direct me to a thread that can?

THANKS!

~Tom

Mark McLeod 13-02-2008 11:59

Re: Pneumatics coding
 
Put InitPressureSwitch() into the Initialize block and just specify the digital input that the pressure sensor is plugged into and the Relay the compressor's Spike is connected to.

COACHTJ1688 13-02-2008 14:57

Re: Pneumatics coding
 
We had something similar. Perhaps we just had it backwards. I'll check it when I get to the lab.

THANKS!

hipsterjr 13-02-2008 21:24

Re: Pneumatics coding
 
We are having a similar problem. We have this basic layout for our shifters and another cylinder:

Quote:

relay2_fwd = 0;
relay2_rev = 0;

if(p4_sw_trig == 1)
{
relay2_fwd=1;
relay2_rev=0;
}
else if (p4_sw_trig == 0)
{
relay2_fwd=0;
relay2_rev=0;
}
We are using a button on the control panel to activate it. The problem is that the we have to hold the button to say in high or low gear. I tried to set it so that one press of the button would activate the cylinder and a second would deactivate the cylinder. I have tried doing this a couple different ways, but as the code cycles every 20 something milliseconds, the shift state changes with it. So as I press the button quickly, it will activate and deactivate a couple dozen times. How do I stop this? (using MBLAB)

Mark McLeod 13-02-2008 22:24

Re: Pneumatics coding
 
Something such as:
Code:

  static char toggle=1;

  if(p4_sw_trig && toggle)
  {
        toggle = 0;
          relay2_fwd = !relay2_fwd;
          relay2_rev = 0;
  }
  if(!p4_sw_trig)
  {
        toggle = 1;
  }

prevents further toggling until the button has been released again.


All times are GMT -5. The time now is 23:45.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi