Go to Post I've found that being outraged on behalf of others is often a misuse of energy. - Taylor [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Spotlight this post!  
Unread 26-03-2007, 15:01
Imajie Imajie is offline
Registered User
AKA: James Letendre
FRC #0195 (Cyber Knights)
Team Role: Electrical
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Southington
Posts: 114
Imajie has much to be proud ofImajie has much to be proud ofImajie has much to be proud ofImajie has much to be proud ofImajie has much to be proud ofImajie has much to be proud ofImajie has much to be proud ofImajie has much to be proud of
Send a message via AIM to Imajie
Re: Easy C Relay Programming

You want the relay to toggle. Its not too complicated to do.
This example will toggle a relay when the trigger is pulled on the first joystick.
Code:
char relayPos = 0;    //Holds the current position of the relay
char relayRelease = 1;    //Holds if trigger has been released yet
if(GetOIDInput(1, 1) && relayRelease)    //If trigger is pressed after being released
{
    if(relayPos == 1)
    {
        SetRelay(1, 0, 1);
        relayPos = 0;
    }else
    {
        SetRelay(1, 1, 0);
        relayPos = 1;
    }
    relayRelease = 0;    //Set trigger as pressed
}else if(GetOIDInput(1, 1)==0)    //trigger released
{
    relayRelease = 1;
}
Note that the above is for a double solenoid. If you are using a single solenoid then change the SetRelays to SetRelay(1, 0, 0) and SetRelay(1, 1, 0)
__________________
2007 UTC Champions Thanks 1124 and 558
2007 UTC GM Industrial Design Award

2006 Newton Divisional Winners
2006 Championship finalists
(Thanks 25 and 968 for picking us!)
2006 National Innovation in Control
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Pneumatics (Spike Relay, Solenoid etc.) Programming oceansidehs Programming 8 10-02-2007 13:58
Easy C programming Problem fredliu168 FIRST Tech Challenge 6 19-11-2006 22:44
Relay Programming Questions... comwiz7 Programming 11 21-02-2006 13:04
Easy C programming , Worth teaching? Nine9cracker Programming 16 19-01-2006 00:45
Easy-C Programming CD Jeff K. Programming 2 09-01-2006 02:20


All times are GMT -5. The time now is 19:46.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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