|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools |
Rating:
|
Display Modes |
|
#16
|
|||
|
|||
|
Re: 2010 Accelerometer I2C Object/Class
Quote:
Also, did this code work? I didn't see anything wrong with it. |
|
#17
|
|||
|
|||
|
Re: 2010 Accelerometer I2C Object/Class
Quote:
If you look at the getAxis method you will see that I am doing a 2-byte read when I get the data (2 consecutive registers in one read). This insures that the data does not get corrupted. If two individual 1-byte reads were performed there is a chance that in between the first and second read the data could change. This would result in first read getting the low byte of the prior value and second read getting the high byte of the subsequent value. Putting the two together again could create some really funny numbers. See page 18 of the ADXL345 data sheet "Register 0x32 to Register 0x37" section for more information about this. Here is an example of the problem: prior value is 0x0100 subsequent value is 0x00ff, a 1 bit change. Two single byte reads would read low byte 0x00 and high byte 0x00 giving 0x0000. No where near close to what the sensor is actually reading. Last edited by charrisTTI : 03-02-2010 at 10:56. |
|
#18
|
|||
|
|||
|
Re: 2010 Accelerometer I2C Object/Class
Quote:
|
|
#19
|
||||
|
||||
|
Re: 2010 Accelerometer I2C Object/Class
/sigh
we tested this code yesterday. but it did not work for us and since the code seems to work for u guys. We are probably doing something wrong. For our wiring we plugged in (obviously 5v to 5v and 0v to ground and so on) but what i have a question on is which I2C channel those plug in to. There are 2 that are not labeled, so i guess the question here is what channel I2C is the kaddress is referring to? Also I am using the class in the code by -instantiating with an argument of 4 (which is where the digital module is plugged in to on the crio) -calling the initialize() method -and then calling the getXAxis() method in my polling while loop which runs every .02 seconds. The only thing i could see that might cause a problem is that the accel does not show a significant enough amount of change in the .02s in which we check it. If this is what is happening please let me know and if its not please try and help. Thanks in advance. |
|
#20
|
|||
|
|||
|
Re: 2010 Accelerometer I2C Object/Class
Here is my test program:
Code:
public class RobotTest extends SimpleRobot {
ADXL345DigitalAccelerometer accelerometer = new ADXL345DigitalAccelerometer(4);
public RobotTest()
{
accelerometer.intitialize();
accelerometer.setRange(ADXL345DigitalAccelerometer.DATA_FORMAT_16G);
}
/**
* This function is called once each time the robot enters autonomous mode.
*/
public void autonomous() {
}
/**
* This function is called once each time the robot enters operator control.
*/
public void operatorControl() {
this.getWatchdog().setEnabled(false);
while( this.isOperatorControl() && this.isEnabled() )
{
System.out.println("Accel X, Y, Z: " + accelerometer.getXAxis() + " " + accelerometer.getYAxis() + " " + accelerometer.getZAxis() );
Timer.delay(0.001);
}
}
}
|
|
#21
|
|||
|
|||
|
Re: 2010 Accelerometer I2C Object/Class
Quote:
![]() |
|
#22
|
||||
|
||||
|
Re: 2010 Accelerometer I2C Object/Class
possibly the most helpful post Ever.
I will try this in about an hour and post the results we were on the ones labeled not these. Also i am curious what the pins labeled not these are for? It says "Out" does that just mean those are all Digital Outputs? Thanks again |
|
#23
|
|||
|
|||
|
Re: 2010 Accelerometer I2C Object/Class
Quote:
-Joe |
|
#24
|
||||
|
||||
|
Re: 2010 Accelerometer I2C Object/Class
We tried using the "these" pins instead of the "not these" pins and the accelerometer is returning values now. Thanks for the picture!
|
|
#25
|
|||
|
|||
|
Re: 2010 Accelerometer I2C Object/Class
Okay, I tried it out yesterday and everything seemed to work. Only problem I had was that it floated just enough to make numbers not work for integration to position. For instance, it would float from 0.0 to about 0.007 and then back to 0.0. Problem there is that it technically never had negative acceleration to counter that, meaning the velocity doesn't go back to 0, making my position infinitely change. Even if I do make a dead band, the readings aren't perfectly symmetrical, again meaning velocity doesn't go back to zero. I don't think I'm the only one with this problem. Any suggestions as to how I can use an accelerometer to at least approximate position, accurate enough to maybe 6 inches to a foot, during autonomous?
|
|
#26
|
|||
|
|||
|
Re: 2010 Accelerometer I2C Object/Class
We tested out the code for the I2C Accelerometer and we seem to be having some issues. We are doing the following:
Code:
ADXL345DigitalAccelerometer accelerometer; accelerometer = ADXL345DigitalAccelerometer(4); accelerometer.initialize(); accelerometer.getZAxis(); Any help would be appreciated! |
|
#27
|
|||
|
|||
|
Re: 2010 Accelerometer I2C Object/Class
Quote:
|
|
#28
|
|||
|
|||
|
Re: 2010 Accelerometer I2C Object/Class
Quote:
|
|
#29
|
|||
|
|||
|
Re: 2010 Accelerometer I2C Object/Class
Yes, the sidecar is definitely powered. I am not sure about the clock line being shorted. The clock should be available on the SCL line on the sidecar right? Is it possible that we're missing other hardware modifications or connections? The only thing we've done was connect the 12V supply to the sidecar using the wago connector and the accelerometer to the I2C header.
Last edited by urg8rb8 : 05-02-2010 at 13:30. |
|
#30
|
|||
|
|||
|
Re: 2010 Accelerometer I2C Object/Class
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help with 2010 Accelerometer & I2C | wt200999 | C/C++ | 33 | 08-02-2010 15:16 |
| 2010 accelerometer | chsr | C/C++ | 1 | 22-01-2010 02:28 |
| 2010 Accelerometer Documentation? | JDM | Sensors | 13 | 18-01-2010 12:42 |
| Where to find a Gyro and Accelerometer Sensor Board for 2010 FRC? | xSpongeX | Sensors | 4 | 18-01-2010 06:17 |
| Accelerometer class - isn't reading zero at rest? | oddjob | C/C++ | 3 | 02-02-2009 17:11 |