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.
Dependencies: mbed-dev-f303 FastPWM3
Diff: Transforms/Transforms.cpp
- Revision:
- 20:bf9ea5125d52
- Parent:
- 19:bd10a04eedc2
- Child:
- 21:7d1f0a206668
--- a/Transforms/Transforms.cpp Tue Feb 14 03:28:16 2017 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-#include "mbed.h"
-#include "Transforms.h"
-#include "FastMath.h"
-
-using namespace FastMath;
-
-void Transforms::Park(float alpha, float beta, float theta, float *d, float *q){
- //float cosine = cos(theta);
- //float sine = sin(theta);
- float cosine = FastCos(theta);
- float sine = FastSin(theta);
- //*d = alpha*cosine - beta*sine; //This is a hack - effectively using -beta instead of beta
- //*q = -beta*cosine - alpha*sine; //I think because I'm using pi as the d axis offset instead of zero, but I need to investigate more.
- *d = alpha*cosine + beta*sine;
- *q = beta*cosine - alpha*sine;
- //DAC->DHR12R1 = (int) (*q*49.648f) + 2048;
- //DAC->DHR12R1 = (int) (*q*2048.0f) + 2048;
- }
-
-void Transforms::InvPark(float d, float q, float theta, float *alpha, float *beta){
- //float cosine = cos(theta);
- //float sine = sin(theta);
- float cosine = FastCos(theta);
- float sine = FastSin(theta);
- *alpha = d*cosine - q*sine;
- *beta = q*cosine + d*sine;
- }
-
-void Transforms::Clarke(float a, float b, float *alpha, float *beta){
- *alpha = a;
- *beta = 0.57735026919f*(a + 2.0f*b);
- }
-
-void Transforms::InvClarke(float alpha, float beta, float *a, float *b, float *c){
- *a = alpha;
- *b = 0.5f*(-alpha + 1.73205080757f*beta);
- *c = 0.5f*(-alpha - 1.73205080757f*beta);
- }
-