a fork of priustroller

Dependencies:   mbed

Fork of priustroller_current by N K

Committer:
nki
Date:
Mon Mar 16 03:09:48 2015 +0000
Revision:
33:e7b132029bae
Parent:
27:846c08fb3697
New working set - reverted to synchronous current sensor reads

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bwang 11:dccbaa9274c5 1 #include "includes.h"
bwang 11:dccbaa9274c5 2 #include "transforms.h"
bwang 11:dccbaa9274c5 3 #include "fastmath.h"
bwang 11:dccbaa9274c5 4
bwang 11:dccbaa9274c5 5 void Transforms::Clarke(float a, float b, float *alpha, float *beta) {
bwang 11:dccbaa9274c5 6 *alpha = a;
bwang 11:dccbaa9274c5 7 *beta = (a + 2.0f * b)/sqrt(3.0f);
bwang 11:dccbaa9274c5 8 }
bwang 11:dccbaa9274c5 9
bwang 14:1cc975207995 10 void Transforms::InverseClarke(float alpha, float beta, float *a, float *b) {
bwang 14:1cc975207995 11 *a = alpha;
bwang 14:1cc975207995 12 *b = -0.5 * alpha + sqrt(3.0f) / 2.0f * beta;
bwang 14:1cc975207995 13 }
bwang 14:1cc975207995 14
nki 33:e7b132029bae 15 void Transforms::Parke(float beta, float alpha, float theta, float *d, float *q) {
bwang 11:dccbaa9274c5 16 float cos = FastCos(theta);
bwang 11:dccbaa9274c5 17 float sin = FastSin(theta);
bwang 11:dccbaa9274c5 18 *d = alpha * cos + beta * sin;
bwang 11:dccbaa9274c5 19 *q = -alpha * sin + beta * cos;
bwang 11:dccbaa9274c5 20 }
bwang 11:dccbaa9274c5 21
nki 33:e7b132029bae 22 void Transforms::InverseParke(float d, float q, float theta, float *alpha, float *beta) {
bwang 11:dccbaa9274c5 23 float cos = FastCos(theta);
bwang 11:dccbaa9274c5 24 float sin = FastSin(theta);
bwang 11:dccbaa9274c5 25 *alpha = cos * d - sin * q;
nki 33:e7b132029bae 26 *beta = sin * d + cos * q;
bwang 11:dccbaa9274c5 27 }