Go to Post A quote from the Southern California Regional Visitors guide: "If you are having problems the FIRST thing to do is ask your neighbor for help" - ChrisH [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
  #1   Spotlight this post!  
Unread 27-03-2007, 17:22
JBotAlan's Avatar
JBotAlan JBotAlan is offline
Forever chasing the 'bot around
AKA: Jacob Rau
FRC #5263
Team Role: Mentor
 
Join Date: Sep 2004
Rookie Year: 2004
Location: Riverview, MI
Posts: 723
JBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond repute
Send a message via AIM to JBotAlan Send a message via Yahoo to JBotAlan
Joystick filtering gone horribly wrong...help!

Hey all,

I was asked to make the robot have a curved response in the drive motors, i.e. pushing the joysticks halfway gets you about quarter speed, but pushing them full gets you full speed. I was advised that this will make the drivers' jobs easier. However, it seems to be making my job more complicated...

I have a basic lookup table solution in place right now...but it doesn't work. Ideally, I want to be able to input a number of points on the curve (right now, I have 7) and have the code extrapolate the points in between. I would be able to tweak this curve, adjust the constants in code, recompile, and blast the code down again to have filtered joysticks.

Now, at this point in time, I am getting strange results. The code I have is trying to set outputs to values like 360-something or greater, and I can't figure out why (I know it's out of range. I know PWMs only go up to 254...). I am seeing this code get more and more complex, and I need some help implementing KISS in this situation.

Here's the code I've got right now:
Code:
unsigned char DRV_GetFilteredValue(unsigned char joystick)
{
	static const unsigned char lookup[] = {127,135,140,145,165,200,254};
	int temp_joystick = (((int)joystick-127)/21.1);
	printf("temp_joystick = %d\r\n",(int)temp_joystick);
	printf("joystick is %d\r\n", (int)joystick);
	if (temp_joystick >= 7) { temp_joystick = 6; }
	if ((joystick < 130) && (joystick > 124)) {
		return 127;
	} else if (temp_joystick < 0) {
		printf("lookup[temp_joystick] = %d, lookup[temp_joystick-1] = %d, output is %d\r\n", (int)lookup[temp_joystick], (int)lookup[temp_joystick-1], (int)((joystick - lookup[temp_joystick-1])*(lookup[temp_joystick] - lookup[temp_joystick-1]) / 21) + lookup[temp_joystick-1]);
		return ((joystick - lookup[temp_joystick-1])*(lookup[temp_joystick] - lookup[temp_joystick-1]) / 21) + lookup[temp_joystick-1];
	} else {
		temp_joystick = -temp_joystick;
		printf("lookup[temp_joystick] = %d, lookup[temp_joystick-1] = %d, output is %d\r\n", (int)lookup[temp_joystick], (int)lookup[temp_joystick-1], (int)254-((joystick - lookup[temp_joystick-1]) * (lookup[temp_joystick] - lookup[temp_joystick-1]) / 21) + lookup[temp_joystick-1]);
		return 254-((joystick - lookup[temp_joystick-1]) * (lookup[temp_joystick] - lookup[temp_joystick-1]) / 21) + lookup[temp_joystick-1];
	}
}
(If you can weed through that, you get a cookie)

You don't even have to look at that code. I just need something that I can put in place to filter the joysticks.

Thanks in advance for any help you can provide.

And I'm willing to throw out the code I've got; I just need *something* to work.

JBot
__________________
Aren't signatures a bit outdated?
 


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
EMI Filtering Mike Betts Electrical 1 06-03-2007 15:38
pic: Dodgeball gone wrong. Bharat Nain Extra Discussion 6 23-04-2006 20:11
Genia and Mike's Walmart Frolic Gone Wrong MikeyP Chit-Chat 25 20-04-2005 20:21
Math Gone Wrong psquared Programming 10 23-01-2005 12:18
HELP! My 'Documents & Settings' Folder Is Gone... WITH ALL MY STUFF! Joe Matt Chit-Chat 3 28-10-2004 21:09


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

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