Sawtooth program

Dependencies:   mbed

Fork of shomberg_hw_3 by Russell Shomberg

Revision:
2:312a0a9c4485
Parent:
1:cbee04784c60
Child:
3:56972a65cd0a
--- a/main.cpp	Tue Sep 25 14:59:23 2018 +0000
+++ b/main.cpp	Tue Sep 25 15:42:54 2018 +0000
@@ -9,7 +9,8 @@
     @author Russell Shomberg
     @version 1.0 2018-09-25
     
-    Issues: NTR
+    Issues: 
+        Frequency and amplitude only change at the start of the waveform by design
             
 
 */
@@ -18,27 +19,28 @@
 #include "mbed.h"
 
 // INPUTS
-DigitalIn switchPosition(p7);
-AnalogIn Ain(p20); // wire p20 to a variable resister connected from Vref and GND
+DigitalIn switchPosition(p7);   // wire p7 to middle connection of 2 position switch between Vref and GND
+AnalogIn Ain(p20);              // wire p20 to a variable resister connected from Vref and GND
 
 // OUTPUTS
-Serial pc(USBTX, USBRX);
-AnalogOut Aout(p18);
+Serial pc(USBTX, USBRX);        // for debugging
+AnalogOut Aout(p18);            // leave open lead on p18 for signal output
 
 // VARIABLES
-float period;
-float amplitude;
-float i;
+float period;       // range between ~0 and 1 (seconds)
+float amplitude;    // switch between 1 and -.5
+float i;            // index
 
 int main() {
     while(1) {
         
-        // Check any settings which are changed with 
+        // Check settings at start of loop which are changed with 
         if (switchPosition==1) {amplitude = 1;}
         else {amplitude = 0.5;}
         
         period = Ain;
         
+        // Debugging code
         //printf("Amplitude = %1.2f Volts\n\r", amplitude * 3.3f);
         //printf("Period = %1.2f seconds\n\r", period);