Go to Post You can either suck up a lot of oxygen, or you can contribute to our communal knowledge. The choice is yours. - dlavery [more]
Home
Go Back   Chief Delphi > Technical > Technical Discussion
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 08-02-2002, 20:15
Joelster Joelster is offline
Registered User
#0758 (Roboticats)
 
Join Date: Feb 2002
Location: Blenheim
Posts: 11
Joelster is an unknown quantity at this point
A quick question

I know i should post this in the techinical but i need an answer now. Here is my question

We are trying to extend and retract a cylinder with a button push. We've already made it work well with two different buttons, but now we're just trying to make the joystick more user-friendly. We have all programmed in C++ and Turing languages, and have tried to incorporate that type of logic in our programs, but have failed miserably. For example, logically one would think that "p1_sw_top = 1" means that the button is pressed, but we have found that it is actually "p1_sw_top = 0". Does Basic not allow If statements inside other If statements?

This is part of the program, and we want to know what part doesn't work. We have declared count1 and assigned a value of 1 to it at the beginning of the program, outside the main loop.

if p1_sw_top = 0 then turn:
if count1=1 then left:
relay1_fwd = 0
relay1_rev = 1
count1 = 2
left:
if count1=2 then right:
relay1_fwd = 1
relay1_rev = 0
count1 = 1
right:
turn:

Another example program that we have tried is :

'if ((p1_sw_top = 0) &~ (count1=2))then turn:
' relay1_fwd = 1
' relay1_rev = 0
' count1 = 2
'turn:

'if (p1_sw_top = 0) & (count1 = 2) then turn1:
' relay1_fwd = 1
' relay1_rev = 0
' count1 = 1
'turn1:

For some reason, the controller doesn't wait for a button to be pressed, it just sees "count1 = 1," and extends.


Any help and/or suggestions would be greatly appreciated.
  #2   Spotlight this post!  
Unread 08-02-2002, 21:14
Radiant Phoenix's Avatar
Radiant Phoenix Radiant Phoenix is offline
Registered User
#0481 (DART)
 
Join Date: Jan 2002
Location: Richmond, Ca
Posts: 17
Radiant Phoenix is an unknown quantity at this point
Quote:
if p1_sw_top = 0 then turn:
if count1=1 then left:
relay1_fwd = 0
relay1_rev = 1
count1 = 2
left:
if count1=2 then right:
relay1_fwd = 1
relay1_rev = 0
count1 = 1
right:
turn:
Ummm, looking at it, I can't see any problems, except for the 2. The values have to be 1 or 0 or it doesn't work. If your adding or subtracting its a different story of course.

What is changing the value of count1?

Athena

__________________
"Not all those who wander are lost." ~J.R.R. Tolkien~
" 'I wonder if they do exist...'
'Who?'
'The Elves.'
'Of course they exist- I'm the First one.' "
~The Vendori Chronicles; By Athena~


De Anza Robotics Team
  #3   Spotlight this post!  
Unread 08-02-2002, 23:07
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
Re: A quick question

Quote:
Originally posted by Joelster
if p1_sw_top = 0 then turn:
Try using the debug feature of PBASIC(see the manual) to output the values of count1 and p1_sw_top to see what is going on...
__________________
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...
  #4   Spotlight this post!  
Unread 09-02-2002, 00:13
s_alaniz s_alaniz is offline
Registered User
#0057 (Leopards)
 
Join Date: Jun 2001
Location: Houston, Tx
Posts: 73
s_alaniz is an unknown quantity at this point
OK you said that "p1_sw_top=0" occurs when the switch is pressed
If that is the case then the first program skips to "turn:" when the button is drepressed and doesn't execute the commands.
(Did you intend "p1_sw_top=1" as in the switch is NOT being pressed?) You said it executes the following commands without a button being pressed.... well that's what's you've got it programmed to do.



SO if you're NOT pressing the top button, and count1 =1 then the program skips to "left:" , fails the "count1=2" test and executes the "relay1_fwd = 1" and " relay1_rev = 0 " commands...reaffirms "count1 = 1 " (which it already is) and falls through the "right:" and "turn:" labels and continues to the rest of the program.
if no button is pushed and count1 is not changed externally, it repeats the sbove sequence.
If you're NOT pressing the top button, and count1=2 then the program fails the "count1=1" test and continues and sets "relay1_fwd = 0" and relay1_rev = 1" reaffirms count1=2 (which it already does) drops through "left:" taed the branch from "if count1 = 2 then right:" goes to "right:" drops through "turn:" and continues on throught the rest of the program.


In the second program... if you're NOT pressing a button, both conditional statements "'if ((p1_sw_top = 0) &~ (count1=2))then turn: " and "if (p1_sw_top = 0) & (count1 = 2) then turn1: " FAIL to branch (because p1_sw_top = 0 is false or "0" unless you push the button) and the program executes all the statements ... well you get the idea.

Anyone read this differently? I get confused easily.

Best wishes


Steve Alaniz


"What good is technology if you can't abuse it?" - Ted Forth
  #5   Spotlight this post!  
Unread 09-02-2002, 09:38
Unsung FIRST Hero
Warren Boudreau Warren Boudreau is offline
Registered User
FRC #0180 (Team SPAM)
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 1999
Location: Stuart, FL
Posts: 354
Warren Boudreau has a reputation beyond reputeWarren Boudreau has a reputation beyond reputeWarren Boudreau has a reputation beyond reputeWarren Boudreau has a reputation beyond reputeWarren Boudreau has a reputation beyond reputeWarren Boudreau has a reputation beyond reputeWarren Boudreau has a reputation beyond reputeWarren Boudreau has a reputation beyond reputeWarren Boudreau has a reputation beyond reputeWarren Boudreau has a reputation beyond reputeWarren Boudreau has a reputation beyond repute
Your code looks about right. You may have a hardware problem.

Are you using a joystick or a switch wired in to the p1_sw_top pin on port 1? Using the joystick, you should get 0 when the button is not depressed and 1 when it is. It's easy enough to throw in a debug to verify that.

If you are using a switch wired in to the port make sure that you are wired to the normally open side of the switch. If the switch has three tabs on it, usually one will have NO and another will have NC next to them. NO is normally open, NC is normally closed. The third tab wil go to ground.

Once again, debug statements are the way to go. I always check out the code operation without any PWMs or relays plugged in to the Robot Controller and use debug statements to verify operation. This tip comes from a bitter experience as the team rookie coder when I loaded up my first ever piece of code and promptly destroyed our lifting mechanism. Ouch, that hurt.

I hope this helps.
__________________
Warren B

Pool Noodles. They're not just for bumpers anymore.
  #6   Spotlight this post!  
Unread 09-02-2002, 16:00
Joelster Joelster is offline
Registered User
#0758 (Roboticats)
 
Join Date: Feb 2002
Location: Blenheim
Posts: 11
Joelster is an unknown quantity at this point
Angry Another flaw

if count1= 1 | p1_sw_top = 0 then do:
relay7_fwd = 1
goto loop:
do:

if count1= 0 | p1_sw_top = 0 then do2:
relay7_fwd = 0
goto loop:
do2:

if p1_sw_top = 0 then s:
loop:
if p1_sw_top = 1 then j:
goto red:
j:
goto loop:
red:
if count1 = 1 then yo:
count1=1
yo:
if count1 = 0 then yo2:
count1 = 0
yo2:
s:

This is our other flaw.....think you can make it work??? please reply asap!!
  #7   Spotlight this post!  
Unread 10-02-2002, 09:09
s_alaniz s_alaniz is offline
Registered User
#0057 (Leopards)
 
Join Date: Jun 2001
Location: Houston, Tx
Posts: 73
s_alaniz is an unknown quantity at this point
I only did a quick read but I think I see two problems:



loop:
if p1_sw_top = 1 then j:
goto red:
j:
goto loop:



If p1_sw_top = 1 is true, then you have the program stuck in an infinite loop until you change p1_sw_top = 1 to false. That will probably shut down your robot since you exceed the time limit on the watchdog timer.. (delta T)


if count1 = 1 then yo:
count1=1
yo:
if count1 = 0 then yo2:
count1 = 0
yo2:
s:

if count1 = 0 you then change count1 to 1 go past the yo: label, test if count1 = 0 which it never will (since you just changed it to 1) and then change it with count1 = 0 so you're right back with count1 = 0 just like you started. I think you intended to have an unconditional "goto s:" between "count1 = 1" and "yo:"



Good luck... I'm off to N.O. for Mardi Gras!


Steve Alaniz


" What good is technology if you can't abuse it?" - Ted Forth
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
Quick <hr> question Jack Website Design/Showcase 1 31-01-2003 22:19
Quick Optical Sensor Question zorro Technical Discussion 10 21-01-2003 06:39
To all the ladies in the hiz-ous!! lol a quick question archiver 2001 1 24-06-2002 02:12
Quick Question archiver 2001 5 24-06-2002 00:08
Quick Question, i guess Andrew Rudolph Motors 1 12-08-2001 14:39


All times are GMT -5. The time now is 19:34.

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