|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||||
|
|||||
|
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! |
|
#2
|
||||
|
||||
|
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.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |