
EMG and motor script together, Not fully working yet,.
Dependencies: Encoder MODSERIAL QEI biquadFilter mbed
Fork of Code_MotorEMG by
Diff: main.cpp
- Revision:
- 18:00379f0ecc7f
- Parent:
- 17:0acc8d4b142c
- Child:
- 19:6567ed67d6ee
--- a/main.cpp Wed Nov 01 12:34:47 2017 +0000 +++ b/main.cpp Wed Nov 01 12:59:02 2017 +0000 @@ -3,8 +3,9 @@ //#include "encoder.h" #include "QEI.h" #include "BiQuad.h" +#include "MODSERIAL.h" -Serial pc(USBTX, USBRX); +MODSERIAL pc(USBTX, USBRX); //Defining all in- and outputs //EMG input @@ -361,9 +362,9 @@ int error_o = reference_o - position_o; - //pc.printf("Position_o = %i reference_o=%i Error_o=%i\n\r" ,position_o,reference_o,error_o); + pc.printf("Position_o = %i reference_o=%i Error_o=%i\n\r" ,position_o,reference_o,error_o); - if (-100<error_o && error_o<100){ + if (-10<error_o && error_o<10){ motorValue1 = 0; } else { @@ -392,7 +393,7 @@ //pc.printf("Position_b = %i reference_b=%i Error_b=%i " ,position_b,reference_b,error_b); - if (-100<error_b && error_b<100){ + if (-10<error_b && error_b<10){ motorValue2 = 0; } else { @@ -422,7 +423,7 @@ //pc.printf("Position_r = %i reference_r=%i Error_r=%i\n\r" ,position_r,reference_r,error_r); - if (-100<error_r && error_r<100){ + if (-10<error_r && error_r<10){ motorValue3 = 0; } @@ -575,12 +576,12 @@ getbqChain(); threshold_timerR.attach(&Threshold_samplingBR, 0.002); threshold_timerL.attach(&Threshold_samplingBL, 0.002); + setcurrentposition(); while(true){ sample_timer.attach(&EMG_sample, 0.002); wait(2.5f); tellerX(); tellerY(); - setcurrentposition(); calculator(); controlmotor1.attach(&MotorController1, 0.01); controlmotor2.attach(&MotorController2, 0.01);