N K / Mbed 2 deprecated priustroller_2

Dependencies:   mbed

Fork of priustroller by Bayley Wang

Files at this revision

API Documentation at this revision

Comitter:
nki
Date:
Mon Mar 16 03:09:48 2015 +0000
Parent:
32:4e1a223fad52
Child:
34:bfe180de813a
Commit message:
New working set - reverted to synchronous current sensor reads

Changed in this revision

callbacks.cpp Show annotated file Show diff for this revision Revisions of this file
context.cpp Show annotated file Show diff for this revision Revisions of this file
context.h Show annotated file Show diff for this revision Revisions of this file
core/core.h Show annotated file Show diff for this revision Revisions of this file
core/inverter.cpp Show annotated file Show diff for this revision Revisions of this file
core/motor.cpp Show annotated file Show diff for this revision Revisions of this file
includes.h Show annotated file Show diff for this revision Revisions of this file
isr.cpp Show diff for this revision Revisions of this file
isr.h Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
sensors/NativeAnalogIn.cpp Show diff for this revision Revisions of this file
sensors/currentsensors.cpp Show annotated file Show diff for this revision Revisions of this file
sensors/positionsensors.cpp Show annotated file Show diff for this revision Revisions of this file
sensors/sensors.h Show annotated file Show diff for this revision Revisions of this file
sensors/tempsensors.cpp Show annotated file Show diff for this revision Revisions of this file
sensors/voltagesensors.cpp Show annotated file Show diff for this revision Revisions of this file
util/transforms.cpp Show annotated file Show diff for this revision Revisions of this file
util/transforms.h Show annotated file Show diff for this revision Revisions of this file
--- a/callbacks.cpp	Mon Mar 16 02:43:19 2015 +0000
+++ b/callbacks.cpp	Mon Mar 16 03:09:48 2015 +0000
@@ -12,38 +12,15 @@
     float I_b, I_c, angle, d_filtered, q_filtered, vd, vq;
     dbg_ib = I_b = c->motor->GetCurrentB();
     dbg_ic = I_c = c->motor->GetCurrentC();
-    
     dbg_angle = angle = c->motor->GetPosition();
     
     Clarke(-(I_b + I_c), I_b, &alpha, &beta);
     Parke(alpha, beta, angle, &d, &q);
     
-    dbg_ialpha = alpha;
-    dbg_ibeta = beta;
-    
-    d_filtered = c->filter_d->Update(d);
-    q_filtered = c->filter_q->Update(q);
-    
-    /*
-    
-    //these envelope d and q about 0.  the envelope looks like this:
-    // X= -1 0 1 
-    // ____| | |____  
-    //     \___/      
-    if(d_filtered < 1.0f & d_filtered > -1.0f) d_filtered = 0.0f;
-    if(d_filtered < 2.0f & d_filtered >= 1.0f) d_filtered = (d_filtered-1.0f)*d_filtered;
-    if(d_filtered > -2.0f & d_filtered <= -1.0f) d_filtered = (-d_filtered-1.0f)*d_filtered;
-    
-    if(q_filtered < 1.0f & q_filtered > -1.0f) q_filtered = 0.0f;
-    if(q_filtered < 2.0f & q_filtered >= 1.0f) q_filtered = (q_filtered-1.0f)*q_filtered;
-    if(q_filtered > -2.0f & q_filtered <= -1.0f) q_filtered = (-q_filtered-1.0f)*q_filtered;
-    */
-    
-    dbg_d_filtered = d_filtered;
-    dbg_q_filtered = q_filtered;
-    
+    dbg_d_filtered = d_filtered = c->filter_d->Update(d);
+    dbg_q_filtered = q_filtered = c->filter_q->Update(q);
 
-    c->reference->GetReference(angle, -c->user->throttle, &ref_d, &ref_q);
+    c->reference->GetReference(angle, c->user->throttle, &ref_d, &ref_q);
     
     dbg_ref_d = ref_d;
     dbg_ref_q = ref_q;
@@ -55,10 +32,9 @@
     vq = c->user->throttle;
     */
     
-    vd = 0.0f;
-    vq = 1.0f;
+    vd = 0.05f;
+    vq = 0.95f;
     
-
     InverseParke(vd, vq, angle, &valpha, &vbeta);
     
     c->modulator->Update(valpha, vbeta); 
@@ -69,15 +45,10 @@
 }
 
 void debug(Context *c) {
-    //c->serial->printf("CR1:%x CR2:%x SMPR1:%x SMPR2:%x\n\r", ADC1->CR1, ADC1->CR2, ADC1->SMPR1, ADC1->SMPR2);
-    //c->serial->printf("%f %f %f %d %d\n\r",dbg_angle, dbg_ib,dbg_ic, channel_ib, channel_ic);
     //c->serial->printf("%f %f %f %f %f %f\n\r", dbg_d_filtered, dbg_q_filtered, dbg_ref_d, dbg_ref_q, dbg_loop_d, dbg_loop_q);
-   // c->serial->printf("%f %f %f\n\r", dbg_angle, dbg_d_filtered, dbg_q_filtered);
 }
 
 void log(Context *c) {
-    //c->debugger->Write(0, dbg_angle);
-    //c->debugger->Write(1, 0);
-    //c->debugger->Write(0, dbg_ib);
-    //c->debugger->Write(1, dbg_ic);
+    c->debugger->Write(0, dbg_d_filtered);
+    c->debugger->Write(1, dbg_q_filtered);
 }
\ No newline at end of file
--- a/context.cpp	Mon Mar 16 02:43:19 2015 +0000
+++ b/context.cpp	Mon Mar 16 03:09:48 2015 +0000
@@ -71,7 +71,9 @@
     _callbacks[_index++] = f;
 }
 
-void Context::Start() {    
+void Context::Start() {
+    InitData();
+    
     for (;;) {
         for (int i = 0; i < _index; i++) {
             if (_time - _call_times[i] >= _call_periods[i]) {
@@ -88,17 +90,9 @@
 }
 
 void Context::InitData() {
-    serial = new Serial(USBTX, USBRX);
-    serial->baud(115200);
-    serial->printf("%s\n\r", "Init Serial Communications");
-    
     sense_p = new AnalogHallPositionSensor(_pos_a_pin, _pos_b_pin, _cal1_a, _cal2_a, _cal1_b, _cal2_b, _offset);
-    channel_ib = NativeAnalogIn::PinToAdcChannel(_ib_pin);
-    channel_ic = NativeAnalogIn::PinToAdcChannel(_ic_pin);
-    AnalogIn dummyb = AnalogIn(_ib_pin);
-    AnalogIn dummyc = AnalogIn(_ic_pin);
-    _dummyb = dummyb;
-    _dummyc = dummyc;
+    sense_ib = new AnalogCurrentSensor(_ib_pin, _scale);
+    sense_ic = new AnalogCurrentSensor(_ic_pin, _scale);
     throttle = new Throttle(_throttle_pin, _min, _max);
     sense_bus = new VoltageSensor();
     sense_t_motor = new TempSensor();
@@ -107,7 +101,7 @@
     pid_d = new PidController(_dki, _dkp, _dkd, _dpidmax, _dpidmin);
     pid_q = new PidController(_qki, _qkp, _qkd, _qpidmax, _qpidmin);
     
-    motor = new Motor(sense_p, sense_t_motor);
+    motor = new Motor(sense_ic, sense_ib, sense_p, sense_t_motor);
     inverter = new Inverter(_oa, _ob, _oc, _en, sense_bus, sense_t_inverter);
     user = new User(throttle);
     modulator = new SvmModulator(inverter);
@@ -115,30 +109,9 @@
     filter_d = new MeanFilter(_filter_strength);
     filter_q = new MeanFilter(_filter_strength);
     
-    wait(1);
-    
-    double ib_mean, ic_mean;
-    TIM2->DIER = 0;
-    for (int i = 0; i < 100; i++) {
-        ADC1->SQR3 = 0;
-        ADC1->SQR3 |= channel_ib;
-        ADC1->CR2 |= ADC_CR2_SWSTART;
-        while ((ADC1->SR & 2) == 0){}
-        ib_mean += (float) ADC1->DR;
-        
-        ADC1->SQR3 = 0;
-        ADC1->SQR3 |= channel_ic;
-        ADC1->CR2 |= ADC_CR2_SWSTART;
-        while ((ADC1->SR & 2) == 0){}
-        ic_mean += (float) ADC1->DR;
-    }
-    TIM2->DIER = 1;
-    ib_mean /= 100.0f;
-    ib_mean /= 4095.0f;
-    ic_mean /= 100.0f;
-    ic_mean /= 4095.0f;
-    
-    motor->InitSensors((float) ib_mean, (float) ic_mean, _scale);
+    serial = new Serial(USBTX, USBRX);
+    serial->baud(115200);
+    serial->printf("%s\n\r", "Init Serial Communications");
     
     debugger = new BufferedDebugger(this, _debugger_channels, _debugger_size);
 }
--- a/context.h	Mon Mar 16 02:43:19 2015 +0000
+++ b/context.h	Mon Mar 16 03:09:48 2015 +0000
@@ -23,13 +23,13 @@
     void ConfigureReference(float max_current);
     void ConfigureDebugger(int debugger_channels, int debugger_size);
     void AttachCallBack(void (*f)(Context *), int freq);
-    void InitData();
     void Start();
 public:
     Inverter *inverter;
     Motor *motor;
     User *user;
     Throttle *throttle;
+    CurrentSensor *sense_ib, *sense_ic;
     PositionSensor *sense_p;
     TempSensor *sense_t_motor, *sense_t_inverter;
     VoltageSensor *sense_bus;
@@ -40,6 +40,8 @@
     LtiFilter *filter_d, *filter_q;
     BufferedDebugger *debugger;
 private:
+    void InitData();
+private:
     void upd_function();
 private:
     PinName _oa, _ob, _oc, _ib_pin, _ic_pin, _throttle_pin, _pos_a_pin, _pos_b_pin, _en;
@@ -53,8 +55,6 @@
     int _index;
     unsigned long _time;
     
-    float _dummyb, _dummyc;
-    
     Ticker *_time_upd_ticker;
 };
 #endif
\ No newline at end of file
--- a/core/core.h	Mon Mar 16 02:43:19 2015 +0000
+++ b/core/core.h	Mon Mar 16 03:09:48 2015 +0000
@@ -13,21 +13,18 @@
 
 class Motor {
 public:
-    Motor(PositionSensor *sense_p, TempSensor *sense_t);
-    void InitSensors(float ib_zero, float ic_zero, float scale);
+    Motor(CurrentSensor *sense_c, CurrentSensor *sense_b, PositionSensor *sense_p, TempSensor *sense_t);
     void Config(int num_poles, float kv);
     float GetCurrentC();
     float GetCurrentB();
     float GetPosition();
     float GetTemp();
 private:
+    CurrentSensor *_sense_c,*_sense_b;
     PositionSensor *_sense_p;
     TempSensor *_sense_t;
     int _num_poles;
     float _kv;
-    float _ib, _ic;
-    float _ib_zero, _ic_zero;
-    float _scale;
 };
 
 class Inverter {
--- a/core/inverter.cpp	Mon Mar 16 02:43:19 2015 +0000
+++ b/core/inverter.cpp	Mon Mar 16 03:09:48 2015 +0000
@@ -20,21 +20,10 @@
     SetDtcB(0);
     SetDtcC(0);
     
-    TIM2->CR1 &= ~(TIM_CR1_CEN); //disable tim2
-    //TIM2->CR1 |= TIM_CR1_CMS;  //set bits 5 and 6 of the CR1 to 1.  (TIM_CR1_CMS == 96)
-    TIM2->CR1 |= (1 << 5);  //by only enabling bit 5, "Output compare interrupt flags of channels configured in output (CCxS=00 in TIMx_CCMRx register) 
-                      //are set only when the counter is counting down"  (p.342)
-    //These lines do nothing so they are commented out.  They should do something..
-    /*
-    TIM2->CR1 &= ~(1 << 6);
-    //hmm, not sure what's going on there.  It's set to only trigger when counting down, however it triggers at both underflow and overflow
+    TIM2->CR1 &= ~(TIM_CR1_CEN);
+    TIM2->CR1 |= TIM_CR1_CMS;
+    TIM2->CR1 |= TIM_CR1_CEN;
     
-    TIM2->CR1 &= ~(1 << 1);  //Set bit 1 (update disable) to 0.  we want the timer overflow to trigger an interrupt
-    //TIM2->CR1 |= (1 << 2);  //Set bit 2 (update request source) to 1.  Only want under/overflow to trigger an interrupt.
-    */
-    
-    TIM2->DIER |= 1; // set bit 0 equal to 1.  this enables interrupts 
-    TIM2->CR1 |= TIM_CR1_CEN;  //enable tim2
     Enable();
 }
 
--- a/core/motor.cpp	Mon Mar 16 02:43:19 2015 +0000
+++ b/core/motor.cpp	Mon Mar 16 03:09:48 2015 +0000
@@ -2,19 +2,19 @@
 #include "core.h"
 #include "sensors.h"
 
-Motor::Motor(PositionSensor *sense_p, TempSensor *sense_t) {
+Motor::Motor(CurrentSensor *sense_c, CurrentSensor *sense_b, PositionSensor *sense_p, TempSensor *sense_t) {
+    _sense_c = sense_c;
+    _sense_b = sense_b;
     _sense_p = sense_p;
     _sense_t = sense_t;
 }
 
 float Motor::GetCurrentC() {
-    float x = (float) global_ic / 4095.0f;
-    return (x - _ic_zero) / _scale;
+    return _sense_c->GetCurrent();
 }
 
 float Motor::GetCurrentB() {
-    float x = (float) global_ib / 4095.0f;
-    return (x - _ib_zero) / _scale;
+    return _sense_b->GetCurrent();
 }
 
 float Motor::GetPosition() {
@@ -28,10 +28,4 @@
 void Motor::Config(int num_poles, float kv) {
     _num_poles = num_poles;
     _kv = kv;
-}
-
-void Motor::InitSensors(float ib_zero, float ic_zero, float scale) {
-    _ib_zero = ib_zero;
-    _ic_zero = ic_zero;
-    _scale = scale;
 }
\ No newline at end of file
--- a/includes.h	Mon Mar 16 02:43:19 2015 +0000
+++ b/includes.h	Mon Mar 16 03:09:48 2015 +0000
@@ -5,18 +5,10 @@
 #include "math.h"
 #include "fastmath.h"
 #include "transforms.h"
-#include "context.h"
-#include "stm32f411xe.h"
 
 using namespace FastMath;
 using namespace Transforms;
 
-extern Context *context;
-
-extern DigitalOut toggler;
-extern volatile unsigned short global_ib, global_ic;
-extern uint32_t channel_ib, channel_ic;
-
 extern float debug_registers[32];
 
 #define dbg_angle debug_registers[0]
@@ -33,9 +25,5 @@
 #define dbg_q_filtered debug_registers[11]
 #define dbg_ref_d debug_registers[12]
 #define dbg_ref_q debug_registers[13]
-#define dbg_ialpha debug_registers[14]
-#define dbg_ibeta debug_registers[15]
-#define dbg_ascaled debug_registers[16]
-#define dbg_bscaled debug_registers[17]
 
 #endif
\ No newline at end of file
--- a/isr.cpp	Mon Mar 16 02:43:19 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-#include "includes.h"
-
-extern "C" void TIM2_IRQn_Handler() {
-    TIM2->SR &= ~1;
-    ADC1->SQR1 &= ~ADC_SQR1_L;
-    ADC1->SQR3 = 0;
-    ADC1->SQR3 |= channel_ib;
-    ADC1->CR2 |= ADC_CR2_SWSTART;
-    while ((ADC1->SR & 2) == 0){}
-    global_ib = ADC1->DR;
-    
-    ADC1->SQR3 = 0;
-    ADC1->SQR3 |= channel_ic;
-    ADC1->CR2 |= ADC_CR2_SWSTART;
-    while ((ADC1->SR & 2) == 0){}
-    global_ic = ADC1->DR;
-} 
\ No newline at end of file
--- a/isr.h	Mon Mar 16 02:43:19 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-#ifndef __ISR_H
-#define __ISR_H
-
-#include "includes.h"
-
-extern "C" void TIM2_IRQn_Handler();
-
-#endif
\ No newline at end of file
--- a/main.cpp	Mon Mar 16 02:43:19 2015 +0000
+++ b/main.cpp	Mon Mar 16 03:09:48 2015 +0000
@@ -6,28 +6,20 @@
 #include "meta.h"
 #include "sensors.h"
 #include "callbacks.h"
-#include "isr.h"
-
-volatile unsigned short global_ib, global_ic;
-uint32_t channel_ib, channel_ic;
 
 int main() { 
-    NVIC_EnableIRQ(TIM2_IRQn);
-    NVIC_SetVector(TIM2_IRQn, (uint32_t)TIM2_IRQn_Handler);
-        
     Context *context = new Context();
     context->ConfigureOutputs(D6, D13, D3, D8);
-    context->ConfigurePositionSensor(A4, A5, 0.249f, 0.497f, 0.231f, 0.499f, 205.0f); 
-    context->ConfigureIdPidController(0.0001f, 0.0f, 0.0f, 5.0f, -5.0f);
-    context->ConfigureIqPidController(0.00001f, 0.1f, 0.0f, 5.0f, -5.0f);
+    context->ConfigureCurrentSensors(A1, A2, 0.01f, 0.7f);
+    context->ConfigureIdPidController(0.01f, 0.8f, 0.0f, 2.0f, -2.0f);
+    context->ConfigureIqPidController(0.01f, 0.8f, 0.0f, 2.0f, -2.0f);
     context->ConfigureThrottle(A0, 0.8f, 3.0f);
-    context->ConfigureCurrentSensors(A1, A2, 0.01f, 0.7f);  // I guess this configures the ADCs or something 
+    context->ConfigurePositionSensor(A4, A5, 0.249f, 0.497f, 0.231f, 0.499f, 205.0f);
     context->ConfigureReference(5.0f);
     context->ConfigureDebugger(2, 1000);
     context->AttachCallBack(&fast, 5000);
     context->AttachCallBack(&slow, 10);
     context->AttachCallBack(&debug, 10);
     context->AttachCallBack(&log, 500);
-    context->InitData();
     context->Start();
 }
--- a/sensors/NativeAnalogIn.cpp	Mon Mar 16 02:43:19 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-#include "includes.h"
-#include "sensors.h"
-
-NativeAnalogIn::NativeAnalogIn(PinName pin) {
-    AnalogIn dummy(pin);
-    _dummy = dummy;
-    ADC1->CR1 &= ~ADC_CR1_JEOCIE;
-    ADC1->CR1 &= ~ADC_CR1_EOCIE;
-    ADC1->CR1 &= ~ADC_CR1_AWDIE;
-    ADC1->CR1 &= ~ADC_CR1_OVRIE;
-    ADC1->CR2 |= ADC_CR2_ADON;
-    ADC1->SQR1 = 0;
-    _channel = PinToAdcChannel(pin);
-}
-
-float NativeAnalogIn::Read() {
-    TIM2->DIER = 0x0000;
-    ADC1->SQR3 = 0x0000;
-    ADC1->SQR3 |= _channel;
-    ADC1->CR2 |= ADC_CR2_SWSTART;
-    while ((ADC1->SR & 2) == 0){}
-    float x = ADC1->DR;
-    TIM2->DIER = 0x0001;
-    return x / 4095.0f;
-}
-
-unsigned char NativeAnalogIn::PinToAdcChannel(PinName pin) {
-    switch (pin) {
-    case A0:
-        return 0;
-    case A1:
-        return 1;
-    case A2:
-        return 4;
-    case A4:
-        return 11;
-    case A5:
-        return 10;
-    default:
-        return 0;
-    }
-}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sensors/currentsensors.cpp	Mon Mar 16 03:09:48 2015 +0000
@@ -0,0 +1,21 @@
+#include "includes.h"
+#include "sensors.h"
+
+AnalogCurrentSensor::AnalogCurrentSensor(PinName pin, float volts_per_amp) {
+    _in = new AnalogIn(pin);
+    _volts_per_amp = volts_per_amp;
+    wait_us(100000);
+    Zero();
+}
+
+void AnalogCurrentSensor::Zero() {
+    float mean = 0;
+    for(int i = 0; i < 1000; i++){
+        mean += (float) *_in;
+    }
+    _zero_level = mean / 1000;
+}
+
+float AnalogCurrentSensor::GetCurrent() {
+    return ((float) *_in - _zero_level) * 3.3f / _volts_per_amp;
+}
\ No newline at end of file
--- a/sensors/positionsensors.cpp	Mon Mar 16 02:43:19 2015 +0000
+++ b/sensors/positionsensors.cpp	Mon Mar 16 03:09:48 2015 +0000
@@ -4,8 +4,8 @@
 
 AnalogHallPositionSensor::AnalogHallPositionSensor(PinName pin_a, PinName pin_b, float cal1_a, float cal2_a, 
                              float cal1_b, float cal2_b, float offset) {
-    _in_a = new NativeAnalogIn(pin_a);
-    _in_b = new NativeAnalogIn(pin_b);
+    _in_a = new AnalogIn(pin_a);
+    _in_b = new AnalogIn(pin_b);
     _cal1_a = cal1_a;
     _cal2_a = cal2_a;
     _cal1_b = cal1_b;
@@ -18,9 +18,6 @@
     float ascaled = 2 * (((float) *_in_a - _cal1_a) / (_cal2_a - _cal1_a) - 0.5f);
     float bscaled = 2 * (((float) *_in_b - _cal1_b)/ (_cal2_b - _cal1_b) - 0.5f);
     
-    dbg_ascaled = ascaled;
-    dbg_bscaled = bscaled;
-    
     float x = bscaled / ascaled;
     
     unsigned int index = (abs(x) / ATAN_UPPER_BOUND) * ATAN_TABLE_SIZE;
--- a/sensors/sensors.h	Mon Mar 16 02:43:19 2015 +0000
+++ b/sensors/sensors.h	Mon Mar 16 03:09:48 2015 +0000
@@ -3,15 +3,10 @@
 
 #include "includes.h"
 
-class NativeAnalogIn {
+class CurrentSensor {
 public:
-    NativeAnalogIn(PinName pin);
-    float Read();
-    operator float() {return Read();}
-    static unsigned char PinToAdcChannel(PinName pin);
-private:
-    unsigned char _channel;
-    float _dummy;
+    virtual float GetCurrent() {return 0.0f;}
+    virtual void Zero() {}
 };
 
 class VoltageSensor {
@@ -30,6 +25,16 @@
     virtual float GetTemp() {return 0.0f;}
 };
 
+class AnalogCurrentSensor: public CurrentSensor {
+public:
+    AnalogCurrentSensor(PinName pin, float volts_per_amp);
+    virtual void Zero();
+    virtual float GetCurrent();
+private:
+    float _zero_level, _volts_per_amp;
+    AnalogIn *_in;
+};
+
 class AnalogVoltageSensor: public VoltageSensor {
 public:
     AnalogVoltageSensor(PinName pin, float scale);
@@ -37,7 +42,7 @@
     virtual float GetVoltage();
 private:
     float _zero_level, _scale;
-    NativeAnalogIn *_in;
+    AnalogIn *_in;
 };
 
 class AnalogHallPositionSensor: public PositionSensor {
@@ -49,7 +54,7 @@
     float _cal1_a, _cal2_a;
     float _cal1_b, _cal2_b;
     float _offset;
-    NativeAnalogIn *_in_a, *_in_b;
+    AnalogIn *_in_a, *_in_b;
 };
 
 class NtcTempSensor: public TempSensor {
@@ -58,7 +63,7 @@
     virtual float GetTemp();
 private:
     float _ntc_a, _ntc_b, _r_divider;
-    NativeAnalogIn *_in;
+    AnalogIn *_in;
 };
 
 class Throttle {
--- a/sensors/tempsensors.cpp	Mon Mar 16 02:43:19 2015 +0000
+++ b/sensors/tempsensors.cpp	Mon Mar 16 03:09:48 2015 +0000
@@ -2,7 +2,7 @@
 #include "sensors.h"
 
 NtcTempSensor::NtcTempSensor(PinName pin, float r_25, float ntc_b, float r_divider) {
-    _in = new NativeAnalogIn(pin);
+    _in = new AnalogIn(pin);
     _ntc_b = ntc_b;
     _ntc_a = r_25 / exp(_ntc_b / 298.0f);
     _r_divider = r_divider;
--- a/sensors/voltagesensors.cpp	Mon Mar 16 02:43:19 2015 +0000
+++ b/sensors/voltagesensors.cpp	Mon Mar 16 03:09:48 2015 +0000
@@ -2,7 +2,7 @@
 #include "sensors.h"
 
 AnalogVoltageSensor::AnalogVoltageSensor(PinName pin, float scale) {
-    _in = new NativeAnalogIn(pin);
+    _in = new AnalogIn(pin);
     _scale = scale;
 }
 
--- a/util/transforms.cpp	Mon Mar 16 02:43:19 2015 +0000
+++ b/util/transforms.cpp	Mon Mar 16 03:09:48 2015 +0000
@@ -12,22 +12,16 @@
     *b = -0.5 * alpha + sqrt(3.0f) / 2.0f * beta;
 }
 
-void Transforms::Parke(float beta, float alpha, float theta, float *d, float *q) {  
-    //reversed alpha and beta order to make d and q ~=constant.
-    //I did this because alpha was found to be sinusoidal and beta was found to be cosinusoidal.  the equation has to take the form sin^2 + cos^2, not sin*cos + sin*cos.
+void Transforms::Parke(float beta, float alpha, float theta, float *d, float *q) {
     float cos = FastCos(theta);
     float sin = FastSin(theta);
-
     *d = alpha * cos + beta * sin;
     *q = -alpha * sin + beta * cos;
-
 }
 
-void Transforms::InverseParke(float d, float q, float theta, float *alpha, float *beta) {  
+void Transforms::InverseParke(float d, float q, float theta, float *alpha, float *beta) {
     float cos = FastCos(theta);
     float sin = FastSin(theta);
-
     *alpha = cos * d - sin * q;
-    *beta = sin * d + cos * q; 
-                              
+    *beta = sin * d + cos * q;                                
 }
\ No newline at end of file
--- a/util/transforms.h	Mon Mar 16 02:43:19 2015 +0000
+++ b/util/transforms.h	Mon Mar 16 03:09:48 2015 +0000
@@ -4,7 +4,7 @@
 namespace Transforms {
     void Clarke(float a, float b, float *alpha, float *beta);
     void InverseClarke(float alpha, float beta, float *a, float *b);
-    void Parke(float alpha, float beta, float theta, float *d, float *q);
+    void Parke(float beta, float alpha, float theta, float *d, float *q);
     void InverseParke(float d, float q, float theta, float *alpha, float *beta);  
 };