Go to Post Elevator speeches too - everyone should have one. - Swan217 [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 11-01-2003, 13:37
rosebud rosebud is offline
Registered User
#0115 (MVRT)
 
Join Date: Sep 2002
Location: California
Posts: 24
rosebud is on a distinguished road
buttons (continued from post in electrical)

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.

**ive been informed that the button command is not valid for us. any thoughts?

*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,P
B_mode,packet_num,p2_y,p1_y,p4_y,p3_y,p2_wheel,p1_
wheel,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 11-01-2003, 14:47
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
That is correct, the BUTTON command is not valid as it relies on having a switch hooked up to one of the pins on the Stamp, which they aren't. What you need is a simple if statement.

2.0:
...
if p4_sw_aux1=0 then dontKill
gosub killLoop
dontKill:
...
serout
goto mainloop

killLoop:
if p4_sw_aux1=1 then keepKilling
return
keepKilling:
Serin...
Serout...
goto killLoop:


2.5:
...
if p4_sw_aux1=1 then gosub killLoop
...
serout
loop

killLoop:
do
serin...
serout...
while p4_sw_aux1=1
return
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
  #3   Spotlight this post!  
Unread 11-01-2003, 17:24
rosebud rosebud is offline
Registered User
#0115 (MVRT)
 
Join Date: Sep 2002
Location: California
Posts: 24
rosebud is on a distinguished road
Question

then why did my other programs work? on the operator interface, aren't all the pins connected? how else can information from the joysticks and everything else be used? isnt the debug program supposed to have names for all the pins so we can use them? id appreciate a more detailed explanation cause im still kinda confused.

also, i have another question not really connected. how different are the analog inputs treated than the digital. my point: if i run out of digital inputs, could i make the computer pretend the analog inputs are digital? so i could use more sensors and limit swtiches.

thanks
  #4   Spotlight this post!  
Unread 11-01-2003, 17:34
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
Quote:
Originally posted by rosebud
then why did my other programs work? on the operator interface, aren't all the pins connected? how else can information from the joysticks and everything else be used? isnt the debug program supposed to have names for all the pins so we can use them? id appreciate a more detailed explanation cause im still kinda confused.

also, i have another question not really connected. how different are the analog inputs treated than the digital. my point: if i run out of digital inputs, could i make the computer pretend the analog inputs are digital? so i could use more sensors and limit swtiches.

thanks

It's a complex issue, but here's a quick explanation of why you can't use BUTTON:

The BASIC Stamp that we use (the 2sx) is designed for a whole lot more than just the robot contollers. In other applications, EE guys will connect a switch directly between ground, +5V and a pin on the Stamp.

This is the intention of the BUTTON command. The InnovationFirst controllers, however, do not work this way. All of the switches, analogs, etc, are connected to a separate uP inside the RC. How exactly they are connected is not documented, but it doesn't really matter. What matters is that this separate uP processes all the inputs from both the OI and the RC. This uP then connects to the Stamp via a standard RS-232 signal over one of the pins. This is where the Serin/Serout comes from.

The only things directly connected to the Stamp that you should EVER touch are pins 7-15. Pin 7 is the basic run LED, and 8-15 are the various other LEDs you can control. Everything else comes in mass through the serin command and becomes individual bits in variables instead of actual pins.



As for using an analog for a digital switch, you can definately do it. Two years ago, we ran out of switches on the OI, so I wired a little toggle switch between +5V and one of the analog ins. There was also an LED in series with it, but that doesn't matter. When the switch is off, the analog will read 127. When it is on, it will read something else. What that something else is depends on the amount of resistance in your circuit. In my case the LED caused us to get a value of 160-ish when on and 127 when off.
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php

Last edited by rbayer : 11-01-2003 at 17:36.
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
ChiefDelphi Forums Community Bulletin Brandon Martus CD Forum Support 0 30-03-2003 23:00
ChiefDelphi Forums Community Bulletin Brandon Martus CD Forum Support 0 12-01-2003 22:19
ChiefDelphi Forums Community Bulletin Brandon Martus CD Forum Support 0 05-01-2003 22:04
ChiefDelphi Forums Community Bulletin Brandon Martus CD Forum Support 0 05-05-2002 22:07
ChiefDelphi Forums Community Bulletin Brandon Martus CD Forum Support 0 28-04-2002 22:53


All times are GMT -5. The time now is 14:57.

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