Software to drive a monitor unit for a closed circuit rebreather using 3 electrogalvanic oxygen sensor cells run through an amplifier (lm324) . Uses a separate ds1307 clock IC to get timestamp values for logged data.

Dependencies:   DS1307 TextOLED_custom mbed

The main electornics is housed in another pod mounted on the back of the unit. I'm using an mbed lpc11u24 to drive everything which comes with a flash drive for data logging built in. It has an external ds1307 clock chip added and a very cheapo lm324 quad op-amp to amplify the o2 sensor signals from the 10s of mV range by 30x so that ppo2=0.21 corresponds to about 0.3V. I still have to do some ADC averaging with this amplifier and do have to calibrate out the individual offsets of the chip but this works ok now that I've worked out which amp is on which adc...

Revision:
9:cd3599adfff6
Parent:
8:f45e654b47d0
--- a/Rebmon_main.cpp	Mon Jan 14 12:55:05 2013 +0000
+++ b/Rebmon_main.cpp	Wed Jan 16 13:47:34 2013 +0000
@@ -232,12 +232,13 @@
     // average 20 readings for noise reduction
     g_lcd.cls();
     for (count=20; count>0; count--) {
-        g_lcd.locate(0,0);
-        g_lcd.printf("Calibrate 21%% %.2d",count);
         s1=s1+EG1;
         s2=s2+EG2;
         s3=s3+EG3;
         pres=pres+PRESin;
+        g_lcd.locate(0,0);
+        g_lcd.printf("CAL 21%% %.2d %1.2f",count,pres/(20-count+1));
+       
         g_lcd.locate(0,1);
         g_lcd.printf("%1.2f: %1.2f: %1.2f",s1/(20-count+1),s2/(20-count+1),s3/(20-count+1));
         wait(1);
@@ -765,12 +766,12 @@
             divetime=(seconds-startdive); // divetime no recorded in seconds since start of dive
 
             // do deco calcs here when implemented
-            if (divetime %15 ==0) store_log(); // this saves the dive profile and sensor optputs in a file called divelog.dat every 15s
+            if (divetime %15 ==0) store_log(); // this saves the dive profile data every 15s and sensor optputs in a file called divelog.dat
             if (depth<=0.5) {
                 endclock=endclock+1;
 
                 if (endclock>150) {
-                    state=1; // 30s at shallower than 0.3m and we return to surface mode. */
+                    state=1; // 30s at shallower than 0.5m and we return to surface mode. */
                     FILE *fp=fopen("/local/CAL.dat","w");
                     fprintf(fp,"%e\n%e\n%e\n%d",eg1cal,eg2cal,pcal,scrubtime);
                     fclose(fp); //NB file system locked on write so must make sure we close files in case want to reprogram etc...