update with altimeter, swimfile.txt endleg.txt, etc see changes_13sep.txt also reset_PI()
Dependencies: mbed MODSERIAL FATFileSystem
Diff: main.cpp
- Revision:
- 56:48a8a5a65b82
- Parent:
- 55:f4ec445c42fe
- Child:
- 57:ec69651c8c21
--- a/main.cpp Tue Jun 12 15:41:51 2018 +0000 +++ b/main.cpp Tue Jun 12 16:20:03 2018 +0000 @@ -30,6 +30,10 @@ - Motor direction was opposite the BCE motor (because of gearing) - BMM P gain is now positive 0.02 (from -0.10) + Modified FSG PCB V2.5 + - added timing code for interrupt that drives the rudder (testing with o-scope) + - + */ #include "mbed.h" @@ -45,6 +49,26 @@ void loop_trigger() { loop = true;} // loop trigger (used in while loop) void log_loop_trigger() { log_loop = true;} // log loop trigger (used in while loop) +/****************** for rudder servo ******************/ +Ticker systemTicker; + +volatile unsigned int timer_counter = 0; + +bool setup_complete = false; + +static void system_timer(void) { + timer_counter++; + + //only start these updates when everything is properly setup (through setup function) + if (setup_complete) { + if ( (timer_counter % 20) == 0 ) { // 0.02 second intervals + rudder().runServo(); + } + } +} + +/****************** for rudder servo ******************/ + void setup() { pc().baud(57600); pc().printf("\n\n\rFSG PCB V1.5 2018-06-06 \n\n\r"); @@ -129,10 +153,16 @@ mbedLogger().initializeLogFile(); // sdLogger().initializeLogFile(); + setup_complete = true; //used for interrupt timing + } int main() { setup(); + + //this is used to control timing on the rudder servo, it's based on the new timing model in the 5/29/18 code with one interrupt running everything...may or may not work here + + systemTicker.attach_us(&system_timer, 1000); // Interrupt timer running at 0.001 seconds (slower than original ADC time interval) while(1) { static int current_state = 0;