yep

Dependencies:   FastPWM2 mbed

Revision:
0:2d2fa105dbb0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Dec 10 08:38:16 2015 +0000
@@ -0,0 +1,58 @@
+#include "mbed.h"
+#include "FastPWM.h"
+AnalogIn ref_raw(A3);
+Ticker read_adc;
+AnalogOut output(A2);
+FastPWM pwm_output(D3);
+DigitalOut testing(D2);
+
+double raw[5] = {0, 0, 0, 0, 0};
+double ref[5] = {0, 0, 0, 0, 0};
+/*
+double raw;
+double old_raw = 0;
+double old_raw_2 = 0;
+double old_raw_3 = 0;
+double old_raw_4 = 0;
+double ref;
+double old_ref = 0;
+double old_ref_2 = 0;
+double old_ref_3 = 0;
+double old_ref_4 = 0;
+*/
+double b[5] = {0.000000018682489340283,   0.000000074729957361130,   0.000000112094936041696,   0.000000074729957361130,   0.000000018682489340283};
+double a[5] = {1.000000000000000,  -3.938430361819403,   5.817179417349660,  -3.819034001378269,   0.940285244767841};
+
+//double b[5] = {0.000144120224075409, 0.000576480896301634, 0.000864721344452452, 0.000576480896301634, 0.000144120224075409};
+//double a[5] = {1.000000000000000, -3.384972728303897, 4.337061817421342, -2.489138293812547, 0.539355128280308};
+
+void read_ref(void){
+    //ref = 3.3*(analog_value.read()-.5);
+    //output.write(ref_raw.read());
+    raw[0] = .85*(ref_raw.read()-.5)+.5;
+//    ref = raw;
+   
+    ref[0] = b[0]*raw[0]+b[1]*raw[1]+b[2]*raw[2]+b[3]*raw[3]+b[4]*raw[4]-a[1]*ref[1]-a[2]*ref[2]-a[3]*ref[3]-a[4]*ref[4];
+    
+    for (int i=4; i > 0; i--){
+        raw[i] = raw[i-1];
+        ref[i] = ref[i-1];
+        }
+
+    output.write(ref[0]);
+    pwm_output.write(ref[0]+.03);
+    //testing=!testing;
+    }
+    
+int main() {
+    testing=0;
+    pwm_output.period(.000025);
+    read_adc.attach(&read_ref, .000025);
+    testing = 0;
+    while(1) {
+        //ref_raw.read();
+        //pwm_output.write(.5);
+        //ref_raw.read();
+        //testing = !testing;
+    }
+}