Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: HIDScope QEI biquadFilter mbed
Fork of EMG_Controller_5 by
Diff: main.cpp
- Revision:
- 17:80316a7a917a
- Parent:
- 16:58b0df053d45
- Child:
- 18:7178416f2db5
--- a/main.cpp Fri Oct 28 12:54:35 2016 +0000 +++ b/main.cpp Mon Oct 31 12:39:41 2016 +0000 @@ -20,7 +20,7 @@ BiQuad bq1(0.06463239794, 0.12926479589, 0.06463239794,-1.16338171052, 0.42191097989); BiQuad bq2(0.07902502847, 0.15805005694, 0.07902502847,-1.42439823874, 0.7409311811); -//Serial pc(USBTX,USBRX); +Serial pc(USBTX,USBRX); Ticker Controller; bool Controller_Flag=0; @@ -73,20 +73,21 @@ Timeout Lift_Timeout; bool Lift_Timeout_Switch = true; +// state machine variables float statechange_threshold = 0.6; bool binary_norm_emg_2 = 0; bool binary_norm_emg_2_previous = 0; -states scoopstate = STATE_MOVE; +states scoopstate = STATE_MOVE; // all states are defined in one place in emg.h bool state_resettime_value = 1; Timeout state_resettime; DigitalOut LED_STATE_MOVE(D15); DigitalOut LED_STATE_GRAB(D14); Timeout controlstarterTimeout; +//callable functions void Slide_Controller(); void Lift_Controller(); void Ticker_Flag(); - void set2true(); void change_scoopstate(); void start_controlling(); @@ -102,6 +103,7 @@ Lift_Input_force = Potmeter.read(); Slide_Input_force = Potmeter2.read(); + // define the filters used in main notch_50_0.add( &bq03 ).add( &bq04 ).add( &bq05 ); notch_50_1.add( &bq13 ).add( &bq14 ).add( &bq15 ); notch_50_2.add( &bq23 ).add( &bq24 ).add( &bq25 ); @@ -112,11 +114,11 @@ low_pass_1.add( &bq19 ).add( &bq110 ).add( &bq111 ); low_pass_2.add( &bq29 ).add( &bq210 ).add( &bq211 ); + //call the timeouts for the startup states and the tickers for reading the emgs change_state.attach( &calibrate,1); change_state2.attach( &run,11); controlstarterTimeout.attach(&start_controlling,11); emgSampleTicker.attach( &emgSample, 0.005); //200Hz - ServoPWMpin.period(0.01f); // 0.01 second period while (true) {