Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Help! Analog Inputs!! (http://www.chiefdelphi.com/forums/showthread.php?t=53807)

brennerator 10-02-2007 01:40

Help! Analog Inputs!!
 
Were using a potentiometer and I have no idea how to read the potentiometer value!

PLease help

kitscuzz 10-02-2007 02:00

Re: Help! Analog Inputs!!
 
Simply plug your POT into a analog port

Then use Get_Analog_Value(rc_ana_in0*)

Where * is the number port you placed the POT.

It will return a value between 0 and 1024, depending on how far it has been turned.

brennerator 10-02-2007 02:13

Re: Help! Analog Inputs!!
 
So i just printf("Pot %d\r", Get_Analog_Value(rc_ana_in0*)); to display it?

JimHull 10-02-2007 02:31

Re: Help! Analog Inputs!!
 
Yes that should do it.

ScottWalls 10-02-2007 08:41

Re: Help! Analog Inputs!!
 
Quote:

Originally Posted by brennerator (Post 575323)
So i just printf("Pot %d\r", Get_Analog_Value(rc_ana_in0*)); to display it?

Well, to clarify, you would replace * with the number of the analog input you put the potentiometer into. For example, if you plugged the potentiometer into analog input 1, you would put
Code:

printf("Pot %d\r", Get_Analog_Value(rc_ana_in01));
But you may have already known that.

Shinigami2057 10-02-2007 10:56

Re: Help! Analog Inputs!!
 
It doesn't really matter in this case, but when using an unsigned value, like analog inputs, you should use %u and not %d (the ADC conversion gives you a 10-bit value, 0-1023, so it should never come up as negative, but it's good to know in case you need a full 16-bit unsigned int).

Just make sure that the pot is properly connected (red + black leads to the outer leads on the pot, white to the wiper/middle lead) and you should have no problems. Our arm potentiometer got disconnected during testing and its value started creeping by 1 every few seconds, it was really weird. O_o

Eclipse 10-02-2007 12:47

Re: Help! Analog Inputs!!
 
Also, make sure you've included ifiutilities.h in whatever file you're using Get_Analog_Value() or else it won't work. o_o

Bomberofdoom 11-02-2007 15:48

Re: Help! Analog Inputs!!
 
Yep, Get_Analog_Value('the analog input number').


All times are GMT -5. The time now is 04:47.

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