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: Encoder HIDScope MODSERIAL QEI biquadFilter mbed
Diff: main.cpp
- Revision:
- 21:c75210216204
- Parent:
- 20:bdc62ee49197
- Child:
- 22:eaf4cbd1dcec
--- a/main.cpp Thu Oct 08 12:14:00 2015 +0000 +++ b/main.cpp Thu Oct 08 12:30:00 2015 +0000 @@ -1,5 +1,5 @@ #include "mbed.h" -//#include "HIDScope.h" +#include "HIDScope.h" #include "QEI.h" #include "MODSERIAL.h" #include "biquadFilter.h" @@ -8,10 +8,10 @@ MODSERIAL pc(USBTX,USBRX); DigitalOut debug_led(LED_RED); // Debug LED -//HIDScope scope(2); // HIDSCOPE declared +HIDScope scope(2); // HIDSCOPE declared -//Ticker Sample_Ticker; // HIDSCOPE voor main -//volatile bool get_sample; // HIDSCOPE voor main +Ticker Sample_Ticker; // HIDSCOPE voor main +volatile bool sample; // HIDSCOPE voor main // (DEBUGGING AND TESTING BUTTONS) (0 when pressed and 1 when not pressed) @@ -57,7 +57,7 @@ void keep_in_range(double * in, double min, double max); void setlooptimerflag(void); double get_reference(double input); -// void get_sample(); //HIDSCOPE +void get_sample(void); //HIDSCOPE // MAIN function @@ -83,7 +83,7 @@ Ticker looptimer; // Ticker called looptimer to set a looptimerflag looptimer.attach(setlooptimerflag,sample_time); // calls the looptimer flag every 0.01s - // Sample_Ticker.attach(&get_sample, (float)1/Fs); HIDSCOPE sample Ticker + Sample_Ticker.attach(&get_sample, sample_time); // HIDSCOPE sample Ticker pc.printf("Start infinite loop \n\r"); wait (3); // Wait before starting system @@ -185,15 +185,15 @@ // Put pwm_motor to the motor pwm_motor_turn=(abs(pwm_to_motor_turn)); -// if(sample_go) // HIDSCOPE input => sample_go nu nog niet nodig opzich // BLINK LEDS TOEVOEGEN -// { -// //sample_filter; (filter function zie EMG filter working script) -// scope.set(0,reference_turn); // HIDSCOPE channel 0 : Current Reference -// scope.set(0,position_turn); // HIDSCOPE channel 0 : Position_turn -// scope.set(1,pwm_to_motor_turn); // HIDSCOPE channel 1 : Pwm_to_motor_turn -// scope.send(); // Send channel info to HIDSCOPE -// sample_go = 0; -// } + while(sample != true) // HIDSCOPE input => sample_go nu nog niet nodig opzich // BLINK LEDS TOEVOEGEN + { + //sample_filter; (filter function zie EMG filter working script) + scope.set(0,reference_turn); // HIDSCOPE channel 0 : Current Reference + scope.set(0,position_turn); // HIDSCOPE channel 0 : Position_turn + scope.set(1,pwm_to_motor_turn); // HIDSCOPE channel 1 : Pwm_to_motor_turn + scope.send(); // Send channel info to HIDSCOPE + sample = false; + } debug_led = !debug_led; // should flicker with freq 50 Hz } } @@ -219,8 +219,8 @@ return (input-offset)*gain; } -//// Get sample -//void get_sample() // HIDSCOPE sample fuction -//{ -// get_sample = 1; -//} +// Get sample +void get_sample(void) // HIDSCOPE sample fuction +{ + sample = true; +}