Go to Post What if my teams drive train isn't an option? - MARS_James [more]
Home
Go Back   Chief Delphi > Technical > Pneumatics
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 18-02-2007, 03:16
Asheron Asheron is offline
Registered User
no team
 
Join Date: Jan 2007
Location: New Orleans
Posts: 13
Asheron is an unknown quantity at this point
Need critique of programming idea and info!!!

I am using EasyC

I was thinking of controlling the soleniods in the following manner (and this is psuedocode)

Setup info: I have a global button_counter(1) integer that keeps track of how many times a button has been pressed on the joystick, and I have a relay, and I have a button(1) variable that holds input from one of the joystick buttons. The example uses 'button1' and 'button_counter1' but could work for buttons 1 through for 4 to control seperate soleniods or relay attachments.

If button(1) is pressed
{
button_counter1 ++
// turn on relay in one positive direction

if button_count == 0

{ while (button not pressed again)
{
set relay1(1,0)
}
else if button_count == 1
{ while (button not pressed again)
{ set relay1(0,0) }
}
else if button_count == 2
{ while (button not pressed again)
{ set relay1(0,1) }
}

else { set relay1(0,0); button_count = 0;}

end if
end if

The purpose being to be able to have the flow controlled for each soleniod by only 1 button being pressed. I don't have access to the robot to know exactly how they work. I'm doing this code from remote location and need help as soon as possible. Let me know if it will work! Please PM me if you have a suggestion.

Also, how do I capture the event of a button press?

I don't know how to set a listener for an OI digital input that could then be the codition for the original if
  #2   Spotlight this post!  
Unread 18-02-2007, 03:33
Ari Allyn-Feuer Ari Allyn-Feuer is offline
Registered User
FRC #0753
 
Join Date: Feb 2006
Location: Bend, OR
Posts: 22
Ari Allyn-Feuer is on a distinguished road
Re: Need critique of programming idea and info!!!

Basically, the way you access the button inputs on the joysticks (not addressing switch breakout boxes and the like) is by using the button flags that the IFI default code uses (of course you can edit the #defines). The tags look like p1_sw_trig. There's p1, p2, p3, p4 (for the four joystick ports on the OI) and sw_trig (trigger), sw_top (thumb on the kit JSs), sw_aux1, sw_aux2.

The relay outputs have two parts, fwd and rev. For pistons, you always want rev to be 0, and forward is 1 if you want the piston forward and 0 if you want it to retract.

The way I turn a button into a toggle and use it to control a relay is like this. You make an unsigned char called "p3_sw_trig_old", and at the end of your routine put:

p3_sw_trig_old = p3_sw_trig;

so that the RC will remember how the button was last time. The times you want to switch the output is the very first loop they push the switch, and then to wait until they press it again. So you do something like:

if(p3_sw_top && !p3_sw_top_old) //If it's pressed but wasn't last loop.
{
relay_1_fwd = 1 - relay_1_fwd; //Toggle the relay's forward part.
relay_1_rev = 0;
}

I hope this helps. Post again with any more issues.

Ari.
  #3   Spotlight this post!  
Unread 18-02-2007, 11:21
Asheron Asheron is offline
Registered User
no team
 
Join Date: Jan 2007
Location: New Orleans
Posts: 13
Asheron is an unknown quantity at this point
Re: Need critique of programming idea and info!!!

I have the same setup on both sides of the robot; a pump that heads out/in to lower a ramp on either side (so its actually 2 pumps, 1 on each side of robot)

Could I use the same button to lower each and raise each by doing the following

OIToRelay (3,1,2,1) //jostick on port 3 trigger button forward to relay 2

OIToRelay (3,2,2,2) //joystick on port 3 thumb button reverse to relay 2

OIToRelay (3,1,3,1) //jostick on port 3 trigger button forward to relay 3

OIToRelay (3,2,3,2) //joystick on port 3 thumb button reverse to relay 3

Would it cause problems trying to use the same input to control relay outputs???
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
Need help Programming and wiring camera! Amisca Programming 1 14-02-2006 18:37
need scouting info from teams 966 and 970!!!! jeffwalsh Scouting 0 05-02-2003 15:48
We NEED 8-inch wheels and programming help archiver 2001 7 24-06-2002 00:29
Need info on how to build temp. receiver and transmitter archiver 1999 5 23-06-2002 22:01


All times are GMT -5. The time now is 17:05.

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