![](/media/cache/profiles/f.jpg.50x50_q85.jpg)
Generates a test signal on an AnalogOut and monitors a signal on an AnalogIn, plotting the test signal or the actual signal depending on a conditional compile. The wait() and wait_ms() library calls for this board are highly inaccurate so a new function is provided to wait for X number of milliseconds -- which is not very accurate.
Dependencies: LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI mbed-os BSP_DISCO_F429ZI
Diff: LaserMon-TestOutput.cpp
- Revision:
- 1:b9d4b9b8884c
- Parent:
- 0:1ebe7d222470
- Child:
- 2:cbcf2695a4a1
--- a/LaserMon-TestOutput.cpp Mon Jun 10 17:10:01 2019 +0000 +++ b/LaserMon-TestOutput.cpp Fri Jun 14 21:11:31 2019 +0000 @@ -24,10 +24,10 @@ // // ---------------------------------------------------------------------- -#define PORCH_WIDTH 40 // In milliseconds -#define RAMP_WIDTH 216 // In milliseconds +#define PORCH_WIDTH 10 // In milliseconds +#define RAMP_WIDTH 250 // In milliseconds #define SCAN_LENGTH (PORCH_WIDTH + RAMP_WIDTH) // In milliseconds -#define STEP_HEIGHT 2.5f // In volts +#define STEP_HEIGHT 1.8f // In volts // ---------------------------------------------------------------------- // Local data storage @@ -36,10 +36,7 @@ // We create an analog output static AnalogOut st_testSignalOut(TEST_SIGNAL_OUT); - - // We will be creating a thread - static Thread st_testSignalOutThread; - + // For diagnostic purposes to show that the test output is working static DigitalOut st_testSignalLED(LED1); @@ -52,7 +49,7 @@ // incremental voltage should be so that when the ramp has // been completed, we end up at 3.3 volts, starting from the // initial step. - static const float f_stepIncrement = ((3.3f - STEP_HEIGHT) / (float)RAMP_WIDTH); + static const float f_stepIncrement = ((3.3f - STEP_HEIGHT) / ((float)RAMP_WIDTH - 10.0f)); // ---------------------------------------------------------------------- // Data that we will export globally @@ -65,10 +62,10 @@ float f_rampVoltage = 0.0f; // ---------------------------------------------------------------------- -// TestOutputDriveWaveformAT1Millisecond() +// TestOutputThread() // // ---------------------------------------------------------------------- -static void TestOutputDriveWaveformAT1Millisecond(void) +void TestOutputThread(void) { static uint8_t u8_ledTimeoutTimer = 0; @@ -86,13 +83,9 @@ // Are we stepping out the porch? if (true == b_onPorch) { - // Yes, are we just now starting on the porch? - if (PORCH_WIDTH == u16_countRemaining) - { - // Yes, so drive the voltage down to zero for porch - st_testSignalOut.write(0.0); - } - + // Drive the voltage down to zero for porch + st_testSignalOut.write(f_rampVoltage = 0.0f); + // Is the porch time remaining still have some time? if (u16_countRemaining > 0) { @@ -105,11 +98,8 @@ // Set the ramp duration u16_countRemaining = RAMP_WIDTH; - // Set the output voltage to the step height - f_rampVoltage = STEP_HEIGHT; - - // Set the initial step height - st_testSignalOut.write(f_rampVoltage / 3.3f); + // Set the next output voltage to the step height + f_rampVoltage = (STEP_HEIGHT - f_stepIncrement); } } } @@ -151,27 +141,6 @@ } // ---------------------------------------------------------------------- -// TestOutputThread() -// -// This thread sleeps for 1 millisecond and then calls the function -// that sends the wavefor out the analog output pin. -// -// ---------------------------------------------------------------------- -static void TestOutputThread(void) -{ - - while(true) - { - // Wait for 1 millisecond - accurate_wait_ms(1); - - // Call the routine which drives the wave form output - // one millisecond at a time. - TestOutputDriveWaveformAT1Millisecond(); - } -} - -// ---------------------------------------------------------------------- // TestOutputInit() // // This function initializes this module and then launches the thread @@ -182,9 +151,6 @@ // Initialize this module b_onPorch = true; u16_countRemaining = PORCH_WIDTH; - - // Start the test output thread - st_testSignalOutThread.start(TestOutputThread); } // End of file