Go to Post I predict the champion drive teams at each event of the 2011 season will consist of vertebrates. - Taylor [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 22-01-2009, 23:27
LinuxMercedes LinuxMercedes is offline
Real men use Macs
FRC #1444 (Lightning Lancers)
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: St. Louis, MO
Posts: 22
LinuxMercedes is an unknown quantity at this point
Analog input delay problems

I've been messing with the analog inputs on both the driver's station and the cRio itself and have noticed a few weird things.

First, it seems to provide values between 0 and 1000. I'm assuming that this is multiplying the actual voltage by 200 since it would be kinda creepy if it was putting 1000 volts through those inputs...

Second, they seem to be mildly inaccurate. A full-open pot reads values between roughly 990 and 1100. This might be just the pot that I was using.

Third, and most importantly, there is a HUGE lag between changing the pot and getting the reading back at the debug console. It's roughly 20 seconds. We've determined that it's not a printf() buffer that's filling up faster than we can read it. Does anyone know why we'd have a delay like that, and how could we fix it?

Thanks!
__________________
Reply With Quote
  #2   Spotlight this post!  
Unread 22-01-2009, 23:43
MikeDubreuil's Avatar
MikeDubreuil MikeDubreuil is offline
Carpe diem
FRC #0125 (Nu-Trons)
Team Role: Engineer
 
Join Date: Jan 2003
Rookie Year: 1999
Location: Boston, MA
Posts: 967
MikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond repute
Send a message via AIM to MikeDubreuil
Re: Analog input delay problems

The reason you are seeing 1000 is most likely because the DS has a 10 bit A/D. Therefore, the data range is 0 to 1024 (2^10). Note: this is just a guess because the spec sheet in the control system does not indicate how large the A/D is.

With most potentiometers (even joysticks) you will notice they don't use the entire range. This is due to many reasons and you should plan accordingly in your software.

As for the lag... I'm pretty stumped. You'll have to provide more info for us to help you on that one.
__________________
"FIRST is like bling bling for the brain." - Woodie Flowers
Reply With Quote
  #3   Spotlight this post!  
Unread 22-01-2009, 23:51
LinuxMercedes LinuxMercedes is offline
Real men use Macs
FRC #1444 (Lightning Lancers)
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: St. Louis, MO
Posts: 22
LinuxMercedes is an unknown quantity at this point
Re: Analog input delay problems

Ok...I'd figured that there was something going on so that it didn't just give us the voltage =]

What information do you want to know? I haven't the slightest clue where to start attacking this problem, to tell you the truth. This is my first (and sadly last--should have gotten into this 2-3 years ago) year with FIRST, although I've been coding for 4-5 years =]. So don't assume 'well, he must have done that, because everyone knows to do x when they have trouble.'

Thanks!
__________________
Reply With Quote
  #4   Spotlight this post!  
Unread 23-01-2009, 07:11
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,078
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: Analog input delay problems

Do you have access to an oscilloscope? I would hook the pot up to that and watch the wiper voltage change as you turn it. If you see a delay there, you probably have a wiring issue or a busted pot.

Also, you can verify that you have the right connections. One end should be +5V, the other end should be GND. The middle (the wiper) is where you are making your reading.

Lastly, what is the resistance of the pot? You may have an RC-type delay somewhere in the circuit.
Reply With Quote
  #5   Spotlight this post!  
Unread 23-01-2009, 19:14
drkiraco drkiraco is offline
Registered User
FRC #1747
 
Join Date: Jan 2009
Location: Lafayette IN
Posts: 23
drkiraco will become famous soon enoughdrkiraco will become famous soon enough
Re: Analog input delay problems

Are you using the 'Get Voltage' or 'Get Average Voltage'? My guess is that you are using 'Get Average Voltage' with a low sample rate and a high number for the oversample value (like 10). I say this because when you use the the oversample at a value of N, it adds the previous 2^N values together (and does NOT divide by 2^N either!) So that explains the high values. You should be getting outputs in volts. Plus, since you're averaging together a whole bunch of values, there is going to be a big delay while the average value catches up to the new input value. If you have a low sample rate (as determined by the set sample rate vi, not how frequently your loop is running), 2^10 averages could concievably be 20s. I'm pretty sure that the sample rate vi sets the rate for the whole module, so the same rate per channel is 1/8 of that.

Now, if this doesn't help you out, then try this: make a copy of your code and delete everything but the bit about reading the analog value and displaying (i.e. delete all the camera stuff and all the drive stuff and everything). If that fixes it, then add stuff back into until you find the culprit. If not, then post that code here and maybe somebody can spot your error.

/* Daniel */

Quote:
Originally Posted by LinuxMercedes View Post
I've been messing with the analog inputs on both the driver's station and the cRio itself and have noticed a few weird things.

First, it seems to provide values between 0 and 1000. I'm assuming that this is multiplying the actual voltage by 200 since it would be kinda creepy if it was putting 1000 volts through those inputs...

Second, they seem to be mildly inaccurate. A full-open pot reads values between roughly 990 and 1100. This might be just the pot that I was using.

Third, and most importantly, there is a HUGE lag between changing the pot and getting the reading back at the debug console. It's roughly 20 seconds. We've determined that it's not a printf() buffer that's filling up faster than we can read it. Does anyone know why we'd have a delay like that, and how could we fix it?

Thanks!
Reply With Quote
  #6   Spotlight this post!  
Unread 23-01-2009, 20:19
LinuxMercedes LinuxMercedes is offline
Real men use Macs
FRC #1444 (Lightning Lancers)
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: St. Louis, MO
Posts: 22
LinuxMercedes is an unknown quantity at this point
Re: Analog input delay problems

Daniel:

I'm using GetValue(). I'll try GetVoltage(). I know it's not a problem with my loop taking 20 seconds to execute because it will printf() the value of the pot several times between changing the pot physically and the voltage change being registered by the software.

Abwher:

Thanks for pointing those things out...as a software guy, I tend to assume there's a software problem, not a hardware problem. I'll check those out tomorrow, although I might have to use a voltmeter of some sort since I don't think we have a 'scope.
__________________
Reply With Quote
  #7   Spotlight this post!  
Unread 23-01-2009, 20:51
PhilBot's Avatar
PhilBot PhilBot is offline
Get a life? This IS my life!
AKA: Phil Malone
FRC #1629 (GaCo: The Garrett Coalition)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Maryland
Posts: 747
PhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond reputePhilBot has a reputation beyond repute
Re: Analog input delay problems

How fast are you looping?
If you printf too fast, won't you overrun the debut port?
Are you using the serial port at 9600?
Remember..... Only 1000 charaters per second.
I'd suggest a 100 ms delay per loop to prevent debug overload.
__________________
Phil Malone
Garrett Engineering And Robotics Society (GEARS) founder.
http://www.GEARSinc.org

FRC1629 Mentor, FTC2818 Coach, FTC4240 Mentor, FLL NeXTGEN Mentor
Reply With Quote
  #8   Spotlight this post!  
Unread 24-01-2009, 00:29
LinuxMercedes LinuxMercedes is offline
Real men use Macs
FRC #1444 (Lightning Lancers)
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: St. Louis, MO
Posts: 22
LinuxMercedes is an unknown quantity at this point
Re: Analog input delay problems

I was using the network terminal and had it set to print once every 1000 loops, which came out to about 1/sec.
__________________
Reply With Quote
  #9   Spotlight this post!  
Unread 24-01-2009, 22:00
LinuxMercedes LinuxMercedes is offline
Real men use Macs
FRC #1444 (Lightning Lancers)
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: St. Louis, MO
Posts: 22
LinuxMercedes is an unknown quantity at this point
Re: Analog input delay problems

Well, I suppose this problem is moot now. I hooked up a pot today to drive a motor speed, and it worked fine...

I think it might have been caused by cosmic rays, since I've never had this happen when printf()ing anything else. =]
__________________
Reply With Quote
  #10   Spotlight this post!  
Unread 24-01-2009, 22:25
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,078
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: Analog input delay problems

Speaking of cosmic rays...

Reply With Quote
  #11   Spotlight this post!  
Unread 25-01-2009, 21:20
LinuxMercedes LinuxMercedes is offline
Real men use Macs
FRC #1444 (Lightning Lancers)
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: St. Louis, MO
Posts: 22
LinuxMercedes is an unknown quantity at this point
Re: Analog input delay problems

I love XKCD. "A bunch of rocks" is probably my favorite (http://xkcd.com/505/), but for some reason this one seems particularly relevant to the current company...
__________________
Reply With Quote
  #12   Spotlight this post!  
Unread 10-02-2009, 20:36
Beakerone Beakerone is offline
Registered User
FRC #1099 (Lions)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2005
Location: Brookfield, CT
Posts: 2
Beakerone is an unknown quantity at this point
Re: Analog input delay problems

Quote:
Originally Posted by LinuxMercedes View Post
Well, I suppose this problem is moot now. I hooked up a pot today to drive a motor speed, and it worked fine...

I think it might have been caused by cosmic rays, since I've never had this happen when printf()ing anything else. =]
Glad the cosmos is aligning for you.
i was wondering - we are using pots also - one on the driver station which we can get the AnalogIn value (1-1024) which we are trying to compare to the value of an identical pot connected to the analog module on the cRio... however, we can not seem to get a similar value back from the Pot attached to the cRio, what was the code that you used to read those values from that pot... appreaciate the help.
we are going to use the pots to control the direction of a turret but need to compare the values so as not to twist the turret all the way around.
thanks in advance for any help you can provide..
have a great season.
Brain

Last edited by Beakerone : 10-02-2009 at 20:37. Reason: missing info
Reply With Quote
Reply


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
Analog Input Errors... Tach'ko Electrical 1 11-01-2008 11:37
HELP: analog input Tottanka Programming 19 18-02-2007 19:27
Analog Input Trouble Matt Krass Programming 10 20-01-2005 21:09
Resistance to Analog Input Value. Josh Hambright Electrical 12 15-04-2003 16:12
DC Motor current to an Analog Input junkyarddawg Motors 43 04-04-2002 15:53


All times are GMT -5. The time now is 03:11.

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