Go to Post "If all else fails, use a bigger hammer" - Steve Florence - Logan Byers [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 08-02-2005, 22:41
Workaphobia Workaphobia is offline
Registered User
AKA: Jon
FRC #1546 (Chaos Inc.)
Team Role: Alumni
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Long Island
Posts: 26
Workaphobia will become famous soon enough
Re: Negative numbers?

Quote:
Originally Posted by probizzle
Since pwm01 is an unsigned char and the whole thing will be converted to a char later, it does not matter that you are doing integer division.
Actually when I said it would partly help him, I meant because it's pretty hard to overflow a float by multiplying integers.
  #2   Spotlight this post!  
Unread 09-02-2005, 01:08
Calvin Calvin is offline
Registered User
no team
 
Join Date: Feb 2005
Location: Portland OR
Posts: 105
Calvin has a spectacular aura aboutCalvin has a spectacular aura about
Re: Negative numbers?

Thanks for the fast reply, I'll test the revisions tomorrow at school and see if it works.
  #3   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!
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
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