Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of priustroller_2 by
modulators.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 "core.h"
#include "meta.h"
#include "sensors.h"
#include "lut.h"
void SinusoidalModulator::Update(float va, float vb) {
_inverter->va = va;
_inverter->vb = vb;
//inverse \alpha \beta (Clarke) transform
_inverter->SetDtcA(va/2.0f + 0.5f);
_inverter->SetDtcB(((-va + sqrt(3.0f)*vb)/2.0f)/2.0f + 0.5f);
_inverter->SetDtcC(((-va - sqrt(3.0f)*vb)/2.0f)/2.0f + 0.5f);
/*
_inverter->SetDtcA((LutSin(va)/2.0f)+0.5f);
_inverter->SetDtcB((LutSin(va - 120.0f)/2.0f)+0.5f);
_inverter->SetDtcC((LutSin(va + 120.0f)/2.0f)+0.5f);
*/
test_DtcA = vb/2.0f + 0.5f;
test_DtcB = ((-vb + sqrt(3.0f)*va)/2.0f)/2.0f + 0.5f;
test_DtcC = ((-vb - sqrt(3.0f)*va)/2.0f)/2.0f + 0.5f;
/*
_inverter->SetDtcA(1.0f);
_inverter->SetDtcB(0.5f);
_inverter->SetDtcC(1.0f);
*/
}
float SinusoidalModulator::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 SinusoidalModulator::LutCos(float theta) {
return LutSin(90.0f - theta);
}
