UVW 3 phases Brushless DC motor control

Dependencies:   QEI mbed-rtos mbed

Fork of DCmotor by manabu kosaka

Committer:
kosaka
Date:
Fri Jun 07 08:49:44 2013 +0000
Revision:
14:7f83c4b96d34
Parent:
13:791e20f1af43
mbed-rtos is updated

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kosaka 12:a4b17bb682eb 1 #ifndef __fast_math_h
kosaka 12:a4b17bb682eb 2 #define __fast_math_h
kosaka 12:a4b17bb682eb 3
kosaka 13:791e20f1af43 4 #define PI 3.14159265358979 // π: def. of PI
kosaka 13:791e20f1af43 5 #define DEG60 512 // 60degを512に定義
kosaka 12:a4b17bb682eb 6
kosaka 12:a4b17bb682eb 7 extern unsigned short sin60[]; // sin table from 0 to 60 deg. (max precision error is 0.003%)
kosaka 12:a4b17bb682eb 8 // sin(th) = (float)(_sin(th/(PI/3.)*(float)DEG60+0.5))/65535.;
kosaka 12:a4b17bb682eb 9 extern long _sin(unsigned short); // return( 65535*sin(th) ), th=rad*DEG60/(PI/3)=rad*(512*3)/PI (0<=rad<2*PI)
kosaka 12:a4b17bb682eb 10 extern long _cos(unsigned short); // return( 65535*sin(th) ), th=rad*DEG60/(PI/3)=rad*(512*3)/PI (0<=rad<2*PI)
kosaka 12:a4b17bb682eb 11 extern void init_fast_math(); // call before using _sin(). sin0-sin60deg; 0deg=0, 60deg=512
kosaka 12:a4b17bb682eb 12
kosaka 12:a4b17bb682eb 13 //extern float norm(float); // 2ノルムを計算
kosaka 12:a4b17bb682eb 14 extern float sqrt2(float x); // √xのx=1まわりのテイラー展開 √x = 1 + 1/2*(x-1) -1/4*(x-1)^2 + ...
kosaka 12:a4b17bb682eb 15
kosaka 12:a4b17bb682eb 16 #endif