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:
- 14:599896acf576
- Parent:
- 13:bcf8ec7120ab
- Child:
- 15:f029351f1f3a
--- a/main.cpp Wed Oct 07 13:51:17 2015 +0000 +++ b/main.cpp Wed Oct 07 21:21:24 2015 +0000 @@ -7,6 +7,12 @@ MODSERIAL pc(USBTX,USBRX); +//HIDScope scope(2); // HIDSCOPE declared + +//Ticker Sample_Ticker; // HIDSCOPE voor main +//volatile bool get_sample; // HIDSCOPE voor main + + // (DEBUGGING AND TESTING BUTTONS) (0 when pressed and 1 when not pressed) DigitalIn buttonL1(PTC6); // Button 1 (laag op board) for testing at the lower board DigitalIn buttonL2(PTA4); // Button 2 (laag op board) for testing at the lower board @@ -21,6 +27,7 @@ // stel setpoint tussen (0 en 360) en position tussen (0 en 360) // max verschil: 360 -> dan pwm_to_motor 1 tot aan een verschil van 15 graden-> bij 15 moet pwm_to_motor ong 0.1 zijn // dus 0.1=15*gain gain=0.0067 + // Als 3 graden verschil 0.1 dan 0.1/3=gain=0.33 double Gain_I_turn=0.025; //(1/2000) //0.00000134 // pwm_motor_I=(integrate_error_turn + sample_time*error)*gain; pwm = (4*0.01 + 4)* Gain => 0.1 pwm gewenst (na 1 seconde een verschil van 4 graden) @@ -28,7 +35,7 @@ double Gain_D_turn=1; // error_derivative_turn=(error - previous_error_turn)/sample_time - // + // double conversion_counts_to_degrees=0.085877862594198; // gear ratio motor = 131 @@ -47,6 +54,7 @@ void keep_in_range(double * in, double min, double max); void setlooptimerflag(void); double get_reference(double input); +// void get_sample(); //HIDSCOPE // MAIN function @@ -72,6 +80,8 @@ 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 + pc.printf("Start infinite loop \n\r"); wait (3); // Rest before starting system @@ -162,6 +172,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,u); // HIDSCOPE channel 0 : +// scope.set(1,y); // HIDSCOPE channel 1 : +// scope.send(); // Send channel info to HIDSCOPE +// sample_go = 0; +// } } } } @@ -185,3 +204,9 @@ const float gain = 4.0; return (input-offset)*gain; } + +//// Get sample +//void get_sample() // HIDSCOPE sample fuction +//{ +// get_sample = 1; +//} \ No newline at end of file