OCCRA
Go to Post I can't wait until IFI starts their FRC sized competition and quickly overtakes FRC. - AdamHeard [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Events   CD-Media   CD-Spy   FRC-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 02-17-2003, 03:28 PM
Mike375's Avatar
Mike375 Mike375 is offline
Registered User
#0375 (Robotic Plague)
 
Join Date: Sep 2001
Location: New York City
Posts: 46
Mike375 will become famous soon enough
Send a message via AIM to Mike375
picking auto program

whew, the extension might give me the time to get my "auto code picking" program working, so that I dont have to carry around my laptop during the competition. I have written several auto programs that have worked surprisingly well, but I have been having a bit of trouble writing code to select which one I want to run. I built a switch box wired to rc_sw1 through rc_sw8 (rc_sw0 used for the pressure switch) and plugged it into the RC's digital inputs, but it fails to select the program I wish to run. Could someone provide me with some guidance on the matter?

-Mike
  #2   Spotlight this post!  
Unread 02-17-2003, 03:42 PM
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 7,841
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
It is impossible to tell you what is wrong with the details given.

What types of switches are you using, and how are they connected to the RC?

Does the box you made pinout with a multimeter the way that you think it should?

Does a debug statement showing the states of the switches show what you expect.

What code are you using to try to switch programs?


Answer those, and people here will be much better able to help you.
  #3   Spotlight this post!  
Unread 02-17-2003, 04:57 PM
Mike375's Avatar
Mike375 Mike375 is offline
Registered User
#0375 (Robotic Plague)
 
Join Date: Sep 2001
Location: New York City
Posts: 46
Mike375 will become famous soon enough
Send a message via AIM to Mike375
What types of switches are you using, and how are they connected to the RC?

-They are 2 position switches, on and off. Each switch has one connection to a digital input pin and the other goes to a common digital input ground.

Does the box you made pinout with a multimeter the way that you think it should?

-This was tried, everything worked as it should

Does a debug statement showing the states of the switches show what you expect.

-I have no idea how debug works

What code are you using to try to switch programs?

-I was hoping a simple IF THEN in the autonomous section of code would perform this task

example:
counter var word
counter=0

IF auton mode = 1 THEN
select counter

IF rc_sw1=1 THEN start_left:
IF rc_sw2=1 THEN start_right:

'Starting on left side of field
start_left:
(left auto program here)
goto imdone:

'Starting on right side of field
start_right:
(right auto program here)
goto imdone:

ELSE 'Resume Human Control
imdone:
  #4   Spotlight this post!  
Unread 02-17-2003, 11:17 PM
DanL DanL is offline
Crusty Mentor
FRC #0097
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: Somerville, MA
Posts: 682
DanL is just really niceDanL is just really niceDanL is just really niceDanL is just really niceDanL is just really nice
Send a message via AIM to DanL
IF auton mode = 1 THEN

First of all, I'm not sure if your line "IF auton mode = 1 THEN" is a typo cause you were typing fast, or if it's copied from your code. The variable is "auton_mode," so double check that (although I'd assume you'd get a tokenize error if you forgot the _ in your code).

Another problem may be the actual status of this bit. Have you followed the instructions on enabling auto mode (here or here)? There are basically two ways to do it: set the team number to zero, or make a dongle (the dongle I made this year is shown below).

If you're checking the auton_mode bit, you have to have turned it on in the first place. Not sure if you did this or not - you never specified.

--

Another suggestions: just a small note: it would have been a lot more simpler and elegant if you just hooked the left and right side to one toggle switch...

IF sw = 1 THEN <left code>
ELSE <right code>

But with the goto imdone, it'll still work.
__________________
Dan L
Team 97 Mentor
Software Engineer, Vecna Technologies
  #5   Spotlight this post!  
Unread 02-17-2003, 11:21 PM
DanL DanL is offline
Crusty Mentor
FRC #0097
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: Somerville, MA
Posts: 682
DanL is just really niceDanL is just really niceDanL is just really niceDanL is just really niceDanL is just really nice
Send a message via AIM to DanL
[edit]Forgot to upload that pic of my dongle.... apparently you can't upload attachments to a attachmentless post when editing it... *glare at Brandon*)
Attached Thumbnails
Click image for larger version

Name:	dongle.jpg
Views:	462
Size:	31.2 KB
ID:	1076  
__________________
Dan L
Team 97 Mentor
Software Engineer, Vecna Technologies
  #6   Spotlight this post!  
Unread 02-17-2003, 11:50 PM
Lloyd Burns Lloyd Burns is offline
Registered User
FRC #1246 (Agincourt Robotics)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Toronto
Posts: 292
Lloyd Burns is an unknown quantity at this point
Quote:
Originally posted by Mike375
Does a debug statement showing the states of the switches show what you expect.

-I have no idea how debug works


put this in your program and download it:

DEBUG cls,bin8 rc_swA,cr

a little window will appear with a 1's and 0's representation of the first 8 digital inputs.

What code are you using to try to switch programs?

-I was hoping a simple IF THEN in the autonomous section of code would perform this task

example:
counter var word
counter=0

IF auton mode = 1 THEN
select counter


is this all your IF is to decide ? I see no 'endif', efendi.

IF rc_sw1=1 THEN start_left:
IF rc_sw2=1 THEN start_right:


With no distinction, these should execute all the time

'Starting on left side of field
start_left:
(left auto program here)
goto imdone:

'Starting on right side of field
start_right:
(right auto program here)
goto imdone:

ELSE 'Resume Human Control
imdone:
I would make the converse statement,

if auton_mode = 0 then goto end_o_this_code

{auto mode stuff, like if left_sw then goto the_left, &c}

end_o_this_code:

rest of program:
  #7   Spotlight this post!  
Unread 02-18-2003, 12:14 AM
rwaliany's Avatar
rwaliany rwaliany is offline
R
None #0691 (HartBurn)
Team Role: Programmer
 
Join Date: Jan 2003
Rookie Year: 2000
Location: http://www.hartrobot.com
Posts: 137
rwaliany will become famous soon enough
I like
direction VAR bit
program VAR bit(2)

direction = sw5
program = sw6 <<1 + sw7

program1 CON 0

if program = program1 then
...
endif

if program = ...
__________________
R
  #8   Spotlight this post!  
Unread 02-18-2003, 10:03 AM
DanL DanL is offline
Crusty Mentor
FRC #0097
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: Somerville, MA
Posts: 682
DanL is just really niceDanL is just really niceDanL is just really niceDanL is just really niceDanL is just really nice
Send a message via AIM to DanL
eh, problem there is you're wasting precious bits. Last year we used up ALL of our memory for our program, and this year we've been VERY conservative with our memory (i.e. if you put your light-relay-on code at the very end of your code, then you can use the two light relay bits as temporary swap bits cause they're just hard-coded later on).

For example...
direction = sw5
If you're setting direction to be equal to sw5, there's no need to make a seperate bit for it. Just make "direction" an alias for "sw5" if you don't want to use sw5 (aliases take no memory).

Same thing with
program1 CON 0
I see no reason for this. Just make the if statement "IF program = 0...."

On PC programming, there's no real problem with memory allocation being as leniant as you're doing it if it's something as small as the robot code is (although it's much more efficient if you use less memory).

However, with something that has as little memory as a PBASIC stamp, you should be really careful with memory allocation - otherwise, you're going to run out.
__________________
Dan L
Team 97 Mentor
Software Engineer, Vecna Technologies
  #9   Spotlight this post!  
Unread 02-18-2003, 01:23 PM
rwaliany's Avatar
rwaliany rwaliany is offline
R
None #0691 (HartBurn)
Team Role: Programmer
 
Join Date: Jan 2003
Rookie Year: 2000
Location: http://www.hartrobot.com
Posts: 137
rwaliany will become famous soon enough
Quote:
Originally posted by SuperDanman
eh, problem there is you're wasting precious bits. Last year we used up ALL of our memory for our program, and this year we've been VERY conservative with our memory (i.e. if you put your light-relay-on code at the very end of your code, then you can use the two light relay bits as temporary swap bits cause they're just hard-coded later on).

For example...
direction = sw5
If you're setting direction to be equal to sw5, there's no need to make a seperate bit for it. Just make "direction" an alias for "sw5" if you don't want to use sw5 (aliases take no memory).

Same thing with
program1 CON 0
I see no reason for this. Just make the if statement "IF program = 0...."

On PC programming, there's no real problem with memory allocation being as leniant as you're doing it if it's something as small as the robot code is (although it's much more efficient if you use less memory).

However, with something that has as little memory as a PBASIC stamp, you should be really careful with memory allocation - otherwise, you're going to run out.

Right...I have room for 20 more bytes in my auton program (160 bits). 3 bits aren't going to make that much of a difference...I'm not going to run out, and we are done with the programming.

You know there are 8 slots on the RC right?
__________________
R
  #10   Spotlight this post!  
Unread 02-18-2003, 07:48 PM
Scooter's Avatar
Scooter Scooter is offline
Galactic Doughnut!!
#0418 (Purple Haze)
Team Role: Programmer
 
Join Date: Feb 2003
Location: Austin, Texas
Posts: 117
Scooter will become famous soon enoughScooter will become famous soon enough
Send a message via AIM to Scooter
Here...Lemme put into comments what need to be fixed:

'********************

counter var word
counter=0

IF auton mode = 1 THEN 'needs to be auton_mode
select counter

IF rc_sw1=1 THEN start_left: 'lose the colon...
IF rc_sw2=1 THEN start_right: 'lose the colon

'Starting on left side of field
start_left:
(left auto program here)
goto imdone:

'Starting on right side of field
start_right:
(right auto program here)
goto imdone:

ELSE 'Resume Human Control
imdone:

'**************************

Here is what it should look like corrected (with a few tweaks added for efficency):

'**************************

counter var word
counter=0

IF auton_mode = 1 THEN
goto auton_on
else
goto imdone
endif

auton_on:
select counter

IF rc_sw1=1 THEN start_left
IF rc_sw2=1 THEN start_right

'Starting on left side of field
start_left:
(left auto program here)
goto imdone

'Starting on right side of field
start_right:
(right auto program here)
goto imdone

'Resume Human Control
imdone:

'**********************

You could also just use 1 switch for the left-right selection. Have it if the switch is open, then it goes left, else it goes right. This way, you avoid the instance of having both acidetally closed or open. Here is what your code would look like:

'**********************

counter var word
counter=0

IF auton_mode = 1 THEN
goto auton_on
else
goto imdone
endif

auton_on:
select counter

IF rc_sw1=1 THEN
goto start_left
else
goto start_right
endif

'Starting on left side of field
start_left:
(left auto program here)
goto imdone

'Starting on right side of field
start_right:
(right auto program here)
goto imdone

'Resume Human Control
imdone:

'*********************

Hope this helps.

Bill B.
__________________
"Those who think that they know everything are especially annoying to those of us who do."

Last edited by Scooter : 02-18-2003 at 07:54 PM.
  #11   Spotlight this post!  
Unread 02-18-2003, 08:19 PM
Jeff_Rice's Avatar
Jeff_Rice Jeff_Rice is offline
ElementisRegamusProelium
#1359
Team Role: Programmer
 
Join Date: Dec 2002
Location: Linn County
Posts: 283
Jeff_Rice will become famous soon enoughJeff_Rice will become famous soon enough
select var nib 'in the variable initialization part



select = (rc_sw1 * 2) + rc_sw2 'in the start of autonomous mode

if select = 1 then follow_the_yellow_brick_road

if select = 2 then fly_vertically_through_space

if select = 3 then seek_and_stack_all_drivers_on_opposing_team

'put regular code here Make sure that you don't run through
'two sections at once

The preceding code may or may not have been taken from our robot code

But you get the idea.
__________________
"He said my name is Private Andrew Malone
If you're reading this then I didn't make it home
But for every dream that's shattered another one comes true
This car was once a dream of mine now it belongs to you
And though you may take her and make her your own
You'll always be riding with Private Malone" David Ball, "Private Malone"
  #12   Spotlight this post!  
Unread 02-20-2003, 09:39 PM
Jared Russell's Avatar
Jared Russell Jared Russell is offline
I feel better now.
AKA: Jared341
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 2,626
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
the word "select" is a reserved operator. choose a different one.
  #13   Spotlight this post!  
Unread 02-20-2003, 09:56 PM
Caleb Fulton's Avatar
Caleb Fulton Caleb Fulton is offline
Z = Z^2 + C ......WHEEEE!
AKA: aXvXiA
#0461 (West Side Boiler Invasion)
Team Role: College Student
 
Join Date: Dec 2002
Location: West Lafayette, Indiana
Posts: 205
Caleb Fulton has a spectacular aura aboutCaleb Fulton has a spectacular aura aboutCaleb Fulton has a spectacular aura about
Send a message via AIM to Caleb Fulton
I got ours to work with a 3-position switch using simple if/then statements.....
__________________
  #14   Spotlight this post!  
Unread 02-20-2003, 10:31 PM
Jeff_Rice's Avatar
Jeff_Rice Jeff_Rice is offline
ElementisRegamusProelium
#1359
Team Role: Programmer
 
Join Date: Dec 2002
Location: Linn County
Posts: 283
Jeff_Rice will become famous soon enoughJeff_Rice will become famous soon enough
Oh. It wasn't the word I used anyway.

What is select used for then?
__________________
"He said my name is Private Andrew Malone
If you're reading this then I didn't make it home
But for every dream that's shattered another one comes true
This car was once a dream of mine now it belongs to you
And though you may take her and make her your own
You'll always be riding with Private Malone" David Ball, "Private Malone"
  #15   Spotlight this post!  
Unread 02-21-2003, 04:29 PM
Greg Ross's Avatar
Greg Ross Greg Ross is offline
Grammar Curmudgeon
AKA: gwross
FRC #0330 (Beach 'Bots)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Hermosa Beach, CA
Posts: 2,244
Greg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond repute
Send a message via AIM to Greg Ross Send a message via Yahoo to Greg Ross
Quote:
Originally posted by Jeff_Rice
What is select used for then?
Select is like a multi-condition IF or a BRANCH.

From the PBASIC 2.5 Documentation:
Quote:
SELECT…CASE can be used to cleanly replace multiple IF…THEN…ELSE structures. The PBASIC syntax
for SELECT…CASE is ( | denotes mutually-exclusive items ):
Code:
SELECT expression
CASE | TCASE ELSE | condition(s)
statement(s)
ENDSELECT
Notes:
• expression can be a variable, a constant or an expression.
• condition can be in the form:

{condition-op} #

-- where condition-op is an optional conditional operator: =, <>, <, >, >= or <=
-- # is a variable, a constant or an expression
or…

# TO #

-- Indicates a range of the first number to the next number, inclusive
-- Conditional operators are not allowed in this form.

• Multiple conditions within the same case can be separated by commas ( , ).
• When a CASE is True, the default function is for the CASE's statement(s) to be executed, then
program execution jumps to the first statement following ENDSELECT.
• TCASE, meaning “Through CASE”, behaves exactly like CASE, except that it causes the previous
CASE (if executed) to continue program execution at the first statement within the TCASE,
instead of jumping to after the ENDSELECT. After execution of the statements within TCASE,
execution jumps to after ENDSELECT, unless followed by another TCASE.
Example:
Code:
SELECT irCmd
  CASE 0 TO 3
    HIGH irCmd

  CASE AllOff, Mute
    OutA = %0000

  CASE ELSE
    DEBUG "Bad Command", CR
ENDSELECT
__________________
Greg Ross (The Grammar Curmudgeon formerly known as gwross)
S/W Engineer, Team 330, the Beach 'Bots
<--The Grammar Curmudgeon loves this cartoon.
“Life should not be a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming "Wow! What a Ride!" Hunter S. Thompson
"Playing a practical joke means doing something mean and calling it funny." Me

Last edited by Greg Ross : 02-21-2003 at 04:31 PM.
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
2-week FIRST summer program @ WPI ColleenShaver General Forum 20 05-31-2009 02:02 AM
Fried program slots? Jeff Waegelin Programming 18 03-19-2003 05:08 PM
Ahh! Program trick confusing! archiver 2001 9 06-24-2002 01:26 AM
Credits for FIRST program. archiver 2000 6 06-23-2002 11:16 PM
An invitation for HS Juniors archiver 2000 0 06-23-2002 09:51 PM


All times are GMT -5. The time now is 08:41 AM.

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


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