Control up to two motors using filtered EMG signals and a PID controller
Dependencies: FastPWM HIDScope MODSERIAL QEI Matrix biquadFilter controller errorFetch mbed motorConfig refGen MatrixMath inverseKinematics
Fork of Minor_test_serial by
Diff: main.cpp
- Revision:
- 18:65e24db15c69
- Parent:
- 17:616ce7bc1f96
--- a/main.cpp Thu Sep 21 11:53:09 2017 +0000 +++ b/main.cpp Fri Sep 29 08:08:19 2017 +0000 @@ -9,7 +9,6 @@ QEI Encoder(D12,D13,NC,64, QEI::X4_ENCODING); MODSERIAL pc(USBTX, USBRX); -HIDScope scope(2); // Defining outputs DigitalOut motor1_direction(D4); @@ -41,12 +40,9 @@ // Displaying revs in HIDscope x = revs; // Capture data - scope.set(0, x); // store data in first element of scope memory y = (x_prev + x)/2.0; // averaging filter - scope.set(1, y); // store data in second element of scope memory x_prev = x; // Prepare for next round - scope.send(); // send what's in scope memory to PC } void killSwitch(){ @@ -66,12 +62,14 @@ int main() { + pc.baud(115200); + pc.printf("Entered main function"); motor1_direction = false; motor1_pwm.period(pwmPeriod);//T=1/f sw2.fall(&killSwitch); sw3.fall(&turnMotorsOn); button1.rise(&M1switchDirection); - pc.baud(115200); + encoderTicker.attach(readEncoder, 0.1); pc.printf("Encoder ticker attached and baudrate set");