10 digitalWrite(34,HIGH);
15 delayMicroseconds(250);
53 return raw_temperatur/128 +25;
64 for(uint i = 0;i<20;i++){
66 delayMicroseconds(10);
69 (((axis &&
xAxis) > 0) && (abs(abs(measurment1.
x)-abs(measurment2.
x))>threshold)) ||
70 (((axis &&
yAxis) > 0) && (abs(abs(measurment1.
y)-abs(measurment2.
y))>threshold)) ||
71 (((axis &&
zAxis) > 0) && (abs(abs(measurment1.
z)-abs(measurment2.
z))>threshold))){
74 delayMicroseconds(15);
86 bool flipped = reading.
z < 0;
87 float accelrationStrenght = sqrt(reading.
x*reading.
x+reading.
y*reading.
y+reading.
z*reading.
z);
89 if (abs(accelrationStrenght-this->
gForceCalib) > tolerance ){
98 yAngle = atan(
float(reading.
x)/reading.
z)*180/3.1415+0.5;
99 xAngle = atan(
float(reading.
y)/reading.
z)*180/3.1415+0.5;
101 yAngle = 90*(reading.
x > 0) - (reading.
x < 0);
102 xAngle = 90*(reading.
y > 0) - (reading.
y < 0);
111 xAngle = -1*(180-xAngle);
117 yAngle = -1*(180-yAngle);
166 digitalWrite(34,LOW);
169 result =
handler->transfer(0x00);
170 digitalWrite(34,HIGH);
189 delayMicroseconds(10);
191 delayMicroseconds(10);
198 Serial.println(
"CLK not rdy");
217 delayMicroseconds(10);
253 int16_t fifocount = 0;
256 fifocount = (fifohigh<<8)|fifolow;
258 digitalWrite(34,LOW);
261 digitalWrite(34,HIGH);
265 delayMicroseconds(10);
267 for(
int i = 0; i<fifocount;i++){
272 buffer[i].
gyro.
x = (
buf[0x08+16*i]<<8)|
buf[0x07+16*i];
273 buffer[i].
gyro.
y = (
buf[0x0A+16*i]<<8)|
buf[0x09+16*i];
274 buffer[i].
gyro.
z = (
buf[0x0C+16*i]<<8)|
buf[0x0B+16*i];
283 digitalWrite(34,LOW);
286 digitalWrite(34,HIGH);
287 delayMicroseconds(10);
#define ACCEL_DATA_Z_HIGH
#define ACCEL_DATA_Y_HIGH
#define ACCEL_DATA_X_HIGH
This component controls the IMU (Accelerometer & Gyroscope) ICM-42670-P.
void stopFIFO(void)
stops writing results to FIFO-Storage needs to be called before Data Registers (such as GYRO_DATA_*,...
uint getDataFromFIFO(FIFO_Package *buffer)
will read all availible packages from fifo, after 40ms Fifo is full Only works when startFIFO was cal...
uint16_t cmdWrite(uint8_t regHigh, uint8_t regLow)
bool isShaken(uint32_t threshold=defaultShakeThreshold, uint8_t axis=xAxis|yAxis|zAxis)
Detects if at the time of calling is shaken. Therefore the sum over all accelerationvalues is calcula...
uint8_t readFromRegisterBank(registerBank bank, uint8_t reg)
uint16_t cmdRead(uint8_t regHigh, uint8_t regLow)
uint8_t readRegister(uint8_t reg)
void resetRegisterBankAccess()
Orientation getTilt()
calculates how the robot is tilted. It is set, that when the robot is placed normally on a flat table...
int8_t getWhoAmI(void)
Returns the value of reading the whoAmI register When IMU working correctly, value should be 0x67.
static const uint frequency
IMUResult getRotation(void)
Triggers a new reading of the gyroscope and reads the values from the imu.
Direction getTiltDirection(uint tolerance=10)
Checks in which direction (Front, Left, Right, Back) the robot is tilted.
void calibrateZAxis(uint gforceValue)
void startFIFO(void)
starts writing the measurment results to the FIFO-Storage
void end(void)
stops the component Sets the IMU to Low-Power-Mode
void writeRegister(uint8_t reg, uint8_t value)
void writeToRegisterBank(registerBank bank, uint8_t reg, uint8_t value)
void begin(void)
initialized the IMU Component. Wakes the IMU from Standby Set configuration
void initFIFO(void)
makes all settings necessary so it is possible to use the FIFO, but does not actually start writing p...
IMUResult getAcceleration(void)
Triggers a new Reading of the accelerationvalues and reads them from the IMU.
float getTemperature(void)
Reads the current On Chip temperature of the IMU.