Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By dwindey1
#55532 Hi,
I am building a quadcopter with an ESP8266 as a flight controller. In theory is could work. For the 'transmitter' Blynk over wifi is used (via a Raspberry Pi Blynk server). An MPU6050 sensor is used for balancing.
But it seems the ESP8266 math.h library (from Arduino IDE) is missing the sqrt() function necessary to calculate angles.
Anyone knows where to find a math.h library with the sqrt function, or knows a way to calculate angles (from an accellerometer G value) without need of a square root, or has a suggestion of any other way to get there.
I am looking into this problem for a few weeks now and I'm getting a bit frustrated :-). And it would be a pitty not being able to use our favorite controller.

thanks
User avatar
By RichardS
#55534 A really fast sqrt() function I wrote once....

Just a thought.... you might want a float one....

RichardS

Code: Select allconst uint16_t sqrt_integer_guess_table[33] = {
55109,
38968,
27555,
19484,
13778,
 9742,
 6889,
 4871,
 3445,
 2436,
 1723,
 1218,
  862,
  609,
  431,
  305,
  216,
  153,
  108,
   77,
   54,
   39,
   27,
   20,
   14,
   10,
    7,
    5,
    4,
    3,
    2,
    1,
    0
};

__INLINE uint32_t sqrt_uint32(uint32_t in)
{
   uint32_t n = sqrt_integer_guess_table[__builtin_clz(in)];
   n = ((in / n) + n) / 2;
   n = ((in / n) + n) / 2;
   n = ((in / n) + n) / 2;
   return n;
}
User avatar
By RichardS
#55536 How about pow(x,0.5)??

RichardS
User avatar
By RichardS
#55538 OK I just tested:

pow(4.3,0.5);

and

sqrt(4.3);

and they both work for me...

Arduino board support for ESP8266 2.3.0

RichardS