Go to Post Life can be painfully short and you never know how things could change in an instant. It never hurts to say thank you. - Karthik [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-02-2003, 07:53
cammie825 cammie825 is offline
Registered User
#0825 (Maximum Velocity)
 
Join Date: Jan 2003
Location: Galax, VA
Posts: 8
cammie825 is an unknown quantity at this point
Send a message via ICQ to cammie825
Yes This IS a Beginner's Question

I know that everyone is in deep with their programs at this point, but I'm having problems programming a dead zone into our joysticks. When we put the program in, it seemed to not respond all the time. Like it would go backwards, and then it would decide that it wouldn't go backwards anymore. I'm not really sure. Here's what we put in:

If 117<p1_y<137 THEN stop_p1_y
If 117<p3_y<137 THEN stop_p3_y
goto end_zero

stop_p1_y:
p1_y = 127
goto end_zero

stop_p3_y:
p3_y = 127
goto end_zero

end_zero:

If you could help, that would be great.
Thanks!
  #2   Spotlight this post!  
Unread 11-02-2003, 08:01
cammie825 cammie825 is offline
Registered User
#0825 (Maximum Velocity)
 
Join Date: Jan 2003
Location: Galax, VA
Posts: 8
cammie825 is an unknown quantity at this point
Send a message via ICQ to cammie825
One more thing to note

What it actually seemed like it was doing, was that the port 3 joystick was going UP to 137, or down to 117, and THEN cutting off. Which is odd, but that's what it felt like it was doing.

Thanks Again.
  #3   Spotlight this post!  
Unread 11-02-2003, 08:01
Gadget470's Avatar
Gadget470 Gadget470 is offline
A Fire Outside
AKA: Brandon Joerges
no team (Alpha Omega)
Team Role: Alumni
 
Join Date: Jan 2002
Rookie Year: 2000
Location: Madison Heights, MI
Posts: 1,000
Gadget470 is a jewel in the roughGadget470 is a jewel in the roughGadget470 is a jewel in the roughGadget470 is a jewel in the rough
Send a message via ICQ to Gadget470 Send a message via AIM to Gadget470
rbayer is really the authority on this one, but this is my thought. (I havn't used pbasic much and cannot test this threory from where I'm at)

Code:
If 117 < p1_y & p1_y < 137 THEN stop_p1_y
If 117 < p3_y & p1_y < 137 THEN stop_p3_y
goto end_zero
Having the checking seperated may be your problem.
  #4   Spotlight this post!  
Unread 11-02-2003, 08:07
cammie825 cammie825 is offline
Registered User
#0825 (Maximum Velocity)
 
Join Date: Jan 2003
Location: Galax, VA
Posts: 8
cammie825 is an unknown quantity at this point
Send a message via ICQ to cammie825
tried that

I just reworked the code, the way you suggested, and it's still doing the same thing. Going UNTIL it gets to 117 or 137, then cutting itself off.
Thanks though!
  #5   Spotlight this post!  
Unread 11-02-2003, 09:41
seanwitte seanwitte is offline
Registered User
None #0116
Team Role: Engineer
 
Join Date: Nov 2002
Location: Herndon, VA
Posts: 378
seanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant future
Send a message via AIM to seanwitte
bitwise AND operator

Quote:
Code:
If 117 < p1_y & p1_y < 137 THEN stop_p1_y
If 117 < p3_y & p1_y < 137 THEN stop_p3_y
goto end_zero
Ampersand (&) is the bitwise logical AND operator. You'd have to use the word AND instead.

Code:
IF (117 < p1_y) AND (p1_y < 137) THEN p1_y = 127
IF (117 < p3_y) AND (p3_y < 137) THEN p3_y = 127

or, if you're using a symmetric deadband:

cDeadband CON 10

IF ABS(p1_y - 127) < cDeadband THEN p1_y = 127
IF ABS(p3_y - 127) < cDeadband THEN p3_y = 127
<edited>
Sorry, figured most teams would be using the new compiler. We haven't had any problems and it really is a lot more productive than the old version. (knocking on wood heard in background)
</edited>

Last edited by seanwitte : 11-02-2003 at 12:14.
  #6   Spotlight this post!  
Unread 11-02-2003, 09:51
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: 8,567
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
Besides the errors in your syntax (which have already been pointed out), there is an error in your logic.

Lets assume that p1_y is 136 and p3_y is 118. If you follow your code through, you will set p1_y to 127 and then goto end_zero. p3_y will never be set. You need to rearrange your statements.

This is assuming that you are using the pbasic 2.0 syntax, which I assume becasue you used it in your first post. If you don't mind using the pbasic 2.5 syntax, then what seanwitte posted would work and is a lot simpler.
  #7   Spotlight this post!  
Unread 11-02-2003, 11:52
Jnadke Jnadke is offline
Go Badgers!
#0093
Team Role: Alumni
 
Join Date: Jan 2002
Location: Appleton, WI
Posts: 775
Jnadke is on a distinguished road
Send a message via ICQ to Jnadke Send a message via AIM to Jnadke Send a message via Yahoo to Jnadke
Re: Yes This IS a Beginner's Question

Quote:
Originally posted by cammie825
I know that everyone is in deep with their programs at this point, but I'm having problems programming a dead zone into our joysticks. When we put the program in, it seemed to not respond all the time. Like it would go backwards, and then it would decide that it wouldn't go backwards anymore. I'm not really sure. Here's what we put in:
Thanks!

The problem is, you're not giving the stop_p3_y function a chance to execute. Also, PBASIC doesn't allow multiple comparisons (117<p1_y<137).

The easiest way is to check how far away it is from the middle (127) and compare it with a zone value. Usually around 6-10 is a good DEAD_ZONE value.

Here's an example of the drive code I used on TOBOR V last year. We had a tank-style drivetrain.

Code:
Drive:

left_motor:
	if (abs(p1_y - 127) > DEAD_ZONE) then right_motor
	p1_y = MOTOR_OFF

right_motor:
	if (abs(p3_y - 127) > DEAD_ZONE) then Drive_return
	p3_y = MOTOR_OFF

Drive_return:
__________________
The best moments of our lives fall in two categories: those that did happen and those that did not.
  #8   Spotlight this post!  
Unread 11-02-2003, 17:22
cammie825 cammie825 is offline
Registered User
#0825 (Maximum Velocity)
 
Join Date: Jan 2003
Location: Galax, VA
Posts: 8
cammie825 is an unknown quantity at this point
Send a message via ICQ to cammie825
Thanks You Guys!

Thank you all, EVER so much for help me out.

I really haven't been allowed to program too much this year, and now it's all coming at me at one. The robot is now running properly.. Thanks!!!

and, just so ya know, I'll probably have questions of this same nature later on.. So, go ahead and be ready! j/k
  #9   Spotlight this post!  
Unread 11-02-2003, 22:16
Anthony Kesich's Avatar
Anthony Kesich Anthony Kesich is offline
Programmer Turned Engineer
AKA: SonKenshin
#1097 (Site 3 Engineernig)
Team Role: Leadership
 
Join Date: Jan 2003
Rookie Year: 2003
Location: Sacramento, CA
Posts: 186
Anthony Kesich has a spectacular aura aboutAnthony Kesich has a spectacular aura about
Send a message via AIM to Anthony Kesich
Lightbulb here is the easiest way in 2.0

here is the easiest way to do this in 2.0:

Code:
 If p1_y >= 137 or p1_y <= 117 then skipleftneu:
  left_drive = 127
skipleftneu:
 If p2_y >= 137 or p2_y <= 117 then skiprightneu:
  right_drive = 127
skiprightneu:
it works very well because you dont have to worry about order and goto statements, because those just get confusing. I'm using this and it works just great.

-Kesich
__________________
C is screwing up my English--I'm ending all my sentences in semi-colons;

Horray for most things! -George Carlin

"Sure, I'll play rugby. Besides, I have a lot of experience running from really big guys who want to cream me." -Me, Freshman year
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
question on launching boxes 2PI4Julia Rules/Strategy 4 18-01-2003 10:17
my idea of a question forum... Ken Leung General Forum 12 30-11-2002 12:17
MnM EASY Question of the Day Winners! Mike Bonham General Forum 22 03-05-2002 21:21
Chief Delphi Site Question Mike Bonham General Forum 1 16-02-2002 22:18
Rookie Programmer has question about the default code DanL Programming 3 26-01-2002 19:59


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

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