![]() |
Help with pots/interrupts
Arg! I've hit the wall. Unfortunately, the responsibility of getting all of our electronics/programming is heavily on me, and I've come to a dead end. I've gotten about 3 hours of sleep in as many days, and the deadline is approaching ... and the only reason I have time to post here is because I'm about to take a linear algebra test, and had to stop working on the robot temporarily for the night, so I'm somewhat streched for nerves, but here goes:
We're trying to use pots to get finer control. I put a multimeter on the ground/signal leads of the pwm cable it is attached to, and I get 0-10k Ohms varying like it should -- so it seems to me that the wiring is okay. It is plugged into analog input 1. In the program I say: Code:
printf ("The pot value is: %d\n", (int) rc_ana_in01);And, being held up in that matter, I turned to work on the autonomous mode. I had it working fine for the EduBot. I changed out the version for the FRC, and tried to get that working. After a while, I isolated the problem to figuring out that the Clock variable is 0 -- and never increases. The timer 1 interrupt is programmed, straight from Ken Watson as a matter of fact ... yet it doesn't increment. I realize some code might help, but as I said, I'm about to take a test and the code is on the team laptop, so I'll get around to it sometime tomorrow maybe. Thank you, A much distressed programmer. |
Re: Help with pots/interrupts
Code:
printf ("The pot value is: %d\n", (int) rc_ana_in01);Code:
unsigned int pot_value; |
Re: Help with pots/interrupts
two things with your pot.
it has to be wired to the +5V pin on one end, gnd at the other, with the signal on the middle terminal of the pot - at the analog in connector on the RC, the wires are black= gnd, red (middle) = +5 and white = signal. if you put a voltmeter on the center and gnd pins of the pot you should see it range from 0 to 5 VDC as you turn the pot (with the RC on) the RC is different from wireing pots to the OI - the RC needs to see an actual voltage. the other problem is you must use the 'get_analog_value' function to read the analog inputs - check the analog input section of the default users guide - the correct syntax is in there. (or just read Marks post for the right code cause he types faster than I do :c) |
Re: Help with pots/interrupts
Quote:
Anyway, I'll post that code now. Code:
static unsigned int Old_Clock = 0;Code:
// while (autonomous_mode) /* DO NOT CHANGE! */ |
Re: Help with pots/interrupts
Also, I don't know if it is a typo or not, but you should be using 100K ohm pots, not 10K, unless you only want 1/10th the resolution.
|
Re: Help with pots/interrupts
You can get some sleep after the robot ships.
Oh, wait you're a programmer! No sleep until after Nationals!!! As for your Clock... A likely reason for the non-interrupting interrupt is incorrect initialization. I assume you are using Kevin's edu_clock_demo_2 example? I'll run through the obvious. Since you are sleep deprived double check all these even if you are sure you did them already. - Are you calling Initialize_Timer_2(); from User_Initialization()? - Are you using any other code that might be trying to utilize Timer 2 as well(e.g., beacon s/w)? - Calling Timer_2_Int_Handler() from the interrupt handler in user_routines_fast.c? - Clearing the timer interrupt flag? - Make any mods to the clock_demo_2.c file? - Including "clock_demo_2.h" in user_routines.c? |
Re: Help with pots/interrupts
Quote:
|
Re: Help with pots/interrupts
Quote:
-Kevin |
Re: Help with pots/interrupts
Quote:
|
Re: Help with pots/interrupts
Err..., I was thinking 10 turn pot when I wrote 10K (it is 100K for the record).
And it was a silly, stupid mistake. I realized it sitting in english, that when transferring the Edu Code to the RC code I didn't change the User Init function to call Initialize_Tracker(). Thanks for all the help. It sure would be a lot easier if I didn't have a million tests this week (just finished one right now, and off to the robot, where we found out we have a bad speed controller) ... oh well, it always works out ... right? err... |
Re: Help with pots/interrupts
About competition: Bring Spares. Lots of them. And backup code. And the computer to download from. And docs. And... :)
|
| All times are GMT -5. The time now is 04:19. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi