View Single Post
  #6   Spotlight this post!  
Unread 06-02-2007, 09:16
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
Re: limiting voltage to the speed controller

If it was me, I don't think I'd use a lookup table. I have no idea how to set that up in easyC (which is part of why I don't use it all the time). In any case, here's my solution.

If you take the joystick input and subtract 127, you get a -127 to 127 value. Divide that by 127 to get a -1 to 1 value. Then, you multiply that by the range you want the output to be--if you want it to be half what it is, the range would be 127 / 2 = 64ish. So you'd multiply by 64. That will give you a -64 to 64 value. Then, add 127 to center it around 127 again, for the PWM output, and output it.

I've attached a screen shot of the code I use. I multiplied the value first, then divided, but that shouldn't change the answer.

JBot
Attached Thumbnails
Click image for larger version

Name:	easyC scaled output.JPG
Views:	45
Size:	29.3 KB
ID:	5020  
__________________
Aren't signatures a bit outdated?