Go to Post We're moving to metric, inch by inch. - Joe Ross [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 10-02-2007, 01:40
brennerator brennerator is offline
Registered User
#1560
 
Join Date: Jan 2005
Location: Silicon Valley
Posts: 75
brennerator is an unknown quantity at this point
Help! Analog Inputs!!

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

PLease help
  #2   Spotlight this post!  
Unread 10-02-2007, 02:00
kitscuzz's Avatar
kitscuzz kitscuzz is offline
Not alotta posts
AKA: Kit
FRC #1389 (Worst Case Scenario)
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Home
Posts: 47
kitscuzz will become famous soon enough
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.
  #3   Spotlight this post!  
Unread 10-02-2007, 02:13
brennerator brennerator is offline
Registered User
#1560
 
Join Date: Jan 2005
Location: Silicon Valley
Posts: 75
brennerator is an unknown quantity at this point
Re: Help! Analog Inputs!!

So i just printf("Pot %d\r", Get_Analog_Value(rc_ana_in0*)); to display it?
  #4   Spotlight this post!  
Unread 10-02-2007, 02:31
JimHull's Avatar
JimHull JimHull is offline
Registered User
FRC #1891
 
Join Date: Feb 2007
Location: Boise, ID
Posts: 11
JimHull is an unknown quantity at this point
Re: Help! Analog Inputs!!

Yes that should do it.
  #5   Spotlight this post!  
Unread 10-02-2007, 08:41
ScottWalls ScottWalls is offline
Registered User
FRC #0245 (AdamBots)
Team Role: Leadership
 
Join Date: Mar 2006
Rookie Year: 2003
Location: Rochester Hills
Posts: 31
ScottWalls will become famous soon enoughScottWalls will become famous soon enough
Re: Help! Analog Inputs!!

Quote:
Originally Posted by brennerator View Post
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.
  #6   Spotlight this post!  
Unread 10-02-2007, 10:56
Shinigami2057 Shinigami2057 is offline
Slackware Is Your New God (Mentor)
AKA: Harry Bock
FRC #1350 (Rambots)
Team Role: Programmer
 
Join Date: Oct 2006
Rookie Year: 2006
Location: Johnston, RI
Posts: 106
Shinigami2057 is just really niceShinigami2057 is just really niceShinigami2057 is just really niceShinigami2057 is just really niceShinigami2057 is just really nice
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
__________________
One of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs.
  #7   Spotlight this post!  
Unread 10-02-2007, 12:47
Eclipse's Avatar
Eclipse Eclipse is offline
Registered User
AKA: Sensei Hanzo
FRC #1250 (Gatro-Bots)
Team Role: Programmer
 
Join Date: Feb 2006
Rookie Year: 2004
Location: Dearborn, MI
Posts: 18
Eclipse is an unknown quantity at this point
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
__________________
xXx.S3nS31-h4nz0.xXx
  #8   Spotlight this post!  
Unread 11-02-2007, 15:48
Bomberofdoom's Avatar
Bomberofdoom Bomberofdoom is offline
Biggest FIRST addict in Israel
AKA: Nir Levanon
FRC #2230 (Zcharia's Angels)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Israel
Posts: 471
Bomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond repute
Send a message via MSN to Bomberofdoom
Re: Help! Analog Inputs!!

Yep, Get_Analog_Value('the analog input number').
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Analog Inputs bush Programming 5 13-03-2006 17:49
Analog Inputs prob. Bharat Nain Programming 2 07-02-2004 20:48
Failing analog inputs? Phasmatis568 Control System 5 22-01-2004 13:28
Analog vs Digital inputs? f22flyboy Programming 8 08-11-2002 22:18
Analog Inputs 316_programer Technical Discussion 2 05-02-2002 05:53


All times are GMT -5. The time now is 00:23.

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