|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
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! |
|
#2
|
|||||
|
|||||
|
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. |
|
#3
|
|||
|
|||
|
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! |
|
#4
|
|||||
|
|||||
|
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. |
|
#5
|
|||
|
|||
|
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:
|
|
#6
|
|||
|
|||
|
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. |
|
#7
|
|||||
|
|||||
|
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. |
|
#8
|
|||
|
|||
|
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.
|
|
#9
|
|||
|
|||
|
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. =] |
|
#10
|
|||||
|
|||||
|
Re: Analog input delay problems
Speaking of cosmic rays...
![]() |
|
#11
|
|||
|
|||
|
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...
|
|
#12
|
|||
|
|||
|
Re: Analog input delay problems
Quote:
![]() 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 |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |