Go to Post You are given a goal with some simple restrictions. That's it. No one really cares how you get it done, just the fact that you get it done. - Max Lobovsky [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
  #7   Spotlight this post!  
Unread 09-02-2005, 10:46
Rocketboy's Avatar
Rocketboy Rocketboy is offline
Programmer at work, Pilot by heart
AKA: Daniel Schoessler
FRC #1317 (Digital Fusion)
Team Role: College Student
 
Join Date: Apr 2004
Rookie Year: 2003
Location: Westerville, Ohio
Posts: 67
Rocketboy will become famous soon enough
Send a message via ICQ to Rocketboy Send a message via AIM to Rocketboy
Re: Negative numbers?

I used the same exact process to debug my drive protocol. I wrote a "rampPWMs" feature which ramps the output once every loop. Heres the idea (not actual code):

Code:
getData

unsigned char driveRobot (motor, joystick, sensitivity){

set joystick = p1_y;
set motor = pwm01;
set sensitivity = 5;

if (the joystick is in the dead zone){
return 127
}

else if (the joystick is NOT in the dead zone){


   if (((joystick + sensitivity)is greater than (the motor value + sensitivity))
   && ((the motor value + sensitivity) < MAX_SPEED){
   // IF we get here the motor is accelerating, and has not reached it's goal
   yet.
   return motor + sensitivity;
   }


   else if (((joystick + sensitivity) is less than (the motor value - sensitivity)) 
   && ((the motor value - sensitivity) > MIN_SPEED){
   // IF we get here the motor is decellerating, and has not reached it's goal
   yet.
   return motor - sensitivity;
   }


   else return joystick // We have reached our goal PWM setting.

}

else FUBAR;

}

As you might see, this function adds a value named "sensitivity" to the "current motor value" each time it goes through the loop until the value is within "range" (joystick +||- sensitivity) of the joystick. As sensitivity increases, the robot will accelerate faster, and vice-versa. I had to cast temporary int types to each variable to keep them from looping around.

The FUBAR case should never occur (where the joystick is neither in the dead zone nor out of it). But if there was a short in the electrical system or something the process could get FUBAR and the robot might do some strange things.

Anyway, I had the same problems you have until I cast in a signed variable type.
__________________
-- Unofficial Google Advocate --

I soloed my
"Skyhawk" before I even soloed my car!
 


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
Field Elements errors in part numbers Mike Martus Kit & Additional Hardware 0 08-01-2005 19:05
Pneumatic Part Numbers CyberWolf_22 Pneumatics 3 01-10-2004 11:19
A couple of noodle scratchers Cheese Head Programming 11 07-12-2002 09:59
Even more interesting numbers: Division of regional winners archiver 2001 8 24-06-2002 03:10
More interesting numbers...specific to big-ball matches archiver 2001 13 24-06-2002 02:51


All times are GMT -5. The time now is 07:09.

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