Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Double Solenoid Help (http://www.chiefdelphi.com/forums/showthread.php?t=34933)

doyler 18-02-2005 18:53

Double Solenoid Help
 
We have a double solenoid hooked up to a piston
It is hooked up to relays 1 and 2
We are trying to make it come out when the trigger is pulled and go back when it is pulled again

What would I have to fix here?

Code:

int pnu = 0;
...........
      if(p3_sw_trig==1 && pnu==0)
        {
        relay1_fwd=0;
        relay1_rev=1;
        relay2_fwd=1;
        relay2_rev=0;
        pnu+=1;
        }

        if(p3_sw_trig==1 && pnu==1)
        {
        relay1_fwd=1;
        relay1_rev=0;
        relay2_fwd=0;
        relay2_rev=1;
        pnu=0;
        }


whakojacko 18-02-2005 19:07

Re: Double Solenoid Help
 
Only have taken a quick glance at your code, but you can wire a double solenoid unsing just 1 spike. Look at the spike manual on ifirobotics.com to find otu how to wire. At will also make your code a bit easier

doyler 18-02-2005 19:21

Re: Double Solenoid Help
 
We don't really have time to put a double on 1 spike, but is there a way to fix my code?

Alan Anderson 18-02-2005 23:12

Re: Double Solenoid Help
 
To fix your code, you also need to make sure that you only process the change once each time the switch is activated.
Code:

  last_trig = 0;
  ...
  if (p3_sw_trig ==1 && last_trig == 0 && pnu == 0)
  {
    ...
    pnu += 1;
  }
  if (p3_sw_trig == 1 && last_trig == 0 && pnu == 1)
  {
    ...
    pnu = 0;
  }
  last_trig = p3_sw_trig;


doyler 19-02-2005 11:36

Re: Double Solenoid Help
 
I added that, but for some reason I still can't get it working


All times are GMT -5. The time now is 04:40.

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