Go to Post GP makes us all on one and the same team. They understand that in order for any of us to succeed, we need to help out where we can. It is why you will see so many other teams helping a team with a failing robot, buggy software, team strategy, etc. - 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

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 19-01-2008, 20:21
Tim Skloss's Avatar
Tim Skloss Tim Skloss is offline
Dr. Skloss
FRC #0930
Team Role: Parent
 
Join Date: Jan 2002
Rookie Year: 2000
Location: Waukesha, WI, USA
Posts: 73
Tim Skloss is a jewel in the roughTim Skloss is a jewel in the roughTim Skloss is a jewel in the roughTim Skloss is a jewel in the rough
Use a Potentiometer to Tune your programs

We implemented this simple idea and it worked so well that I though it should be posted for others to steal.

Ever need to tune a value in your program to make the output behave in particular manner but get frustrated by having to edit-compile-download every time? Then this is for you.

Get a low-cost 5 to 100 k-ohm single-turn potentiometer (RadioShack has them). Connect to a PWM cable as shown in the picture below.

Connect the cable to an analog input and you are done with the hardware.

In software, add the code below into your default and autonomous functions to read the pot:

#define TWEAK_POT rc_ana_in16 //we use channel 16

unsigned int tweak_pot; //variable declaration

tweak_pot = (unsigned int)Get_Analog_Value(TWEAK_POT);

Now you are all set to use the tweak_pot variable in your code. Remember the following points:

-the analog value will be read as a number between 0 and 1023. Zero will be when the potentiometer is rotated full counter-clockwise if you have it connected as in the picture.
-if you need the number converted to a value compatible with a PWM output (8-bit), divide by 4. (new_value = (unsigned char)(tweak_pot >> 2)
-the tweak_pot value is updated every time the loop is executed giving you real-time control of the variable in the RC.
-You can do a similar effect with a joystick on the operator interface, but that input will be limited to a range of 0 to 255.

We have used this approach to great advantage when tuning our autonomous PID code.

You can use more than one tweak pot--you are limited to 16 by the RC.

Happy coding and Good Luck Teams!
Attached Thumbnails
Click image for larger version

Name:	tweak_pot.jpg
Views:	80
Size:	81.8 KB
ID:	6074  
__________________
---------------
FIRST Mentor and Team Leader
C.O.R.E 2062 a NASA, GE Volunteers and Rockwell Automation FRC Team
  #2   Spotlight this post!  
Unread 21-01-2008, 08:43
Kingofl337's Avatar
Kingofl337 Kingofl337 is offline
You didn't see anything....
AKA: Adam
FRC #0501 (Power Knights)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 1998
Location: Manchester, NH
Posts: 861
Kingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond repute
Send a message via Yahoo to Kingofl337
Re: Use a Potentiometer to Tune your programs

Team 40 Does this as well but using the OI for wireless operation. This system works great for PID tuning.
__________________
FIRST Team 501 PowerKnights - Mentor
FIRST Team 40 Checkmate - Mentor Alum
FIRST Team 146 Blue Lightning - Alumni
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
i would like your opinion on my programs CmptrGk Programming 14 14-10-2004 21:28
Favorite FF tune Raven_Writer Chit-Chat 5 22-09-2004 07:53
Video Editing Programs...share what you use and why... Alexander McGee 3D Animation and Competition 25 09-01-2003 22:27
Code for use of a potentiometer wonderdog5 Programming 2 06-11-2002 23:15
Code for use of a potentiometer wonderdog5 OCCRA 2 06-11-2002 23:15


All times are GMT -5. The time now is 18:39.

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