![]() |
2010 Accelerometer I2C Object/Class
Hey so we discovered that the 2010 Accelerometer is not Analog it is Completely Digital.
And the Class the Java API provides is for the 2009 Analog Accelerometer. It even says in the Documentation that they forgot to write a class for the new accelerometer and will try to add it soon. But Soon isn't soon enough. (Patience Fail) Does anyone know how to go about extending the I2C class in order to create a valid Accelerometer Class? This would be unbelievable helpful. Thx |
Re: 2010 Accelerometer I2C Object/Class
I am working on one now. I have a class for an I2C compass which is now working great. Accelerometer is next.
|
Re: 2010 Accelerometer I2C Object/Class
Quote:
It should be trivial to port the C++ version that I posted. http://decibel.ni.com/content/thread/5634 |
Re: 2010 Accelerometer I2C Object/Class
Thanks,
We converted the code to Java and are going to test it tomorrow. One thing that we had to change was that instead of using enumerations we used arrays. This was because the Version of Java the robot is running on does not support the use of enumerations, but i don't see how that could affect the return values. Again Thanks A Lot!!:) |
Re: 2010 Accelerometer I2C Object/Class
I am saddened our ported code did not work.
It may be that we just didnt translate some of the syntax correctly or something else IDK. Returned 0.0 Heres the code Quote:
Also if we cant get this to work where do you buy the analog accelerometer from last year? |
Re: 2010 Accelerometer I2C Object/Class
We also attempted a I2C accelerometer port and read 0.0 on x,y, and z.
I think the next step we may take is to flash our crio for C programming and see if we read anything but 0 in that environment. |
Re: 2010 Accelerometer I2C Object/Class
Does anyone know if they plan to release a new update for Java with support for an I2C Accelerometer anytime soon.
In the documentation it said that they would release it in later update. Also in case this never works is it legal to use the analog accelerometer from last year and just use the Accelerometer class in Java that was built for the analog Accelerometer? |
Re: 2010 Accelerometer I2C Object/Class
Quote:
Quote:
|
Re: 2010 Accelerometer I2C Object/Class
does anyone know where to buy the Analog Accelerometer Breakout ?
|
Re: 2010 Accelerometer I2C Object/Class
Quote:
Alternately, you could manufacture your own from the designs posted of last year's boards. -Joe |
Re: 2010 Accelerometer I2C Object/Class
Here is java class for the ADXL345 when connected as I2C device at default address.
Code:
/*----------------------------------------------------------------------------*/ |
Re: 2010 Accelerometer I2C Object/Class
Quote:
|
Re: 2010 Accelerometer I2C Object/Class
Quote:
Quote:
|
Re: 2010 Accelerometer I2C Object/Class
Quote:
|
Re: 2010 Accelerometer I2C Object/Class
RAWR!!!
thanks alot for help. I will try the above I2C class, looks better than ours. but then again ours was coded on a hope and a prayer seeing that we did not understand any of that low level stuff. thanks again. Also thanks for the analog accel link. |
Re: 2010 Accelerometer I2C Object/Class
Quote:
Also, did this code work? I didn't see anything wrong with it. |
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. |
Re: 2010 Accelerometer I2C Object/Class
Quote:
|
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. |
Re: 2010 Accelerometer I2C Object/Class
Here is my test program:
Code:
public class RobotTest extends SimpleRobot { |
Re: 2010 Accelerometer I2C Object/Class
Quote:
![]() |
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 |
Re: 2010 Accelerometer I2C Object/Class
Quote:
-Joe |
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!
|
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?
|
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;Any help would be appreciated! |
Re: 2010 Accelerometer I2C Object/Class
Quote:
|
Re: 2010 Accelerometer I2C Object/Class
Quote:
|
Re: 2010 Accelerometer I2C Object/Class
Quote:
|
Re: 2010 Accelerometer I2C Object/Class
Quote:
|
Re: 2010 Accelerometer I2C Object/Class
Quote:
|
Re: 2010 Accelerometer I2C Object/Class
An FYI:
we have this accelerometer working using the code here(thanks much!), and have included it in the latest GRTFramework as well, complete with events for new data, change in data, and data spiking... If you are curious as to how this works, or interested in using it, visit code.google.com/p/grtframework http://code.google.com/p/grtframewor...RTADXL345.java Is where we read data and broadcast/publish events. |
Re: 2010 Accelerometer I2C Object/Class
sorry but ive been trying to get my i2c compass to work for a while but its been failing
it says it cant even find the compass do you think you could help me? |
| All times are GMT -5. The time now is 10:32. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi