Go to Post Life is not about avoiding risk, but managing it. - dtengineering [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-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 02-02-2009, 12:44 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
Accelerometer class - isn't reading zero at rest?

Do we have a bad KoP board or the code is wrong or missing some setup?

Code:
...

// Declare variables for the 3 axis accelerometer (2 channels wired)
Accelerometer *m_accelerometerX;
Accelerometer *m_accelerometerY;

...

// create accelerometers
m_accelerometerX = new Accelerometer(2);
m_accelerometerY = new Accelerometer(3);

...

//m_accelerometerX->SetSensitivity(0.0);
//m_accelerometerY->SetSensitivity(0.0);
//m_accelerometerX->SetZero(0.0);
//m_accelerometerY->SetZero(0.0);

...

accX = m_accelerometerX->GetAcceleration();
accY = m_accelerometerY->GetAcceleration();
...
The accX and accY values are about 1.5 each when the board is at rest. Do we need to use SetZero? I tried putting in 1.5 for the value and then accX went to an entirely different non zero value, -2.5 or something like that. Can I just use AnalogChannel and do the scaling in the code?
Reply With Quote
  #2   Spotlight this post!  
Unread 02-02-2009, 12:47 PM
EricVanWyk EricVanWyk is offline
Registered User
no team
 
Join Date: Jan 2007
Rookie Year: 2000
Location: Boston
Posts: 1,597
EricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond repute
Send a message via AIM to EricVanWyk
Re: Accelerometer class - isn't reading zero at rest?

You certainly can.

Before you do, be sure you are telling the class that your center point is 1.5V and your sensitivity is 300mV/g. I *think* the class assumes a different model.
Reply With Quote
  #3   Spotlight this post!  
Unread 02-02-2009, 02:09 PM
kiettyyyy's Avatar
kiettyyyy kiettyyyy is offline
Registered User
FRC #1538 (The Holy Cows)
Team Role: Engineer
 
Join Date: Mar 2006
Rookie Year: 2005
Location: San Diego, CA
Posts: 181
kiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond repute
Send a message via AIM to kiettyyyy
Re: Accelerometer class - isn't reading zero at rest?

The classes aren't really documented.

How do you set the center point to 1.5V? How do you set the sensitivity to 300mV/g?

From what I can tell, the accelerometer class contains the function calls of SetZero() and SetSensitivity().

How do you use these?
__________________
-Kiet Chau

2004-2008 - Software Developer/Driver on Team #968
2008-2011 - Software Developer/Coach/Mentor/"Engineer" on Team #968
2011-Present - Mentor & Engineer on Team #1538
www.team1538.com
Reply With Quote
  #4   Spotlight this post!  
Unread 02-02-2009, 05:11 PM
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,069
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: Accelerometer class - isn't reading zero at rest?

If you read the WPILib source code, it gives you some hints.

Code:
/**

 * Set the accelerometer sensitivity.

 * 

 * This sets the sensitivity of the accelerometer used for calculating the acceleration.

 * The sensitivity varys by accelerometer model. There are constants defined for various models.

 * 

 * @param sensitivity The sensitivity of accelerometer in Volts per G.

 */

void Accelerometer::SetSensitivity(float sensitivity)

{

	m_voltsPerG = sensitivity;

}

...

/**

 * Set the voltage that corresponds to 0 G.

 * 

 * The zero G voltage varys by accelerometer model. There are constants defined for various models.

 * 

 * @param zero The zero G voltage.

 */

void Accelerometer::SetZero(float zero)

{

	m_zeroGVoltage = zero;

}
So for the KoP accelerometer (zero G = 1.5V, sensitivity = 300mV/G), call:

Code:
myAccelerometer->SetZero(1.5);
myAccelerometer->SetSensitivity(0.3);
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
Floating point math zero flippo Programming 3 02-09-2007 09:00 AM
OI and analog: Zero value Astronouth7303 Programming 1 02-02-2004 04:00 PM
Community Zero archiver 2001 1 06-24-2002 04:08 AM
How about zero qualifying points? archiver 2000 0 06-23-2002 10:01 PM
Zero Hour archiver 2000 4 06-23-2002 09:59 PM


All times are GMT -5. The time now is 09:14 AM.

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