
EMG and motor script together, Not fully working yet,.
Dependencies: Encoder MODSERIAL QEI biquadFilter mbed
Fork of Code_MotorEMG by
Diff: main.cpp
- Revision:
- 11:f23fe69ba3ef
- Parent:
- 10:952377fbbbfe
- Child:
- 12:ea9afe159eb1
--- a/main.cpp Wed Nov 01 11:18:18 2017 +0000 +++ b/main.cpp Wed Nov 01 11:36:04 2017 +0000 @@ -358,12 +358,12 @@ void MotorController1() { - float reference_o = counto-hcounto; + int reference_o = (int) (counto-hcounto); int position_o = Encoder1.getPulses(); erroro = reference_o - position_o; - pc.printf("Position_o = %i \n\r",position_o); + pc.printf("Position_o = %i \n\r reference_o=%.2f\n\r",position_o,reference_o); if (-100<erroro && erroro<100){ motorValue1 = 0; @@ -387,7 +387,7 @@ void MotorController2() { - float reference_b = countb-hcountb; + int reference_b = (int) (countb-hcountb); int position_b = Encoder2.getPulses(); errorb = reference_b - position_b; @@ -416,7 +416,7 @@ void MotorController3() { - float reference_r = countr-hcountr; + int reference_r = (int) (countr-hcountr); int position_r = Encoder3.getPulses(); errorr = reference_r - position_r; @@ -462,7 +462,7 @@ rotr=Lru/omtrekklosje; counto=roto*4200; dcounto=counto-hcounto; - pc.printf("counto = %f \n\r", counto); + //pc.printf("counto = %f \n\r", counto); //pc.printf("hcounto = %f \n\r", hcounto); //pc.printf("dcounto = %f \n\r",dcounto); countb=rotb*4200; @@ -481,11 +481,11 @@ touwlengtes(); Pex=Pstx; Pey=Psty; - pc.printf("een stappie verder\n\r x=%.2f\n\r y=%.2f\n\r",Pstx,Psty); + //pc.printf("een stappie verder\n\r x=%.2f\n\r y=%.2f\n\r",Pstx,Psty); //pc.printf("met lengtes:\n\r Lo=%.2f Lb=%.2f Lr=%.2f\n\r",Lou,Lbu,Lru); turns(); //pc.printf("rotatie per motor:\n\r o=%.2f b=%.2f r=%.2f\n\r",roto,rotb,rotr); - pc.printf("counts per motor:\n\r o=%.2f b=%.2f r=%.2f\n\r",counto,countb,countr); + //pc.printf("counts per motor:\n\r o=%.2f b=%.2f r=%.2f\n\r",counto,countb,countr); /*float R; R=Vex/Vey; // met dit stukje kan je zien dat de verhouding tussen Vex en Vey constant is en de end efector dus een rechte lijn maakt pc.printf("\n\r R=%f",R);*/