Go to Post Read the manual! - Trent B [more]
Home
Go Back   Chief Delphi > Technical > Programming > WindRiver C++
CD-Events   CD-Media   CD-Spy   FRC-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 03-03-2009, 09:51 PM
oddjob oddjob is offline
Registered User
no team
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Earth
Posts: 118
oddjob is a splendid one to beholdoddjob is a splendid one to beholdoddjob is a splendid one to beholdoddjob is a splendid one to beholdoddjob is a splendid one to beholdoddjob is a splendid one to beholdoddjob is a splendid one to behold
DriverStation::GetAnalogIn - what range?

From the C++ reference manual:
DriverStation::GetAnalogIn returns the analog voltage on the input. The analog values are returned as UINT32 values....

Let's keep it simple, ignoring noise:
1) when an analog input is at ground, what value is returned?
2) when an analog input is at +5V, what value is returned?
Reply With Quote
  #2   Spotlight this post!  
Unread 03-03-2009, 11:55 PM
MattD's Avatar
MattD MattD is offline
Registered User
AKA: Matthew Douglas
FRC #0228 (GUS Robotics)
Team Role: Alumni
 
Join Date: Feb 2006
Rookie Year: 2005
Location: Indianapolis, IN
Posts: 185
MattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to behold
Send a message via AIM to MattD
Re: DriverStation::GetAnalogIn - what range?

The Driver Station has a 10 bit ADC. This means that the possible range of values is from 0 to (2^10)-1, or 0 to 1023.

I just looked at the source code for the DriverStation, and I'm actually a little confused about it. FRCComm.h describes the analog inputs like this:

Code:
struct FRCControlData{
...
	//Analog inputs are 10 bit right-justified
	UINT16 analog1;
	UINT16 analog2;
	UINT16 analog3;
	UINT16 analog4;
...
That makes sense. However, DriverStation::GetAnalogIn() looks like this:

Code:
/**
 * Get an analog voltage from the Driver Station.
 * The analog values are returned as UINT32 values for the Driver Station analog inputs.
 * These inputs are typically used for advanced operator interfaces consisting of potentiometers
 * or resistor networks representing values on a rotary switch.
 * 
 * @param channel The analog input channel on the driver station to read from. Valid range is 1 - 4.
 * @return The analog voltage on the input.
 */
float DriverStation::GetAnalogIn(UINT32 channel)
{
	wpi_assert ((channel >= 1) && (channel <= 4));
	GetData();
	switch (channel)
	{
	case 1:
		return m_controlData->analog1;
	case 2:
		return m_controlData->analog2;
	case 3:
		return m_controlData->analog3;
	case 4:
		return m_controlData->analog4;
	}
	return 0;
}
Why does the documentation say the values are returned as a UINT32, yet the function returns a float? Also, as seen in FRCComm.h, the control data actually represents these inputs as 16-bit integers. Note that m_controlData is of type FRCControlData, meaning that analog1..4 are all UINT16 values. Perhaps this was an oversight.

The @return comment implies that it returns the actual voltage on the analog port -- but how does it do this? It doesn't look right to me, and could be an oversight by the WPI Library developers. If it's not, perhaps someone else could help explain this...
__________________
GUS Robotics Team 228

2010 WPI Engineering Inspiration Award
2010 WPI Regional Champions (Thanks 230 & 20!)
2010 CT VEX Champions
2010 CT VEX Innovate Award
2009 QCC VEX Champions
2009 CT Motorola Quality Award
2007 CT J&J Sportsmanship Award
2006 CT Best Website Award
Reply With Quote
  #3   Spotlight this post!  
Unread 03-04-2009, 12:45 AM
MattD's Avatar
MattD MattD is offline
Registered User
AKA: Matthew Douglas
FRC #0228 (GUS Robotics)
Team Role: Alumni
 
Join Date: Feb 2006
Rookie Year: 2005
Location: Indianapolis, IN
Posts: 185
MattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to behold
Send a message via AIM to MattD
Re: DriverStation::GetAnalogIn - what range?

For reference, I've posted about this on the official FRC Control System forum here:

http://forums.usfirst.org/showthread.php?t=12254
__________________
GUS Robotics Team 228

2010 WPI Engineering Inspiration Award
2010 WPI Regional Champions (Thanks 230 & 20!)
2010 CT VEX Champions
2010 CT VEX Innovate Award
2009 QCC VEX Champions
2009 CT Motorola Quality Award
2007 CT J&J Sportsmanship Award
2006 CT Best Website Award
Reply With Quote
  #4   Spotlight this post!  
Unread 03-04-2009, 09:41 PM
heydowns's Avatar
heydowns heydowns is offline
Registered User
FRC #1511 (Rolling Thunder)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Ra-Cha-Cha
Posts: 117
heydowns is a name known to allheydowns is a name known to allheydowns is a name known to allheydowns is a name known to allheydowns is a name known to allheydowns is a name known to all
Re: DriverStation::GetAnalogIn - what range?

Quote:
Originally Posted by oddjob View Post
From the C++ reference manual:
DriverStation::GetAnalogIn returns the analog voltage on the input. The analog values are returned as UINT32 values....

Let's keep it simple, ignoring noise:
1) when an analog input is at ground, what value is returned?
0

Quote:
Originally Posted by oddjob View Post
2) when an analog input is at +5V, what value is returned?
1023

We are using these with version WPILib 3.0, and have tested and used on our production bot.

Not that this is the intended behavior, but that is what it returns.
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
question regarding driverstation ringo115 Programming 4 02-16-2009 10:16 AM
driverstation outputs agough WindRiver C++ 3 02-15-2009 09:25 PM
Wiring LED to Driverstation sircedric4 Electrical 11 01-23-2009 07:31 AM
Writing to DriverStation cRio screen alexjplant NI LabVIEW 2 01-17-2009 09:59 AM
Finding range DanDon Programming 11 01-10-2006 09:58 PM


All times are GMT -5. The time now is 05:41 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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