Go to Post Build a student a robot and it will keep him/her busy for a few days in the spring. Teach a student how to build(design, wire, program) a robot and they will stay away from home, use some really strange language and wear funny clothes the whole year long. - Al Skierkiewicz [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #10   Spotlight this post!  
Unread 02-02-2003, 01:35
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: Working with Potentiometers

if stack_pos - sw_stacker > 10 then pos_error
This statement is fine as long as stack_pos is greater than sw_stacker; and the jump will be executed when stack_pos is more than 10 greater than sw_stacker. BUT if stack_pos is less than sw_stacker, then the result of the subtraction will be negative, and since the BASIC Stamp does UNSIGNED comparisons, THE JUMP PATH WILL ALWAYS BE TAKEN. It would be safer to say "if stack_pos > sw_stacker + 10 then pos_error".

if abs(stack_pos - sw_stacker) < 10 then done_stack
To reiterate, this test will only be made when stack_pos is between sw_stacker and sw_stacker +10. And this jump will ALWAYS be taken UNLESS stack_pos EQUALS sw_stacker + 10.

Thus, the following section will only be executed when stack_pos EQUALS sw_stacker + 10:

neg_error:
error = (sw_stacker - stack_pos)
sw_stacker = 127 - (4 * error) / 10)

... and this, only when stack_pos IS GREATER THAN sw_stacker + 10:

pos_error:
error = (stack_pos - sw_stacker)
sw_stacker = 127 + (4 * error) / 10)

I don't think this is what you intended.

This should do more like what you expected:
Code:
	if abs(stack_pos - sw_stacker) < 10 then done_stack
	if stack_pos > sw_stacker + 10 then pos_error
neg_error:
	error = (sw_stacker - stack_pos)
	sw_stacker = 127 - (4 * error) / 10)
pos_error:
	error = (stack_pos - sw_stacker)
	sw_stacker = 127 + (4 * error) / 10)
Now, I'm not sure whether your code for neg_error and pos_error is correct, but this should get you closer, at least.
__________________
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-02-2003 at 01:38.
 


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
Whose working this summer? Frank(Aflak) Chit-Chat 20 28-05-2003 11:35
pic: Working Hard, As Always CD47-Bot Extra Discussion 4 14-04-2003 09:07
Are ramp blocker bots working? Jim S Regional Competitions 42 22-03-2003 20:55
Please identify these two hard working hula 'botters! archiver 2001 2 24-06-2002 03:37
Anyone working on game/mod and looking for a 3d modeller? Devil's Kid 3D Animation and Competition 5 21-04-2002 15:08


All times are GMT -5. The time now is 16: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