motor spins

Dependencies:   mbed

Fork of analoghalls5 by Bayley Wang

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers referencesynthesizers.cpp Source File

referencesynthesizers.cpp

00001 #include "includes.h"
00002 #include "meta.h"
00003 #include "lut.h"
00004 
00005 void SynchronousReferenceSynthesizer::GetReference(float angle, float *ref_d, float *ref_q) {
00006     *ref_d = _max_phase_current * LutSin(angle);
00007     *ref_q = 0.0f;
00008 }
00009 
00010 float ReferenceSynthesizer::LutSin(float theta) {
00011     if (theta < 0.0f) theta += 360.0f;
00012     if (theta >= 360.0f) theta -= 360.0f;
00013     return sinetab[(int) theta] * 2.0f - 1.0f;
00014 }
00015 
00016 float ReferenceSynthesizer::LutCos(float theta) {
00017     return LutSin(90.0f - theta);
00018 }