I have a problem when trying to run the SQRT function.
The system hangs and returns the following message:
Here's the test code . note that if you uncomment the line " x = 2; " the program works normally.
It also works normally use ATAN in place of SQRT .
ATAN2 have also hangs .
Someone went through it and managed to solve ?
Thanks.
#include "math.h"
#include "I2Cdev.h"
#include "MPU6050.h"
#include "Wire.h"
MPU6050 accelgyro;
int16_t ax, ay, az;
int16_t gx, gy, gz;
void setup() {
Wire.begin();
Serial.begin(115200);
// initialize device
Serial.println("Initializing I2C devices...");
accelgyro.initialize();
// verify connection
Serial.println("Testing device connections...");
Serial.println(accelgyro.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed");
Serial.print("\n");
}
void loop() {
double g;
// read raw accel/gyro measurements from device
accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
//ax= 2; //uncomment and works
Serial.print("ax=");
Serial.println(ax);
g = sqrt(ax);
Serial.print("g=");
Serial.println(g);
delay(200);
}