Go to Post Break Robot. Re-engineer. Repeat! - Mr MOE [more]
Home
Go Back   Chief Delphi > Technical > Electrical
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 09-01-2003, 20:30
rosebud rosebud is offline
Registered User
#0115 (MVRT)
 
Join Date: Sep 2002
Location: California
Posts: 24
rosebud is on a distinguished road
Unhappy buttons

im extremely confused about buttons. ive read the section in the basic manual several times, and played with them a little. however, ive gotten two conflicting definitions of the last parameter on target state. 1) that is says which state the button should be in in order to branch 2) that when in downstate, 0 it doesnt branch and 1 it does. also, ive been trying to program a kill switch in that is basically a button statement that says when the button is pressed, goto a subroutine that puts the program into an infinite loop. ive written this program before for the edu robot and had it work, and i also have last year's code which is working. but mine isnt, and i cant figure out why.the program goes into the kill switch subroutine whether the button is pressed or not, and wont get out of the subroutine. here is the code:
the pin is p4_sw_aux1, and ive already tested the mechanical switch and it works physically.

*in main section
BUTTON p4_sw_aux1, 0, 255, 0, wksp, 0, KillSwitch:

*in subroutine section
KillSwitch:
Serin COMA\COMB, INBAUD, [oi_swA,oi_swB,rc_swA,rc_swB,p2_x,p1_x,p4_x,p3_x,PB _mode,packet_num,p2_y,p1_y,p4_y,p3_y,p2_wheel,p1_w heel,p4_wheel,p3_wheel]


BUTTON p4_sw_aux1, 0, 255, 0, wksp,1, Mainloop:

Serout USERCPU, OUTBAUD, [255,255,127,0,127, 0, 127,127,127,127,127,127,127,127,127,127,127,127,12 7,127]

GOTO KillSwitch:
  #2   Spotlight this post!  
Unread 09-01-2003, 21:14
Jay5780 Jay5780 is offline
Registered User
no team (Aztechs)
Team Role: Alumni
 
Join Date: May 2001
Rookie Year: 1996
Location: Warwick, Rhode Island
Posts: 172
Jay5780 will become famous soon enoughJay5780 will become famous soon enough
I thought buttons were those things teams handed out at the comps...


LOL
__________________
Jay
  #3   Spotlight this post!  
Unread 09-01-2003, 22:15
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
ermm....

that may possibly be the most complicated way to do anything i have ever seen..

a button is nothing more than a if-then loop

example, using p1_sw_trig :
(the trigger swich on the joystick plugged into P1)
---------------------------------------------
panicbutton: 'lables the loop (neatness)
if p1_sw_trig = 1 then mysub: 'if button is pressed then goto sub
goto endsub: 'if it isnt.. then dont

mysub: 'put whatever you want the
out 8 = 1 'button to do here
out8 = 1 'this example Turns on some LED's
out9 = 1
out10 = 1

endsub: resumes the rest of the code


----------------------------------------------
as for infinite loops.. you really cant do that unless you use a do while loop, wich pretty much is the same structure. Rbayer posted a discription of the commands in the Pbasic programming section, you may want to check that out!

~Pyro

and you may want to avoid the Serin/out things.. you really dont need more than 2 at most
__________________
Squee!
-=-=-=-==-=-=-=-==-=-=-==-
Team 263, Aftershock:
Alumni, guy who comes back and fixes Krass's mistakes
  #4   Spotlight this post!  
Unread 10-01-2003, 01:49
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,245
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
BUTTON is a PBASIC command that is not available to us in the Innovation First Robot Controller. Only a small number of the PBASIC commands are actually of use to us.

The BUTTON command works on a physical pin. The BS2SX our robot programs run on doesn't have access to any of the inputs and outputs on the RC.

p4_sw_aux1 is aliased to a bit in either oi_swA or oi_swB which is passed to us via the SERIN command. You will need to do something like what PyroPhin said to do.
__________________
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
  #5   Spotlight this post!  
Unread 10-01-2003, 01:56
Noah's Avatar
Noah Noah is offline
Code Monkey
#0861 (The Gondobots)
Team Role: Programmer
 
Join Date: Apr 2002
Location: Venice, California
Posts: 139
Noah has a spectacular aura aboutNoah has a spectacular aura about
Send a message via AIM to Noah
Probably the easiest way to do what you want to would be something like this (I'm not even going to try for proper syntax, so watch out):

MainLoop:
Serin (blah blah blah)
If kill_switch then skip_all:
blah
blah 'code to do stuff
blah
blah
blah 'code to do more stuff
blah
skip_all:
serout (pwm1, pwm2, etc.)
Goto MainLoop:


This was written (poorly, by a programmer who hasn't slept in days) in "old-style" PBASIC... 2.0, whoo... so.. tired... eyes so heavy... must program robot... make it clean my room... ::yawn::
__________________
"It's broken? NOOAAHH!!! This is your doing, isn't it!"

"We can fix it in the software!"
"It's a BROKEN GEAR!"
  #6   Spotlight this post!  
Unread 10-01-2003, 18:11
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
whats with the excessive use of the serouts? you can route anything you need through the one statement if you code it right

(im really just curious, not being a smartypants)
~Pyro
__________________
Squee!
-=-=-=-==-=-=-=-==-=-=-==-
Team 263, Aftershock:
Alumni, guy who comes back and fixes Krass's mistakes
  #7   Spotlight this post!  
Unread 10-01-2003, 22:20
rosebud rosebud is offline
Registered User
#0115 (MVRT)
 
Join Date: Sep 2002
Location: California
Posts: 24
rosebud is on a distinguished road
more help

hmmm...thanks for the alternate advice, but whats wrong with what i wrote? i hate unsolved programming bugs. they keep me up at night, and when i fall asleep its to dream of possible reasons for the bug. also, my team mates and i were wondering what the difference was between using an if statement or a button statement. i suppose all the loop stuff... could it do with an interrup or something like in java?
thanks

the multiple serouts are to output neutral values to all the the motors to turn everything off. if u stop outputting everything, will the motors stop or stay the same as they were before the program went into an infinite loop?
  #8   Spotlight this post!  
Unread 10-01-2003, 22:58
Damian Manda's Avatar
Damian Manda Damian Manda is offline
The Damian
no team
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2003
Location: Fort Collins, CO
Posts: 154
Damian Manda has much to be proud ofDamian Manda has much to be proud ofDamian Manda has much to be proud ofDamian Manda has much to be proud ofDamian Manda has much to be proud ofDamian Manda has much to be proud ofDamian Manda has much to be proud ofDamian Manda has much to be proud ofDamian Manda has much to be proud of
Send a message via AIM to Damian Manda
Maybe you could try posing this in the programming forum if you wan more responses. That seems to be where it belongs.
  #9   Spotlight this post!  
Unread 11-01-2003, 04:04
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,245
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
Re: more help

Quote:
Originally posted by rosebud
hmmm...thanks for the alternate advice, but whats wrong with what i wrote? i hate unsolved programming bugs. they keep me up at night, and when i fall asleep its to dream of possible reasons for the bug. also, my team mates and i were wondering what the difference was between using an if statement or a button statement. i suppose all the loop stuff... could it do with an interrup or something like in java?
thanks
I can't explain why your eduBot code works. Maybe you could post that code for me to analyze too. But I do know why it won't work on the full sized robot controller. Please reread my previous post. YOU CANNOT USE THE BUTTON COMMAND IN THIS APPLICATION (the innovation first full size robot controller.)

Just to dig a little further: the PIN parameter on your BUTTON command (p4_sw_aux1) is a bit sized variable. Which means that when the BUTTON command is executed, it will sometimes read pin 0 and sometimes pin 1 (depending upon the state of the switch on the OI). I don't know what, if anything, is connected to pin 0 inside the RC, but pin 1 is the pin the serin command uses to read its data from the master microprocessor. In either case, you're NOT reading aux switch 1 on port 4 on the operator interface which is what I believe was your intention.

As for the target state parameter, I'm afraid I don't know which way it's going to work. I think I saw the same conflicting information you saw: 1) was in the command description, and 2) was from the example code. Am I correct? I don't know of any way (using either the eduBot or the full sized robot controller) to check which way it will work, but my team has one of Parallax's BOE 'Bots. Maybe if I get a round tuit one of these days, I will check it out.
__________________
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 : 11-01-2003 at 04:27.
  #10   Spotlight this post!  
Unread 11-01-2003, 13:34
rosebud rosebud is offline
Registered User
#0115 (MVRT)
 
Join Date: Sep 2002
Location: California
Posts: 24
rosebud is on a distinguished road
hmmm... now im really confused. from the pbasic manual the first parameter is the name/alias of the pin it will be gathering information from, not the actual number of the pin it should be looking at. also, ive used the button command numerous times and had it work, both with the edurobot and the full sized rc, on the joystick buttons and switches hooked up to a port on the operator interface. however, im curious why u say the button command isnt valid for bs2sx. can u please refer me to a manual or something so i can look it up? id really appreciate solving this problem. ill also be posting my original message under programing. thanks!
  #11   Spotlight this post!  
Unread 12-01-2003, 00:05
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,245
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
Rosebud,

Have you read the Innovation First documentation? Remember, the control system was built by Innovation First. They happened to use the Parallax BASIC Stamp 2sx processor, but we have to live within the architecture they chose.

Here is the list of some documents you should be familiar with:
Overview:
  • Control System Overview
Quick Start Guides:
  • Full-Size Control System Quick Start Guide
  • EDU Control System Quick Start Guide
  • EDU Default Software Quick Start Guide
Reference Guides:
  • Full-Size RC Reference Guide
  • Operator Interface Reference Guide
  • EDU-RC & Motherboard Ref Guide
  • Programming Reference Guide
All of these are available at innovationfirst.com.

At the end of the Programming Reference Guide, they have a list of PBASIC commands which are valid for the IFI control system. BUTTON is NOT on the list.
__________________
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 : 12-01-2003 at 10:10.
  #12   Spotlight this post!  
Unread 12-01-2003, 02:02
nwagers nwagers is offline
Registered User
#0240 (Mach Vee)
 
Join Date: Oct 2001
Location: Monroe, MI
Posts: 88
nwagers is an unknown quantity at this point
Send a message via AIM to nwagers Send a message via Yahoo to nwagers
My question is, why do you need the BUTTON command? I don't see much functionality to an auto-repeat button with a debounce feature
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
Looking for some help with buttons and pins... Amanda Morrison General Forum 4 26-02-2003 17:32
buttons (continued from post in electrical) rosebud Programming 3 11-01-2003 17:34
Assigning Joystick buttons.... archiver 2001 5 24-06-2002 00:59
Where do the stop buttons go??? archiver 2001 0 24-06-2002 00:35
How many buttons??? purplehaze357 Championship Event 0 18-04-2002 23:54


All times are GMT -5. The time now is 20:49.

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