Go to Post If we miss in autonomous, the team blames the programmer, If we miss in teleop, the team blames the drivers - Jared Russell [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

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 19-02-2004, 06:19
Lord Nerdlinger Lord Nerdlinger is offline
Registered User
#1047
 
Join Date: Jan 2003
Location: Irvine
Posts: 98
Lord Nerdlinger has a little shameless behaviour in the past
Getting the relays to stay constant

Right now we have our pump hooked up to one of the spikes on #5 and while it works (press a button and it goes on) it doesn't stay on and it's really annoying to have to hold it down.

I think* (i don't know how to code and no one on the team does) that all I have to do is something like this


when joystick button is depressed set a variable equal to one

then do an if statement, if variable equals 1 to set the relay to fwd, else if, set relay to neutral position i guess fwd and rev are equal to zero?

I don't know the proper syntax or way about doing this, but i think it would only be a 1 or 2 lines of code

could anyone tell me how to do it or write it out so I could just copy and paste it into our code? plzzzz

It's #5 if you want to write it out
  #2   Spotlight this post!  
Unread 19-02-2004, 06:50
Ryan M. Ryan M. is offline
Programming User
FRC #1317 (Digital Fusion)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Ohio
Posts: 1,508
Ryan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud of
Re: Getting the relays to stay constant

Do something like this:
Code:
unsigned char state = 0;
unsinged char switchState = 0;

// Check switches. Substitute switch for whatever switch on the OI you are using
// I use the switch state to prevent the switching of the state do to not realeasing the button right away
if(switch && !switchState)
{
    // Set switch state
    swtichState = 1;

    // Switch states
    if(switch)
        state = 0;
    else
        state = 1;
}
else if(!switch)
{
    // reset the switch state
    switchState = 0;
}

// Subitute relay with your relay
if(state)
{
     // Run forward
     relay_fwd = 1;
     relay_rev = 0;
}
else
{
    // Turn off relay
    relay_fwd = 0;
    relay_rev = 0;
}
Put that whole thing where ever you are doing your cheking currently. Put the varable declarations at the top of whatever function you have this in. That should work. (I hope... )
__________________

  #3   Spotlight this post!  
Unread 19-02-2004, 10:17
bstempi bstempi is offline
Captain
#0708 (Hardwired Hatters)
Team Role: Student
 
Join Date: Feb 2004
Location: Horsham, Pa
Posts: 23
bstempi is an unknown quantity at this point
Send a message via AIM to bstempi
Re: Getting the relays to stay constant

Quote:
Originally Posted by Lord Nerdlinger
Right now we have our pump hooked up to one of the spikes on #5 and while it works (press a button and it goes on) it doesn't stay on and it's really annoying to have to hold it down.

I think* (i don't know how to code and no one on the team does) that all I have to do is something like this


when joystick button is depressed set a variable equal to one

then do an if statement, if variable equals 1 to set the relay to fwd, else if, set relay to neutral position i guess fwd and rev are equal to zero?

I don't know the proper syntax or way about doing this, but i think it would only be a 1 or 2 lines of code

could anyone tell me how to do it or write it out so I could just copy and paste it into our code? plzzzz

It's #5 if you want to write it out
This isn't what you're looking for, but you may like this, use it, and even learn from it. In the default code, if you hook up the compressor to relay 8, and hook up your preassure switch( that came with your kit ) to digital in 18, whenever the preasure is below 95, it will pump untill it gets to 115 (or somewhere around there). What happens is this:

relay8rev = !digitalinput18;

those names area ll wrong because I dont have code with me, but what it does is set the relay to the opposite value of the digital input sensor (in this case, the preasure switch). If the swith is 1 (it's up to preasure) the relay is off. If it's below presure (0), then the relay will fire up (to 1). Hope you can learn something from this.
~Bstempi
Closed Thread


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
stay on the carpet????!!!! soap108 Rules/Strategy 12 13-03-2003 12:50
SPIKE relays Andy Brockway Electrical 2 13-11-2002 13:22
where are teams going to stay? archiver 2001 2 24-06-2002 02:49
How many hotels did you team stay at?? Elgin Clock Championship Event 4 10-05-2002 17:53
How do you control relays BinaryBob0001 Technical Discussion 2 21-01-2002 08:42


All times are GMT -5. The time now is 18:22.

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