N K
/
GaNtroller
a fork of priustroller
Fork of priustroller_current by
meta/referencesynthesizers.cpp@55:f102d271e808, 2015-05-21 (annotated)
- Committer:
- nki
- Date:
- Thu May 21 02:19:25 2015 +0000
- Revision:
- 55:f102d271e808
- Parent:
- 34:bfe180de813a
still testing;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bwang | 11:dccbaa9274c5 | 1 | #include "includes.h" |
bwang | 11:dccbaa9274c5 | 2 | #include "meta.h" |
bwang | 11:dccbaa9274c5 | 3 | #include "sensors.h" |
bwang | 11:dccbaa9274c5 | 4 | #include "lut.h" |
bwang | 11:dccbaa9274c5 | 5 | #include "core.h" |
bwang | 11:dccbaa9274c5 | 6 | |
bwang | 11:dccbaa9274c5 | 7 | void SynchronousReferenceSynthesizer::GetReference(float angle, float throttle, float *ref_d, float *ref_q) { |
nki | 34:bfe180de813a | 8 | *ref_d = 0.00f; |
bwang | 11:dccbaa9274c5 | 9 | *ref_q = _max_phase_current * throttle; |
bwang | 11:dccbaa9274c5 | 10 | } |
bwang | 11:dccbaa9274c5 | 11 | |
bwang | 11:dccbaa9274c5 | 12 | float ReferenceSynthesizer::LutSin(float theta) { |
bwang | 11:dccbaa9274c5 | 13 | if (theta < 0.0f) theta += 360.0f; |
bwang | 11:dccbaa9274c5 | 14 | if (theta >= 360.0f) theta -= 360.0f; |
bwang | 11:dccbaa9274c5 | 15 | return sinetab[(int) theta] * 2.0f - 1.0f; |
bwang | 11:dccbaa9274c5 | 16 | } |
bwang | 11:dccbaa9274c5 | 17 | |
bwang | 11:dccbaa9274c5 | 18 | float ReferenceSynthesizer::LutCos(float theta) { |
bwang | 11:dccbaa9274c5 | 19 | return LutSin(90.0f - theta); |
bwang | 11:dccbaa9274c5 | 20 | } |