Kosaka Lab / Mbed 2 deprecated BLDCmotor

Dependencies:   QEI mbed-rtos mbed

Fork of BLDCmotor by manabu kosaka

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers fast_math.h Source File

fast_math.h

00001 #ifndef __fast_math_h
00002 #define __fast_math_h
00003 
00004 #define PI 3.14159265358979 // π: def. of PI
00005 #define DEG60   512         // 60degを512に定義
00006 
00007 extern unsigned short  sin60[]; // sin table from 0 to 60 deg. (max precision error is 0.003%)
00008 // sin(th) = (float)(_sin(th/(PI/3.)*(float)DEG60+0.5))/65535.;
00009 extern long _sin(unsigned short);    // return( 65535*sin(th) ), th=rad*DEG60/(PI/3)=rad*(512*3)/PI (0<=rad<2*PI)
00010 extern long _cos(unsigned short);    // return( 65535*sin(th) ), th=rad*DEG60/(PI/3)=rad*(512*3)/PI (0<=rad<2*PI)
00011 extern void init_fast_math();       // call before using _sin(). sin0-sin60deg; 0deg=0, 60deg=512
00012 
00013 //extern float  norm(float);          // 2ノルムを計算
00014 extern float  sqrt2(float x);         // √xのx=1まわりのテイラー展開 √x = 1 + 1/2*(x-1) -1/4*(x-1)^2 + ...
00015 
00016 #endif