most functionality to splashdwon, find neutral and start mission. short timeouts still in code for testing, will adjust to go directly to sit_idle after splashdown
Dependencies: mbed MODSERIAL FATFileSystem
Diff: main.cpp
- Revision:
- 67:c86a4b464682
- Parent:
- 66:0f20870117b7
- Child:
- 68:8f549749b8ce
--- a/main.cpp Tue Jun 19 20:14:23 2018 +0000 +++ b/main.cpp Mon Jun 25 15:44:00 2018 +0000 @@ -34,12 +34,19 @@ - added timing code for interrupt that drives the rudder (testing with o-scope) - PID controller replaced with newer version from 5/29 code branch - StateMachine hanged style of variables to match convention in code - Modified FSG PCB V_1_4 - - adcLed = 0; in adc - + - adc tests Modified FSG PCB V_1_5 - IMU update + - Testing print outs + Modified FSG PCB V_1_6 + - new BMM zero count of 240 (confirmed manually) + - new BCE zero count of 400 (confirmed manually) + - Modified emergency climb to go to position 10 on the BMM, not zero (almost relying on the limit switch) + - fixed keyboard input; including typing in the timeout (can enter exact times) + Modified FSG PCB V_1_7 + - removed data logger references + */ /* removed unused variables */ @@ -124,6 +131,9 @@ else { //this can only happen once if (file_opened) { + //WRITE ONCE + mbedLogger().appendLogFile(current_state, 1); //write the idle state, then close + mbedLogger().appendLogFile(current_state, 0); //close log file //sdLogger().appendLogFile(current_state, 0); //close log file @@ -159,7 +169,7 @@ } if ( (timer_counter % 50) == 0 ) { // 0.05 second intervals - //imu().runIMU(); + imu().runIMU(); } if ( (timer_counter % 100) == 0) { // 100,000 microseconds = 0.1 second intervals @@ -185,7 +195,7 @@ // set up and start the adc. This runs on a fixed interval and is interrupt driven adc().initialize(); - //adc().start(); + //one central interrupt is updating the ADC (not using the start function) // setup and run the rudder(servo) pwm signal (start the ticker) //rudder().init(); @@ -195,10 +205,6 @@ imu().initialize(); //imu().start(); - // set up the depth sensor. This is an internal ADC read, but eventually will be on the ltc1298 - depth().init(); - depth().tare(); - // construct the MBED local file system local(); @@ -219,6 +225,7 @@ bce().setPIDHighLimit(bce().getTravelLimit()); //travel limit of this linear actuator bce().init(); //bce().start(); //removed start, it's handled by the interrupt + bce().runLinearActuator(); bce().pause(); // start by not moving batt().setPIDHighLimit(batt().getTravelLimit()); //travel limit of this linear actuator @@ -268,6 +275,12 @@ //sdLogger().initializeLogFile(); setup_complete = true; + + // set up the depth sensor. This is an internal ADC read, but eventually will be on the ltc1298 + wait(0.1); //giving this time to work + depth().init(); + wait(0.1); //giving this time to work + depth().tare(); //this did not work correctly before the ADC starts } int main() { @@ -276,7 +289,7 @@ unsigned int tNow = 0; pc().baud(57600); - pc().printf("\n\n\r TICKER TEST 05/25/2018 running at 10 kHz (0.0001 second interval) \n\n\r"); + pc().printf("\n\n\r FSG PCB v1.6 (XBee) 6/22/2018 \n\n\r"); systemTicker.attach_us(&system_timer, 1000); // Interrupt timer running at 0.001 seconds (slower than original ADC time interval) @@ -291,12 +304,9 @@ fsm_loop = true; FSM(); } - if ( (tNow % 1000) == 0 ) { // 1.0 second intervals - log_loop = true; - log_function(); - } } + //NOT TRANSMITTING DATA, NORMAL OPERATIONS else { if ( (tNow % 100) == 0 ) { // 0.1 second intervals (10 Hz) fsm_loop = true; @@ -306,6 +316,8 @@ if ( (tNow % 1000) == 0 ) { // 1.0 second intervals log_loop = true; log_function(); + + led1() = !led1(); } } }