|
Dezibot 4
|
Go to the documentation of this file.
10 digitalWrite(34,HIGH);
15 delayMicroseconds(250);
48 return raw_temperatur/128 +25;
59 for(uint i = 0;i<20;i++){
61 delayMicroseconds(10);
64 (((axis &&
xAxis) > 0) && (abs(abs(measurment1.
x)-abs(measurment2.
x))>threshold)) ||
65 (((axis &&
yAxis) > 0) && (abs(abs(measurment1.
y)-abs(measurment2.
y))>threshold)) ||
66 (((axis &&
zAxis) > 0) && (abs(abs(measurment1.
z)-abs(measurment2.
z))>threshold))){
69 delayMicroseconds(15);
81 bool flipped = reading.
z < 0;
82 float accelrationStrenght = sqrt(reading.
x*reading.
x+reading.
y*reading.
y+reading.
z*reading.
z);
84 if (abs(accelrationStrenght-this->
gForceCalib) > tolerance ){
93 yAngle = atan(
float(reading.
x)/reading.
z)*180/3.1415+0.5;
94 xAngle = atan(
float(reading.
y)/reading.
z)*180/3.1415+0.5;
96 yAngle = 90*(reading.
x > 0) - (reading.
x < 0);
97 xAngle = 90*(reading.
y > 0) - (reading.
y < 0);
106 xAngle = -1*(180-xAngle);
112 yAngle = -1*(180-yAngle);
128 Serial.println(Rot.
xRotation == INT_MAX);
164 digitalWrite(34,LOW);
167 result =
handler->transfer(0x00);
168 digitalWrite(34,HIGH);
187 delayMicroseconds(10);
189 delayMicroseconds(10);
196 Serial.println(
"CLK not rdy");
200 Serial.print(
"MADDR_W: ");
217 delayMicroseconds(10);
219 Serial.print(
"MADDR_W: ");
246 int16_t fifocount = 0;
249 fifocount = (fifohigh<<8)|fifolow;
252 Serial.println(fifolow);
253 Serial.println(fifohigh);
254 Serial.println(fifocount);
256 digitalWrite(34,LOW);
259 digitalWrite(34,HIGH);
263 delayMicroseconds(10);
265 for(
int i = 0; i<fifocount;i++){
270 buffer[i].
gyro.
x = (
buf[0x08+16*i]<<8)|
buf[0x07+16*i];
271 buffer[i].
gyro.
y = (
buf[0x0A+16*i]<<8)|
buf[0x09+16*i];
272 buffer[i].
gyro.
z = (
buf[0x0C+16*i]<<8)|
buf[0x0B+16*i];
281 digitalWrite(34,LOW);
284 digitalWrite(34,HIGH);
285 delayMicroseconds(10);
This component controls the IMU (Accelerometer & Gyroscope) ICM-42670-P.
#define ACCEL_DATA_Z_HIGH
void calibrateZAxis(uint gforceValue)
uint16_t cmdRead(uint8_t regHigh, uint8_t regLow)
static const uint frequency
IMUResult getAcceleration(void)
Triggers a new Reading of the accelerationvalues and reads them from the IMU.
#define ACCEL_DATA_X_HIGH
IMUResult getRotation(void)
Triggers a new reading of the gyroscope and reads the values from the imu.
uint8_t readFromRegisterBank(registerBank bank, uint8_t reg)
void end(void)
stops the component Sets the IMU to Low-Power-Mode
uint getDataFromFIFO(FIFO_Package *buffer)
will read all availible packages from fifo, after 40ms Fifo is full
Orientation getTilt()
calculates how the robot is tilted. It is set, that when the robot is placed normally on a flat table...
void writeToRegisterBank(registerBank bank, uint8_t reg, uint8_t value)
float getTemperature(void)
Reads the current On Chip temperature of the IMU.
void begin(void)
initialized the IMU Component. Wakes the IMU from Standby Set configuration
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...
Direction getTiltDirection(uint tolerance=10)
Checks in which direction (Front, Left, Right, Back) the robot is tilted.
void writeRegister(uint8_t reg, uint8_t value)
#define ACCEL_DATA_Y_HIGH
uint16_t cmdWrite(uint8_t regHigh, uint8_t regLow)
uint8_t readRegister(uint8_t reg)
int8_t getWhoAmI(void)
Returns the value of reading the whoAmI register When IMU working correctly, value should be 0x67.
void resetRegisterBankAccess()