now with PID controler XXXD

Dependencies:   HIDScope MODSERIAL QEI biquadFilter mbed

Fork of another_try_from_scratch_on_emg by Daniqe Kottelenberg

Committer:
sivuu
Date:
Thu Nov 03 09:55:11 2016 +0000
Revision:
50:2c03357de7cc
Parent:
49:818a0e90ed9c
Child:
51:b344a92b6a5f
most variables defined, only not all encoder things, void reference does not work yet

Who changed what in which revision?

UserRevisionLine numberNew contents of line
daniQQue 46:4a8889f9dc9f 1 //=====================================================================================
daniQQue 0:34c739fcc3e0 2 //libraries
daniQQue 49:818a0e90ed9c 3 #include "mbed.h" //mbed revision 113
daniQQue 49:818a0e90ed9c 4 #include "HIDScope.h" //Hidscope by Tom Lankhorst
daniQQue 49:818a0e90ed9c 5 #include "BiQuad.h" //BiQuad by Tom Lankhorst
daniQQue 49:818a0e90ed9c 6 #include "MODSERIAL.h" //Modserial
sivuu 50:2c03357de7cc 7 #include "QEI.h" //QEI library for the encoders
daniQQue 0:34c739fcc3e0 8
daniQQue 46:4a8889f9dc9f 9
daniQQue 46:4a8889f9dc9f 10 //=====================================================================================
daniQQue 0:34c739fcc3e0 11 //Define objects
daniQQue 49:818a0e90ed9c 12
daniQQue 49:818a0e90ed9c 13 //EMG
sivuu 50:2c03357de7cc 14 AnalogIn emg_biceps_right_in (A0); //analog in to get EMG biceps (r) in to c++
daniQQue 40:187ef29de53d 15 AnalogIn emg_triceps_right_in(A1); //analog in to get EMG triceps (r) in to c++
daniQQue 40:187ef29de53d 16 AnalogIn emg_biceps_left_in (A2); //analog in to get EMG biceps (l) in to c++
daniQQue 49:818a0e90ed9c 17
daniQQue 49:818a0e90ed9c 18 //Tickers
daniQQue 49:818a0e90ed9c 19 Ticker sample_timer; //ticker for EMG signal sampling, analog becomes digital
daniQQue 49:818a0e90ed9c 20 Ticker ticker_switch; //ticker for switch, every second it is possible to switch
sivuu 50:2c03357de7cc 21 Ticker ticker_referenceangle; //ticker for the reference angle
sivuu 50:2c03357de7cc 22 Ticker ticker_controllerm1; //ticker for the controller (PID) of motor 1
daniQQue 49:818a0e90ed9c 23
daniQQue 49:818a0e90ed9c 24 //Monitoring
daniQQue 46:4a8889f9dc9f 25 HIDScope scope(5); //open 5 channels in hidscope
daniQQue 46:4a8889f9dc9f 26 MODSERIAL pc(USBTX, USBRX); //pc connection
daniQQue 49:818a0e90ed9c 27 DigitalOut red(LED_RED); //LED on K64F board, 1 is out; 0 is on
daniQQue 49:818a0e90ed9c 28 DigitalOut green(LED_GREEN); //LED on K64f board, 1 is out; o is on
daniQQue 40:187ef29de53d 29
daniQQue 40:187ef29de53d 30 //motors
sivuu 50:2c03357de7cc 31 DigitalOut richting_motor1(D7); //motor 1 connected to motor 1 at k64f board; for turningtable
daniQQue 47:ddaa59d48aca 32 PwmOut pwm_motor1(D6);
sivuu 50:2c03357de7cc 33 DigitalOut richting_motor2(D4); //motor 2 connected to motor 2 at k64f board; for linear actuator
daniQQue 47:ddaa59d48aca 34 PwmOut pwm_motor2(D5);
daniQQue 0:34c739fcc3e0 35
sivuu 50:2c03357de7cc 36 //encoders
sivuu 50:2c03357de7cc 37 DigitalIn encoder1A(D13);
sivuu 50:2c03357de7cc 38 DigitalIn encoder1B(D12);
sivuu 50:2c03357de7cc 39 DigitalIn encoder2A(D11);
sivuu 50:2c03357de7cc 40 DigitalIn encoder2B(D10);
sivuu 50:2c03357de7cc 41
sivuu 50:2c03357de7cc 42 //controller
sivuu 50:2c03357de7cc 43 BiQuad PID_controller;
sivuu 50:2c03357de7cc 44
sivuu 50:2c03357de7cc 45
daniQQue 46:4a8889f9dc9f 46 //=====================================================================================
daniQQue 0:34c739fcc3e0 47 //define variables
daniQQue 47:ddaa59d48aca 48
sivuu 50:2c03357de7cc 49 //thresholds
sivuu 50:2c03357de7cc 50 double treshold_biceps_right = 0.04; //common values that work.
sivuu 50:2c03357de7cc 51 double treshold_biceps_left = -0.04; // tested on multiple persons
sivuu 50:2c03357de7cc 52 double treshold_triceps = -0.04; //triceps and left biceps is specified negative, thus negative treshold
daniQQue 49:818a0e90ed9c 53
daniQQue 49:818a0e90ed9c 54 //on/off and switch signals
daniQQue 49:818a0e90ed9c 55 int switch_signal = 0; //start of counter, switch made by even and odd numbers
daniQQue 49:818a0e90ed9c 56 int onoffsignal_biceps;
daniQQue 45:08bddea67bd8 57 int switch_signal_triceps;
daniQQue 46:4a8889f9dc9f 58
daniQQue 49:818a0e90ed9c 59 //motorvariables
daniQQue 49:818a0e90ed9c 60 float speedmotor1=0.18; //speed of motor 1 is 0.18pwm at start
daniQQue 49:818a0e90ed9c 61 float speedmotor2=1.0; //speed of motor 2 is 1.0 pwm at start
daniQQue 46:4a8889f9dc9f 62
daniQQue 49:818a0e90ed9c 63 int cw=0; //clockwise direction
daniQQue 49:818a0e90ed9c 64 int ccw=1; //counterclockwise direction
sivuu 50:2c03357de7cc 65
sivuu 50:2c03357de7cc 66 //encoder
sivuu 50:2c03357de7cc 67 int counts_encoder1;
sivuu 50:2c03357de7cc 68 //int counts_encoder2;
sivuu 50:2c03357de7cc 69 float rev_counts_motor1;
sivuu 50:2c03357de7cc 70 float rev_counts_motor1_rad;
sivuu 50:2c03357de7cc 71
sivuu 50:2c03357de7cc 72
sivuu 50:2c03357de7cc 73 //reference
sivuu 50:2c03357de7cc 74 volatile float d_ref = 0;
sivuu 50:2c03357de7cc 75 const float w_ref = 3;
sivuu 50:2c03357de7cc 76 const double Ts = 0.001;
sivuu 50:2c03357de7cc 77
sivuu 50:2c03357de7cc 78 //controller
sivuu 50:2c03357de7cc 79 const double Kp = 0.3823;
sivuu 50:2c03357de7cc 80 const double Ki = 0.1279;
sivuu 50:2c03357de7cc 81 const double Kd = 0.2519;
sivuu 50:2c03357de7cc 82 const double N = 100;
sivuu 50:2c03357de7cc 83 volatile double error1;
sivuu 50:2c03357de7cc 84 volatile double controlOutput;
daniQQue 44:c79e5944ac91 85 //=======================================
daniQQue 44:c79e5944ac91 86 //filter coefficients
daniQQue 40:187ef29de53d 87
daniQQue 40:187ef29de53d 88 //b1 = biceps right arm
daniQQue 49:818a0e90ed9c 89 BiQuad filterhigh_b1(9.5654e-01,-1.9131e+00,9.5654e-01,-1.9112e+00,9.1498e-01); // second order highpass filter, with frequency of?
daniQQue 49:818a0e90ed9c 90 BiQuad filternotch1_b1 (9.9376e-01 , -1.8902e-00, 9.9376e-01 , -1.8902e-00 , 9.875e-01); // second order notch filter, with frequency of?
daniQQue 40:187ef29de53d 91
daniQQue 40:187ef29de53d 92 //t1= triceps right arm
daniQQue 49:818a0e90ed9c 93 BiQuad filterhigh_t1(9.5654e-01,-1.9131e+00,9.5654e-01,-1.9112e+00,9.1498e-01); // second order highpass filter, with frequency of?
daniQQue 49:818a0e90ed9c 94 BiQuad filternotch1_t1 (9.9376e-01 , -1.8902e-00, 9.9376e-01 , -1.8902e-00 , 9.875e-01); // second order notch filter, with frequency of?
daniQQue 5:688b1b5530d8 95
daniQQue 40:187ef29de53d 96 //b2= biceps left arm
daniQQue 49:818a0e90ed9c 97 BiQuad filterhigh_b2(9.5654e-01,-1.9131e+00,9.5654e-01,-1.9112e+00,9.1498e-01); // second order highpass filter, with frequency of?
daniQQue 49:818a0e90ed9c 98 BiQuad filternotch1_b2 (9.9376e-01 , -1.8902e-00, 9.9376e-01 , -1.8902e-00 , 9.875e-01); // second order notch filter, with frequency of?
daniQQue 40:187ef29de53d 99
daniQQue 40:187ef29de53d 100 //after abs filtering
daniQQue 49:818a0e90ed9c 101 BiQuad filterlow_b1 (6.2942e-06, 1.2588e-05,6.2942e-06,-1.9929e+00,9.9292e-01); // second order lowpass filter, with frequency of?
daniQQue 49:818a0e90ed9c 102 BiQuad filterlow_t1 (6.2942e-06, 1.2588e-05,6.2942e-06,-1.9929e+00,9.9292e-01); // second order lowpass filter, with frequency of?
daniQQue 49:818a0e90ed9c 103 BiQuad filterlow_b2 (6.2942e-06, 1.2588e-05,6.2942e-06,-1.9929e+00,9.9292e-01); // second order lowpass filter, with frequency of?
daniQQue 10:7255b59224cc 104
daniQQue 45:08bddea67bd8 105 //======================================================================
daniQQue 45:08bddea67bd8 106 //voids
daniQQue 45:08bddea67bd8 107 //======================================================================
daniQQue 45:08bddea67bd8 108
daniQQue 40:187ef29de53d 109 //function teller
daniQQue 49:818a0e90ed9c 110 void switch_function() { // The switch function. Makes it possible to switch between the motors. It simply adds one at switch_signal.
daniQQue 45:08bddea67bd8 111 if(switch_signal_triceps==1)
daniQQue 40:187ef29de53d 112 {
daniQQue 45:08bddea67bd8 113 switch_signal++;
daniQQue 49:818a0e90ed9c 114
daniQQue 49:818a0e90ed9c 115 // To monitor what is happening: we will show the text in putty and change led color from red to green or vice versa.
daniQQue 49:818a0e90ed9c 116
daniQQue 40:187ef29de53d 117 green=!green;
daniQQue 40:187ef29de53d 118 red=!red;
daniQQue 47:ddaa59d48aca 119
daniQQue 45:08bddea67bd8 120 if (switch_signal%2==0)
daniQQue 49:818a0e90ed9c 121 {pc.printf("If you contract the biceps, the robot will go right \r\n");
daniQQue 47:ddaa59d48aca 122 pc.printf("If you contract the triceps, the robot will go left \r\n");
daniQQue 47:ddaa59d48aca 123 pc.printf("\r\n");
daniQQue 47:ddaa59d48aca 124 }
daniQQue 47:ddaa59d48aca 125
daniQQue 47:ddaa59d48aca 126
daniQQue 47:ddaa59d48aca 127 else
daniQQue 40:187ef29de53d 128 {pc.printf("If you contract the biceps, the robot will go up \r\n");
daniQQue 40:187ef29de53d 129 pc.printf("If you contract the triceps, the robot will go down \r\n");
daniQQue 47:ddaa59d48aca 130 pc.printf("\r\n");
daniQQue 40:187ef29de53d 131 }
daniQQue 47:ddaa59d48aca 132
daniQQue 40:187ef29de53d 133 }
daniQQue 40:187ef29de53d 134 }
daniQQue 49:818a0e90ed9c 135
daniQQue 49:818a0e90ed9c 136 //======================================================================
daniQQue 49:818a0e90ed9c 137 //functions which are called in ticker to sample the analog signal and make the on/off and switch signal.
daniQQue 40:187ef29de53d 138
daniQQue 0:34c739fcc3e0 139 void filter(){
daniQQue 40:187ef29de53d 140 //biceps right arm read+filtering
daniQQue 49:818a0e90ed9c 141 double emg_biceps_right=emg_biceps_right_in.read(); //read the emg value from the elektrodes
daniQQue 49:818a0e90ed9c 142 double emg_filtered_high_biceps_right= filterhigh_b1.step(emg_biceps_right); //high pass filter, to remove offset
daniQQue 49:818a0e90ed9c 143 double emg_filtered_high_notch_1_biceps_right=filternotch1_b1.step(emg_filtered_high_biceps_right); //notch filter, to remove noise
daniQQue 49:818a0e90ed9c 144 double emg_abs_biceps_right=fabs(emg_filtered_high_notch_1_biceps_right); //rectify the signal, fabs because float
daniQQue 49:818a0e90ed9c 145 double emg_filtered_biceps_right=filterlow_b1.step(emg_abs_biceps_right); //low pass filter to envelope the signal
daniQQue 40:187ef29de53d 146
daniQQue 40:187ef29de53d 147 //triceps right arm read+filtering
daniQQue 49:818a0e90ed9c 148 double emg_triceps_right=emg_triceps_right_in.read(); //read the emg value from the elektrodes
daniQQue 49:818a0e90ed9c 149 double emg_filtered_high_triceps_right= filterhigh_t1.step(emg_triceps_right); //high pass filter, to remove offset
daniQQue 49:818a0e90ed9c 150 double emg_filtered_high_notch_1_triceps_right=filternotch1_t1.step(emg_filtered_high_triceps_right); //notch filter, to remove noise
daniQQue 49:818a0e90ed9c 151 double emg_abs_triceps_right=fabs(emg_filtered_high_notch_1_triceps_right); //rectify the signal, fabs because float
daniQQue 49:818a0e90ed9c 152 double emg_filtered_triceps_right=filterlow_t1.step(emg_abs_triceps_right); //low pass filter to envelope the signal
daniQQue 7:42d0e38196f1 153
daniQQue 40:187ef29de53d 154 //biceps left arm read+filtering
daniQQue 49:818a0e90ed9c 155 double emg_biceps_left=emg_biceps_left_in.read(); //read the emg value from the elektrodes
daniQQue 49:818a0e90ed9c 156 double emg_filtered_high_biceps_left= filterhigh_b2.step(emg_biceps_left); //high pass filter, to remove offset
daniQQue 49:818a0e90ed9c 157 double emg_filtered_high_notch_1_biceps_left=filternotch1_b2.step(emg_filtered_high_biceps_left); //notch filter, to remove noise
daniQQue 49:818a0e90ed9c 158 double emg_abs_biceps_left=fabs(emg_filtered_high_notch_1_biceps_left); //rectify the signal, fabs because float
daniQQue 49:818a0e90ed9c 159 double emg_filtered_biceps_left=filterlow_b2.step(emg_abs_biceps_left); //low pass filter to envelope the signal
daniQQue 40:187ef29de53d 160
daniQQue 40:187ef29de53d 161 //creating of on/off signal with the created on/off signals, with if statement for right arm!
daniQQue 44:c79e5944ac91 162 //signal substraction of filter biceps and triceps. right Biceps + left biceps -
daniQQue 44:c79e5944ac91 163 double signal_biceps_sum=emg_filtered_biceps_right-emg_filtered_biceps_left;
daniQQue 44:c79e5944ac91 164 double bicepstriceps_rightarm=emg_filtered_biceps_right-emg_filtered_triceps_right;
daniQQue 45:08bddea67bd8 165
daniQQue 44:c79e5944ac91 166 //creating of on/off signal with the created on/off signals, with if statement for right arm!
daniQQue 49:818a0e90ed9c 167 if (signal_biceps_sum>treshold_biceps_right)
daniQQue 49:818a0e90ed9c 168 {onoffsignal_biceps=1;}
daniQQue 7:42d0e38196f1 169
daniQQue 49:818a0e90ed9c 170 else if (signal_biceps_sum<treshold_biceps_left)
daniQQue 49:818a0e90ed9c 171 { onoffsignal_biceps=-1; }
daniQQue 40:187ef29de53d 172
daniQQue 49:818a0e90ed9c 173 else
daniQQue 49:818a0e90ed9c 174 {onoffsignal_biceps=0;}
daniQQue 7:42d0e38196f1 175
daniQQue 40:187ef29de53d 176 //creating on/off signal for switch (left arm)
daniQQue 40:187ef29de53d 177
daniQQue 49:818a0e90ed9c 178 if (bicepstriceps_rightarm<treshold_triceps)
daniQQue 49:818a0e90ed9c 179 { switch_signal_triceps=1; }
daniQQue 40:187ef29de53d 180
daniQQue 40:187ef29de53d 181 else
daniQQue 49:818a0e90ed9c 182 { switch_signal_triceps=0; }
daniQQue 49:818a0e90ed9c 183
daniQQue 49:818a0e90ed9c 184 //send signals to scope to monitor the EMG signals
daniQQue 49:818a0e90ed9c 185 scope.set(0, emg_filtered_biceps_right); //set emg signal of right biceps to scope in channel 0
daniQQue 49:818a0e90ed9c 186 scope.set(1, emg_filtered_triceps_right); // set emg signal of right triceps to scope in channel 1
daniQQue 49:818a0e90ed9c 187 scope.set(2, emg_filtered_biceps_left); // set emg signal of left biceps to scope in channel 2
daniQQue 49:818a0e90ed9c 188 scope.set(3, onoffsignal_biceps); // set on/off signal for the motors to scope in channel 3
daniQQue 49:818a0e90ed9c 189 scope.set(4, switch_signal_triceps); // set the switch signal to scope in channel 4
daniQQue 40:187ef29de53d 190
daniQQue 40:187ef29de53d 191 scope.send(); //send all the signals to the scope
daniQQue 0:34c739fcc3e0 192 }
sivuu 50:2c03357de7cc 193
sivuu 50:2c03357de7cc 194 void reference(){
sivuu 50:2c03357de7cc 195 if (button_cw == 0){
sivuu 50:2c03357de7cc 196 d_ref = d_ref + w_ref * Ts;
sivuu 50:2c03357de7cc 197 }
sivuu 50:2c03357de7cc 198 if (d_ref > 21.36 ){
sivuu 50:2c03357de7cc 199 d_ref = 21.36;
sivuu 50:2c03357de7cc 200 //d_ref_const_cw = 1;
sivuu 50:2c03357de7cc 201 }
sivuu 50:2c03357de7cc 202 else{
sivuu 50:2c03357de7cc 203 d_ref = d_ref;
sivuu 50:2c03357de7cc 204 }
sivuu 50:2c03357de7cc 205
sivuu 50:2c03357de7cc 206 if (button_ccw == 0){
sivuu 50:2c03357de7cc 207 d_ref = d_ref - w_ref * Ts;
sivuu 50:2c03357de7cc 208 }
sivuu 50:2c03357de7cc 209 if (d_ref < -21.36){
sivuu 50:2c03357de7cc 210 d_ref = -21.36;
sivuu 50:2c03357de7cc 211
sivuu 50:2c03357de7cc 212 }
sivuu 50:2c03357de7cc 213 else{
sivuu 50:2c03357de7cc 214 d_ref = d_ref;
sivuu 50:2c03357de7cc 215 }
sivuu 50:2c03357de7cc 216
sivuu 50:2c03357de7cc 217 }
sivuu 50:2c03357de7cc 218
sivuu 50:2c03357de7cc 219 void m1_controller(){
sivuu 50:2c03357de7cc 220 error1 = d_ref-rev_counts_motor1_rad;
sivuu 50:2c03357de7cc 221 ctrlOutput = PID_controller.step(error1);
sivuu 50:2c03357de7cc 222 }
sivuu 50:2c03357de7cc 223
daniQQue 49:818a0e90ed9c 224 //======================================================================
daniQQue 0:34c739fcc3e0 225 //program
daniQQue 49:818a0e90ed9c 226 //======================================================================
daniQQue 0:34c739fcc3e0 227 int main()
daniQQue 0:34c739fcc3e0 228 {
daniQQue 40:187ef29de53d 229
daniQQue 49:818a0e90ed9c 230 pc.baud(115200); //connect with pc with baudrate 115200
daniQQue 49:818a0e90ed9c 231 green=1; //led is off (1), at beginning
daniQQue 49:818a0e90ed9c 232 red=0; //led is on (0), at beginning
daniQQue 49:818a0e90ed9c 233
daniQQue 49:818a0e90ed9c 234 //attach tickers to functions
sivuu 50:2c03357de7cc 235 sample_timer.attach(&filter, Ts); //continously execute the EMG reader and filter, it ensures that filter and sampling is executed every 1/frequency seconds
daniQQue 45:08bddea67bd8 236 ticker_switch.attach(&switch_function,1.0);
sivuu 50:2c03357de7cc 237 ticker_referenceangle.attach(&reference, Ts);
sivuu 50:2c03357de7cc 238 ticker_controllerm1.attach(&m1_controller, Ts);
sivuu 50:2c03357de7cc 239
sivuu 50:2c03357de7cc 240 //PID controller
sivuu 50:2c03357de7cc 241 PID_controller.PIDF(Kp,Ki,Kd,N,Ts);
daniQQue 44:c79e5944ac91 242
daniQQue 49:818a0e90ed9c 243 //Show the user what the starting motor will be and what will happen
daniQQue 47:ddaa59d48aca 244 pc.printf("We will start the demonstration\r\n");
daniQQue 49:818a0e90ed9c 245 pc.printf("\r\n\r\n\r\n");
daniQQue 49:818a0e90ed9c 246
daniQQue 47:ddaa59d48aca 247 if (switch_signal%2==0)
daniQQue 47:ddaa59d48aca 248 {pc.printf("If you contract the biceps, the robot will go right \r\n");
daniQQue 47:ddaa59d48aca 249 pc.printf("If you contract the triceps, the robot will go left \r\n");
daniQQue 47:ddaa59d48aca 250 pc.printf("\r\n");
daniQQue 47:ddaa59d48aca 251 }
daniQQue 47:ddaa59d48aca 252
daniQQue 47:ddaa59d48aca 253
daniQQue 47:ddaa59d48aca 254 else
daniQQue 45:08bddea67bd8 255 {pc.printf("If you contract the biceps, the robot will go up \r\n");
daniQQue 45:08bddea67bd8 256 pc.printf("If you contract the triceps, the robot will go down \r\n");
daniQQue 47:ddaa59d48aca 257 pc.printf("\r\n");
daniQQue 45:08bddea67bd8 258 }
daniQQue 45:08bddea67bd8 259
daniQQue 44:c79e5944ac91 260 //==============================================================================================
daniQQue 0:34c739fcc3e0 261 //endless loop
daniQQue 0:34c739fcc3e0 262
daniQQue 40:187ef29de53d 263
daniQQue 49:818a0e90ed9c 264 while (true) { // neverending loop
daniQQue 8:cd0cb71b69f2 265
daniQQue 45:08bddea67bd8 266 if (onoffsignal_biceps==-1) //left biceps contracted
daniQQue 40:187ef29de53d 267 {
daniQQue 49:818a0e90ed9c 268 if (switch_signal%2==0) //switch even
daniQQue 40:187ef29de53d 269 {
daniQQue 49:818a0e90ed9c 270 richting_motor1 = ccw; //motor 1, left
daniQQue 49:818a0e90ed9c 271 pwm_motor1 = speedmotor1; //speed of motor 1
daniQQue 40:187ef29de53d 272
daniQQue 40:187ef29de53d 273 }
daniQQue 40:187ef29de53d 274
daniQQue 49:818a0e90ed9c 275 else //switch odd
daniQQue 40:187ef29de53d 276 {
daniQQue 49:818a0e90ed9c 277 richting_motor2 = ccw; //motor 2, up
daniQQue 49:818a0e90ed9c 278 pwm_motor2 = speedmotor2;//speed of motor 2
daniQQue 40:187ef29de53d 279
daniQQue 40:187ef29de53d 280 }
daniQQue 40:187ef29de53d 281
daniQQue 8:cd0cb71b69f2 282 }
daniQQue 49:818a0e90ed9c 283 else if (onoffsignal_biceps==1) //right biceps contracted
daniQQue 40:187ef29de53d 284 {
daniQQue 49:818a0e90ed9c 285 if (switch_signal%2==0) //switch signal even
daniQQue 40:187ef29de53d 286 {
daniQQue 49:818a0e90ed9c 287 richting_motor1 = cw; //motor 1, right
daniQQue 49:818a0e90ed9c 288 pwm_motor1 = speedmotor1; //speed motor 1
daniQQue 40:187ef29de53d 289
daniQQue 40:187ef29de53d 290 }
daniQQue 49:818a0e90ed9c 291 else //switch signal odd
daniQQue 40:187ef29de53d 292 {
daniQQue 49:818a0e90ed9c 293 richting_motor2 = cw; //motor 2. down
daniQQue 49:818a0e90ed9c 294 pwm_motor2 = speedmotor2; //speed motor 2
daniQQue 40:187ef29de53d 295
daniQQue 40:187ef29de53d 296 }
daniQQue 40:187ef29de53d 297 }
daniQQue 49:818a0e90ed9c 298 else{
daniQQue 49:818a0e90ed9c 299 //no contraction of biceps
daniQQue 40:187ef29de53d 300 pwm_motor2=0;
daniQQue 40:187ef29de53d 301 pwm_motor1=0;
daniQQue 40:187ef29de53d 302 }
daniQQue 40:187ef29de53d 303
daniQQue 49:818a0e90ed9c 304 }//while true closed
daniQQue 0:34c739fcc3e0 305
daniQQue 49:818a0e90ed9c 306 } //int main closed
daniQQue 49:818a0e90ed9c 307
daniQQue 49:818a0e90ed9c 308 //=============================================================================================1