Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   HELP: analog input (http://www.chiefdelphi.com/forums/showthread.php?t=54146)

Tottanka 14-02-2007 14:40

HELP: analog input
 
Hey,
I'm trying to get an analog input from my 10 Kohm but all i get is a series of numbers counting downwards and reseting the controller makes it go back from the number in which it stopped instead of the one in which it began...

Any suggestions?

Dave K. 14-02-2007 14:58

Re: HELP: analog input
 
Quote:

Originally Posted by Tottanka (Post 578208)
Hey,
I'm trying to get an analog input from my 10 Kohm but all i get is a series of numbers counting downwards and reseting the controller makes it go back from the number in which it stopped instead of the one in which it began...

Any suggestions?

If you could post the relevant portion of your source code here, we could offer you some insight.

Otherwise, the best we could offer up is a generic "look at Kevin's code" here: http://www.kevin.org/frc/ response.

Tottanka 14-02-2007 15:08

Re: HELP: analog input
 
printf("Pot %d\r", Get_ADC_Result(1));

tdlrali 14-02-2007 15:17

Re: HELP: analog input
 
The counting occurs when nothing is connected.
Make sure that the Pot is plugged into the right pin.
In Kevin's ADC, #1 is actually analog in #2 (#0 is pin #1).

Tottanka 14-02-2007 15:44

Re: HELP: analog input
 
we did what you said but it still counts.
can any body please send us a working code for the potentiometer using the analog inputs.

Bharat Nain 14-02-2007 16:03

Re: HELP: analog input
 
Quote:

Originally Posted by Tottanka (Post 578260)
we did what you said but it still counts.
can any body please send us a working code for the potentiometer using the analog inputs.

Without using Kevin's code:

Potentiometervalue = Get_Analog_Value(rc_ana_in01);

Kevin Watson 14-02-2007 16:52

Re: HELP: analog input
 
Quote:

Originally Posted by Bharat Nain (Post 578273)
Without using Kevin's code:

Potentiometervalue = Get_Analog_Value(rc_ana_in01);

I think Bharat is trying to tell you (and he's right) that it's overkill to use my code to read a potentiometer. Just use his example and it should work. If you really want to use my code, if I remember correctly, Get_ADC_Result() returns an unsigned int, which means you should use %u in your printf() format string, not %d.

-Kevin

Tottanka 15-02-2007 09:22

Re: HELP: analog input
 
We have tried both things, with Kevin's code and it still did not work...
any further suggestions?

Shinigami2057 15-02-2007 09:50

Re: HELP: analog input
 
Is your potentiometer wired correctly? Red and black to the outer leads, white (signal) to the center? The problem you described only occurs when nothing is plugged in, so make sure you're referencing the correct analog input in your code, that the pot is wired correctly, and that it's not broken (which is kind of hard to do.. test another one?).

Tottanka 15-02-2007 09:55

Re: HELP: analog input
 
We tested it with a voltmeter and it all good....

Bharat Nain 15-02-2007 10:19

Re: HELP: analog input
 
Quote:

Originally Posted by Tottanka (Post 578694)
We tested it with a voltmeter and it all good....

But is it wired up correctly? You can test it at a point on the potentiometer and get correct readings. However, if it is not wired up correctly, the processor will not be able to read it. There is also a slight chance the processor itself has corrupted analog pins. That happen to our 2006 controller at the end of the season.

Tottanka 15-02-2007 10:38

Re: HELP: analog input
 
the potentiometers are good like i said...
We have checked it with a voltmeter connecting between the where the white cable connects and where the red one connects and it shows the correct results.
We have also tried to change the ports, and neither of them worked...

Alan Anderson 15-02-2007 11:24

Re: HELP: analog input
 
Quote:

Originally Posted by Tottanka (Post 578713)
the potentiometers are good like i said...

If your idea of "good" does not match what the RC expects, it won't work no matter how many times you check to see that it's "good". In order to help you, we need to know exactly how you have wired it. Answering "we wired it correctly" is not going to help. For example:
Quote:

We have checked it with a voltmeter connecting between the where the white cable connects and where the red one connects and it shows the correct results.
But where did you connect the black wire? What measurement are you making, and what results are you getting? Answering "the correct results" does not help.

A potentiometer on the Robot Controller's analog inputs needs three wires. Black (ground) goes to one end of the pot. Red (+5) goes to the other end of the pot. White (signal) goes to the wiper.

Tottanka 15-02-2007 11:48

Re: HELP: analog input
 
Like i said before...its connected CORRECTLY...
There is another problem...
Black goes to left side of potentiometer
Red goes to its right leg
and white goes to the middle one...
and they connect to the analog inputs correctly
We have measured voltages between red and white legs, and it shows inputs from 0 to 4.95V liniarically to the rotation i make...

Here's our code:
printf("%u",Get_Analog_Value(rc_ana_in01));

does not work with %d or %u....

could you show me the code of Get_Analog_value...perhaps the problem we have has to with that function...

buddy.smith 15-02-2007 12:46

Re: HELP: analog input
 
I don't know this first hand, but does the analog port need to be setup as an input somewhere? Does the ADC need to be enabled?

ttyl,

--buddy

Shinigami2057 15-02-2007 13:15

Re: HELP: analog input
 
Make sure you are calling the function

Code:

    Set_Number_of_Analog_Channels(SIXTEEN_ANALOG); /* DO NOT CHANGE! */
In User_Initialization(). Otherwise, I really don't know what to tell you. Make sure it's connected to the RC properly (wire ordering), there are no breaks in the PWM cable, that the wires are SECURELY (i.e. soldered) connected to the pot, and that you've tried it with all the analog inputs (well, 2-4 of them should probably suffice).

Good luck.

Bharat Nain 15-02-2007 13:23

Re: HELP: analog input
 
Okay, here is code from our robot this year. This is exactly how we have written it and it works.

We made variables on top of the file:
Code:

unsigned int BottomSonic = 0;
Then, inbetween Getdata and Putdata, we inserted these two lines:
Code:


Getdata(&rxdata);


TopSonic = Get_Analog_Value(rc_ana_in02);

printf("Top: %d\r\n", TopSonic);


Putdata(&txdata);

If you have it wired up correctly, then the code above will work.


Also, try it on a fresh piece of code with the absolute default code from IFI.

FIRST JerseyKid 15-02-2007 13:38

Re: HELP: analog input
 
Make sure your init functions are correct.

and call the get_analog_value()

Alan Anderson 15-02-2007 14:57

Re: HELP: analog input
 
Quote:

Originally Posted by Tottanka (Post 578746)
...and they connect to the analog inputs correctly...

You left out important details here. Please replace the word "correctly" with a description of the actual connection to the Robot Controller.

EHaskins 18-02-2007 19:27

Re: HELP: analog input
 
I have been having the exact same issue. I tried IFI's ADC, Kevin Watson's integrated into my code, Kevin Watson's from his website(unmodified), and whatever EasyC uses.

They all read 0.

I have tried both the 2006 and 2007 controllers.

I have the pot connected so the 5v+/gnd each connect to one side of the pot, and the signal is connected to the middle connector on the pot.

If I short the gnd/sig pins the reading does NOT change.

I have used Kevin Watson's ADC without any issues before now. I have run it on VEX, EDU, and 2005 controllers.

I was at the Sussex mini-regional today and talked to 4-5 other programmers, and none of them had any ideas.

What am I missing?

Thanks,
Eric Haskins


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

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi