![]() |
C++ I2C Accelerometer - Can't send power
We have recently installed the 2010 Accelerometer (ADXL345) on our robot and have the new ADXL345 class code in Windriver. But whenever we try to read values from it, they all read 0. We believe this is because according to the FIRST Sensor Manual, “The ADXL345 starts in a power saving mode. You must turn it on by writing 0x08 to POWER_CTL (0X2D) before it will do anything interesting.”
We are not sure how to write any values to the I2C class to turn on the accelerometer. We tried accessing the write function from the I2C class through the ADXL345_I2C class and using it within the main robot class, but then the code would not compile. What syntax would we use to write the value "0x08" to the POWER_CTL and turn on the accelerometer? |
Re: C++ I2C Accelerometer - Can't send power
If you are using the ADXL345_I2C class, you should not have to deal with I2C. The class will take care of it for you. It will do the intialization for you provided that you give it the correct slot of your digital I/O module and correctly wire the accelerometer to the I2C port on the digital side car. Assuming your digital I/O module is in the default slot 4, your code should look something like this:
Code:
private:Code:
ADXL345_I2C::ADXL345_I2C(UINT32 slot, ADXL345_I2C::DataFormat_Range range) |
| All times are GMT -5. The time now is 13:04. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi