motor spins

Dependencies:   mbed

Fork of analoghalls5 by Bayley Wang

Committer:
bwang
Date:
Mon Mar 02 01:24:37 2015 +0000
Revision:
3:0a2396597e0d
Child:
5:ee1e6c84c302
should turn moter

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bwang 3:0a2396597e0d 1 #include "includes.h"
bwang 3:0a2396597e0d 2 #include "meta.h"
bwang 3:0a2396597e0d 3 #include "lut.h"
bwang 3:0a2396597e0d 4
bwang 3:0a2396597e0d 5 void SynchronousReferenceSynthesizer::GetReference(float angle, float *ref_d, float *ref_q) {
bwang 3:0a2396597e0d 6 *ref_d = _max_phase_current * LutSin(angle);
bwang 3:0a2396597e0d 7 *ref_q = 0.0f;
bwang 3:0a2396597e0d 8 }
bwang 3:0a2396597e0d 9
bwang 3:0a2396597e0d 10 float ReferenceSynthesizer::LutSin(float theta) {
bwang 3:0a2396597e0d 11 if (theta < 0.0f) theta += 360.0f;
bwang 3:0a2396597e0d 12 if (theta >= 360.0f) theta -= 360.0f;
bwang 3:0a2396597e0d 13 return sinetab[(int) theta];
bwang 3:0a2396597e0d 14 }
bwang 3:0a2396597e0d 15
bwang 3:0a2396597e0d 16 float ReferenceSynthesizer::LutCos(float theta) {
bwang 3:0a2396597e0d 17 return LutSin(90.0f - theta);
bwang 3:0a2396597e0d 18 }