Go to Post Since our team is in possession of the school, we have no restrictions on how late we can be there. So our teams are often practicing into the wee hours of the morning. Also, the school board uses "the breeze" for storage of high jump mats, so it's a great place to nap. :) - Karthik [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 23-02-2004, 17:30
mtrawls's Avatar
mtrawls mtrawls is offline
I am JVN! (John von Neumann)
#0122 (NASA Knights)
Team Role: Programmer
 
Join Date: Mar 2003
Location: Hampton, VA
Posts: 295
mtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to behold
Send a message via AIM to mtrawls
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);
Yet the print statement prints the same value over and over again, even when the pot is being turned! Any insight, or debugging suggestions would be greatly appreciated.

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.
  #2   Spotlight this post!  
Unread 23-02-2004, 17:35
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,722
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Help with pots/interrupts

Code:
printf ("The pot value is: %d\n", (int) rc_ana_in01);
You need to use:
Code:
unsigned int pot_value;
pot_value = Get_Analog_Value(rc_ana_in01);
printf ("The pot value is: %d\n", (int) pot_value);
Edit: Hey Ken, I'm only a two finger typist. I work on too many different types of keyboards to type the normal way anymore. Those vendors keep moving the keys around, so I have to hunt and peck.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 24-02-2004 at 11:56.
  #3   Spotlight this post!  
Unread 23-02-2004, 17:38
KenWittlief KenWittlief is offline
.
no team
Team Role: Engineer
 
Join Date: Mar 2003
Location: Rochester, NY
Posts: 4,213
KenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond repute
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)

Last edited by KenWittlief : 23-02-2004 at 17:42.
  #4   Spotlight this post!  
Unread 24-02-2004, 08:07
mtrawls's Avatar
mtrawls mtrawls is offline
I am JVN! (John von Neumann)
#0122 (NASA Knights)
Team Role: Programmer
 
Join Date: Mar 2003
Location: Hampton, VA
Posts: 295
mtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to behold
Send a message via AIM to mtrawls
Re: Help with pots/interrupts

Quote:
Originally Posted by mtrawls
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.
Thanks for the help. Who would have thought that sleep depravation, loud noise, small rooms, and flying metal sparks wouldn't have been the optimum environment for programming? It is sad, sad day ...

Anyway, I'll post that code now.

Code:
  static unsigned int Old_Clock = 0;
  static unsigned char drive_timer = 0;
...
    /* Add your own autonomous code here. */
    if (Clock > Old_Clock)
    {
	switch (Navigator_State) { ... }
    }
    Old_Clock = Clock; // take a snapshot of the clock
For some reason the clock is not increasing. Now, since we are presently making our auton switch, I did some kludging to get it called; I called User_Autonomous_Mode (where this code is at) from Process_Data_From_Local_uP, and edited as such:

Code:
//  while (autonomous_mode)   /* DO NOT CHANGE! */
   while (1) // just so auto is executed now, for testing
  {
    if (statusflag.NEW_SPI_DATA)      /* 26.2ms loop area */
    {
        Getdata(&rxdata);   /* DO NOT DELETE, or you will be stuck here forever! */

 // PUT THE ABOVE CODE RIGHT HERE

        Generate_Pwms(pwm13,pwm14,pwm15,pwm16);

        Putdata(&txdata);   /* DO NOT DELETE, or you will get no PWM outputs! */
    }
  }
I think the problem might be that I have the code in the 26.2ms loop area -- or at least I have an inclination I don't want it there. But would that explain why the timer interrupt doesn't appear to be interrupting? Maybe I copied the code down incorrectly when switching from Edu to RC. Thanks for all the help ..
  #5   Spotlight this post!  
Unread 24-02-2004, 08:32
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,559
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
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.
  #6   Spotlight this post!  
Unread 24-02-2004, 09:28
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,722
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
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?
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 24-02-2004 at 09:30.
  #7   Spotlight this post!  
Unread 24-02-2004, 11:08
deltacoder1020's Avatar
deltacoder1020 deltacoder1020 is offline
Computer Guy
AKA: Dav
#1020 (The Indiana Prank Monkeys)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Muncie, Indiana
Posts: 340
deltacoder1020 has a spectacular aura aboutdeltacoder1020 has a spectacular aura about
Send a message via AIM to deltacoder1020
Re: Help with pots/interrupts

Quote:
Originally Posted by Joe Ross
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.
Just a side note about pots, we experimented with some different values, and the 10k pots seem to work fine, with about the same resolution as the 100k ones. You might get some slightly different scaling, but as long as all of your pots are the same value you shouldn't run into many problems.
__________________
Team 1020, the Indiana Prank Monkeys (www.team1020.org)
  #8   Spotlight this post!  
Unread 24-02-2004, 12:27
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Caņada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Caņada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: Help with pots/interrupts

Quote:
Originally Posted by Joe Ross
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.
Actually, it doesn't alter the amount of resolution you have. What it does do is raise the amount of current flowing through the potentiometer. As the currents involved in both cases are miniscule (100K = 50uA, 10K = 500uA), I'd go ahead and use the 10K.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #9   Spotlight this post!  
Unread 24-02-2004, 12:34
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,559
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Help with pots/interrupts

Quote:
Originally Posted by Kevin Watson
Actually, it doesn't alter the amount of resolution you have. What it does do is raise the amount of current flowing through the potentiometer. As the currents involved in both cases are miniscule (100K = 50uA, 10K = 500uA), I'd go ahead and use the 10K.
Yep, I realized that after I posted. I had a brainfart and originally was thinking that the RC somehow measured resistance. But of course, it measures the voltage, and that will be the same for the 100K and 10K.
  #10   Spotlight this post!  
Unread 24-02-2004, 16:57
mtrawls's Avatar
mtrawls mtrawls is offline
I am JVN! (John von Neumann)
#0122 (NASA Knights)
Team Role: Programmer
 
Join Date: Mar 2003
Location: Hampton, VA
Posts: 295
mtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to behold
Send a message via AIM to mtrawls
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...
  #11   Spotlight this post!  
Unread 24-02-2004, 17:01
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: Help with pots/interrupts

About competition: Bring Spares. Lots of them. And backup code. And the computer to download from. And docs. And...
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


All times are GMT -5. The time now is 10:46.

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