![]() |
Help with 2010 Accelerometer & I2C
I am trying to implement the kit accelerometer, and I started by basing it off of the HiTechncCompass class from last years code. (I can't find the newest version, but I doubt that class has changed). The problem I am having is when I try to initialize the I2C in my robot constructor, the constructor does not finish and the robot stops responding. The console output from the serial port also does not give me any errors either. Here is the class I started, with simple functions just to see what I can get out of it:
I2CAccel.h Code:
#ifndef __I2CACCEL__Code:
#include "I2CAccel.h" |
Re: Help with 2010 Accelerometer & I2C
I am working on the same project with my team ::ouch:: and play to modify the compass code to get me started. I am hoping the I2C code is good so I can concentrate on the accelerometer.
At first glance of the data sheet for the adxl345 it appears we will need to add more code that just the read of one register. Data is in 3 different registers at addresses 0x32 to 0x37 in a two's complement format so I would guess that returning a float from the read is the wrong choice. The compass may return a float but not the accelerometer. (this is what if get from the data sheet anyway). We will probably have to trigger a sampling of some sort before the read. I am not sure how the chip select is getting set or what the address is on the acclerometer. I'll start by assuming the chip is always selected and the address is zero (0). As far as your code goes the only address I recognized is the power control register, not sure where you got the other ones. there not on my data sheet. I'll keep you posted on what I find this weekend. And look forward to what others have to say. Brian |
Re: Help with 2010 Accelerometer & I2C
I had a little more time to dig into the data sheet and can see where you got address 3a and 3b from. It is the result of adding the r/w bit to the 7 bit address. From looking at the I2C code I wonder if it twittles that read write bit for you. I wonder if the address they are really looking for there is 0x1D.
If you want to work this out off line my email address is k9wis@yahoo.com Brian |
Re: Help with 2010 Accelerometer & I2C
One last thing...Don't try to turn on the measurement bit in the constructor.
There may be other objects associated with the I2C stuff that hasn't been constructed yet. Create an init method where you do the write and call it after you are sure all the construcing is done, like the first part of your main loop. Brian ::ouch:: |
Re: Help with 2010 Accelerometer & I2C
Yeah the address given in the Sensor Guide says 0x3A, and I figure its all in 8bit for the WPI Function, so the 0x1D wouldn't work with that but 0x3A would?? I really don't know I2C or WPI's implementation of it, so I don't really know. I'm going to keep playing with it tonight.
I also just found the register map, didn't see it in the datasheet when I worked on it last, don' know how I missed it. The biggest issue I am having now is whenever I call the read or write function the robot freezes up, and my console output shows nothing. This is both when I try to perform a read or a write.... |
Re: Help with 2010 Accelerometer & I2C
Any luck so far? It would be awesome if you got this working.
|
Re: Help with 2010 Accelerometer & I2C
Quote:
|
Re: Help with 2010 Accelerometer & I2C
The easiest approach would be to port the LabVIEW example called "ADXL345 I2C Accelerometer".
|
Re: Help with 2010 Accelerometer & I2C
Quote:
Brian |
Re: Help with 2010 Accelerometer & I2C
Quote:
Jacob |
Re: Help with 2010 Accelerometer & I2C
Quote:
|
Re: Help with 2010 Accelerometer & I2C
Quote:
This bug would prevent the accelerometer from working. |
Re: Help with 2010 Accelerometer & I2C
Yippeee!! everything is finally working....We re imaged the Crio, made sure 'ALL' the updates were applied to the driver station and the development laptop, compiled then downloaded the BuiltinDefaultCode.out file.
Then we added Joe's accelerometer code and fixed the I2C.cpp file. and all still worked. We had some problems with the IterativeDemo but I we'll revisit that later. The BuiltinDefaultcode is what we will base our robot code on. Thanks to all especially Joe Hersh for all the info and his patience..They don't pay you enough...Every one should send Joe a starbucks gift card so he can buy enough coffee to keep him awake when he sending those responses at 3 AM..:ahh: Brian C |
Re: Help with 2010 Accelerometer & I2C
Quote:
Thanks |
Re: Help with 2010 Accelerometer & I2C
Quote:
It will be officially included and supported in the next C++ update. |
Re: Help with 2010 Accelerometer & I2C
For some reason I keep receiving 0.0 from GetAcceleration(); am I instantiating the accelerometer correctly?:
ADXL345_I2C(4, ADXL345::kRange_2G) (assuming the digital sidecar is connected to slot 4) |
Re: Help with 2010 Accelerometer & I2C
We attached an oscilloscope to the bus and noticed that the data returned from the slave accelerometer is 0 for all three transactions (x, y, z); could it be attributed to some sort of a power saving feature which is not disabled?
|
Re: Help with 2010 Accelerometer & I2C
Quote:
If you fix the I2C library it should start working for you. |
Re: Help with 2010 Accelerometer & I2C
How would I patch wpilib? I could not find anything useful (besides the description of the bug).
|
Re: Help with 2010 Accelerometer & I2C
Quote:
-Joe |
Re: Help with 2010 Accelerometer & I2C
Will this patch be in a team update soon? It's not good that teams already have gone this long with broken support for something in the KoP...
|
Re: Help with 2010 Accelerometer & I2C
Quote:
Quote:
-Joe |
Re: Help with 2010 Accelerometer & I2C
Quote:
I get the "no such file or directory" error. |
Re: Help with 2010 Accelerometer & I2C
Quote:
What file or directory exactly does it fail on? -Joe |
Re: Help with 2010 Accelerometer & I2C
ok, I made a new project in Windriver. I copied the entire WPILib and its files (most recent release) into that project, and made the change to the logical OR.
The build target is specified as "Windows-gnu-native-3.x-4.x-debug" (I'm assuming thats what you mean by building the debug version.) The error is that it can't find "WPILib.h" after I run the updateBuiltInLibrary.cmd |
Re: Help with 2010 Accelerometer & I2C
Quote:
|
Re: Help with 2010 Accelerometer & I2C
Thank you sir. You have been most helpful!
|
Re: Help with 2010 Accelerometer & I2C
Quote:
The updates could be optional (e.g., not an 'official mandatory' team update) until the season draws to a close to prevent teams freaking out over things that aren't affecting them until ship draws close. In any case, thanks a lot for your replies and the hard work you've been doing to make the lives of FIRST teams easier :) |
Re: Help with 2010 Accelerometer & I2C
Should the cRIO need to be re-imaged for the patched WPILib to take effect?
I find that I am still unable to write to the device. Extra details: I know I'm not writing to the device because after I write to PowerControl and DataFormat regAddress's, I read them, and get back nothing (0). I know I'm reading correctly because I can get the DeviceID just fine. I have patched the WPILib as previous posts have instructed, but I think there might be a missing last step or something obvious that I'm missing. |
Re: Help with 2010 Accelerometer & I2C
Quote:
-Joe |
Re: Help with 2010 Accelerometer & I2C
Make sure you are building the debug build of WPILib.
|
Re: Help with 2010 Accelerometer & I2C
FYI: They just released an update to WPILib that fixes all this and adds the ADXL345_I2C class.
It also (finally) adds support for reading 7 bytes instead of just 4. Now I can use the FIFO buffer on the device properly. |
Re: Help with 2010 Accelerometer & I2C
I still receive 0.0 for all three axes, even after updating WPILib and removing the ADXL class I inserted earlier; any ideas?
|
Re: Help with 2010 Accelerometer & I2C
Quote:
|
| All times are GMT -5. The time now is 12:38. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi