working-est copy with class-based code. still open loop

Dependencies:   mbed

Fork of analoghalls6 by N K

referencesynthesizers.cpp

Committer:
nki
Date:
2015-03-06
Revision:
9:d3b70c15baa9
Parent:
6:99ee0ce47fb2
Child:
10:b4abecccec7a

File content as of revision 9:d3b70c15baa9:

#include "includes.h"
#include "meta.h"
#include "lut.h"

void SynchronousReferenceSynthesizer::GetReference(float angle, float *ref_d, float *ref_q) {
    *ref_d = 0.0f;
    *ref_q = _max_phase_current;
}

float ReferenceSynthesizer::LutSin(float theta) {
    if (theta < 0.0f) theta += 360.0f;
    if (theta >= 360.0f) theta -= 360.0f;
    return sinetab[(int) theta] * 2.0f - 1.0f;
}

float ReferenceSynthesizer::LutCos(float theta) {
    return LutSin(90.0f - theta);
}