Go to Post Long Live Gracious Professionalism, and long live F.I.R.S.T. - Matt Krass [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 26-01-2003, 03:59
PBoss PBoss is offline
Registered User
#1212
 
Join Date: Jan 2003
Location: Nowhere
Posts: 9
PBoss is an unknown quantity at this point
switches in order

Here is a piece of code in PBasic 2.5
IF p1_sw_top=1 AND p2_sw_top=1 then
p1_y=200

This means that at any given time, if p1 switch and p2 switch are pressed together p1_y=200, but here is my question:

Is there a way that you can program so that the switches will have to be pressed in order- first p1 switch and then p2 switch or vice versa- then only p1_y=200???
  #2   Spotlight this post!  
Unread 26-01-2003, 04:17
ttedrow's Avatar
ttedrow ttedrow is offline
Herding electrons
AKA: Tim Tedrow
FRC #0281 (EnTech)
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2000
Location: Greenville, SC
Posts: 165
ttedrow will become famous soon enoughttedrow will become famous soon enough
Yes, you can declare a latch or memory bit that is set when the first button is pushed and cleared when the second button is pressed.

Tim Tedrow
__________________
Sr. Design Engineer
Caterpillar Inc.
Greenville, SC

KD4EGM

FRC 281 Greenvillains
Infected with the FIRST virus in 2000

Yes, Chute Door!!!
  #3   Spotlight this post!  
Unread 26-01-2003, 09:04
PyroPhin's Avatar
PyroPhin PyroPhin is offline
Registered User
None #0263
 
Join Date: Feb 2002
Rookie Year: 2002
Location: Frozen Wasteland, NY
Posts: 68
PyroPhin is on a distinguished road
yes, you can do that very simply, using 2 for, next loops:

sw1:
if p1_sw_top = 1 then sw2
goto endswich

sw2:
if p2_sw_top = 1 then dostuff:
goto endswich

Dostuff:
p1_y = 200

endswich:

the program will process the first loop, then only if that requirement is met, go to the second loop. if the requirement isnt met at either button, or at the second, not the first, it bypasses the dostuff loop ^.^

~Pyro
__________________
Squee!
-=-=-=-==-=-=-=-==-=-=-==-
Team 263, Aftershock:
Alumni, guy who comes back and fixes Krass's mistakes
  #4   Spotlight this post!  
Unread 26-01-2003, 10:45
Unsung FIRST Hero
Nate Smith Nate Smith is offline
FRC Key Volunteer Trainer
AKA: CrazyNate
no team
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Old Town, Maine
Posts: 1,029
Nate Smith is a splendid one to beholdNate Smith is a splendid one to beholdNate Smith is a splendid one to beholdNate Smith is a splendid one to beholdNate Smith is a splendid one to beholdNate Smith is a splendid one to beholdNate Smith is a splendid one to beholdNate Smith is a splendid one to behold
Send a message via AIM to Nate Smith Send a message via Yahoo to Nate Smith
Here's a bit of code which will do what you want:
Code:
'in variable declaration section
seq1_flag VAR bit

'in main loop

'Check 2nd condition first to allow for continuous action, and not just one loop
if p2_sw_top = 1 AND seq1_flag = 1 then run_seq1

'Check first condition
if p1_sw_top = 0 then skip_seq1

'if we got here, condition 1 is true, set flag
seq1_flag = 1
'jump out of sequence loop
goto seq1_done

skip_seq1:
'first condition is not met, clear flag
seq1_flag = 0
'jump out of sequence loop
goto seq1_done

run_seq1:
'both conditions met, set value
p1_y = 200

seq1_done:
'end of sequence loop
__________________
Nate Smith
nsmith@smythsoft.com
12 seasons, 4 teams, and more time logged behind the scorekeeper's table than I care to remember...
returning for 2011? only time will tell...
  #5   Spotlight this post!  
Unread 26-01-2003, 15:50
PyroPhin's Avatar
PyroPhin PyroPhin is offline
Registered User
None #0263
 
Join Date: Feb 2002
Rookie Year: 2002
Location: Frozen Wasteland, NY
Posts: 68
PyroPhin is on a distinguished road
isnt that overkill?

~Pyro
__________________
Squee!
-=-=-=-==-=-=-=-==-=-=-==-
Team 263, Aftershock:
Alumni, guy who comes back and fixes Krass's mistakes
  #6   Spotlight this post!  
Unread 26-01-2003, 22:02
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
No. The code you posted doesn't actually take the order you pressed the switches into account. The switch variables don't get updated until you do a SERIN, so you need a way to keep track of stuff between the loops.

--Rob
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
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
Limit switches Team168 Programming 8 10-02-2003 16:22
Custom Pneumatics order form Andrew Schuetze Kit & Additional Hardware 1 10-01-2003 20:34
Team selector switches on ISAAC Lloyd Burns Robotics Education and Curriculum 0 17-12-2002 08:32
More than 2 aux switches in 1 port f22flyboy Programming 2 01-11-2002 14:44
Need help with custom switches archiver 2001 3 24-06-2002 00:35


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

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