//***************************************************************************** // File Name : datalogger.c // // Title : Windlogger // Revision : 0.2 22-10-2006 // Revision History: // When Who Description of change // ----------- ----------- ----------------------- // 20-Oct-2002 pstang Created the program // Oct - 2006 RifRaf changes stuff //***************************************************************************** //----- Include Files --------------------------------------------------------- #include // include I/O definitions (port names, pin names, etc) #include // include interrupt support #include "global.h" // include our global settings #include "uart.h" // include uart function library #include "rprintf.h" // include printf function library #include "timer.h" // include timer function library (timing, PWM, etc) #include "a2d.h" // include A/D converter function library #include "vt100.h" // include VT100 terminal support #include "lcd.h" // include Character LCD support #include "extint.h" // include external interrupt library #define SetBit(BIT, PORT) PORT |= (1< 620) { mode = 0; SwitchToLoad(); } if (volts < 580) { mode = 1; SwitchToCharging(); } vt100SetCursorPos(1,1); rprintfInit(uartSendByte); rprintf("[%d%d%d%d%d%d%d%d%d%d]\r\n",volts,shuntvolts,rpm,windpulse,mode,direction,recttemp,outtemp,insidetemp,barometer); //set maximums and minimums if (rpm > maxrpm) { maxrpm = rpm; } if (rpm <= minrpm) { minrpm = rpm; } if (windpulse > maxwindpulse) { maxwindpulse = windpulse; } if (windpulse <= minwindpulse) { minwindpulse = windpulse; } battvolts = volts/45.71*10; if (battvolts > maxvolts) { maxvolts = battvolts; } if (battvolts <= minvolts) { minvolts = battvolts; } windamp = shuntvolts*1.024*10; if (windamp > maxshuntvolts) { maxshuntvolts = windamp; } if (windamp <= minshuntvolts) { minshuntvolts = windamp; } solaramp = solarvolts*1.024*10; if (solaramp > maxsolarvolts) { maxsolarvolts = solaramp; } if (solaramp <= minsolarvolts) { minsolarvolts = solaramp; } outamp = outvolts*1.024*10; if (outamp > maxoutvolts) { maxoutvolts = outamp; } if (outamp <= minoutvolts) { minoutvolts = outamp; } recttempOut = recttemp*1.024*10; if (recttempOut > maxrecttemp) { maxrecttemp = recttempOut; } if (recttempOut <= minrecttemp) { minrecttemp = recttempOut; } outtempOut = outtemp*1.024*10; if (outtempOut > maxouttemp) { maxouttemp = outtempOut; } if (outtempOut <= minouttemp) { minouttemp = outtempOut; } insidetempOut = insidetemp*1.024*10; if (insidetempOut > maxinsidetemp) { maxinsidetemp = insidetempOut; } if (insidetempOut <= mininsidetemp) { mininsidetemp = insidetempOut; } barometerOut = barometer*1.024*10; if (barometerOut > maxbarometer) { maxbarometer = barometerOut; } if (barometerOut <= minbarometer) { minbarometer = barometerOut; } //Update LCD rprintfInit(lcdDataWrite); // direct printf output to LCD lcdGotoXY(0,0); //goto line 1 , pos 1 rprintf("V%d.%d A%d.%d S%d.%d O%d.%d",battvolts/10,battvolts%10,windamp/10,windamp%10); lcdGotoXY(1,0); //goto line 2 , pos 1 rprintf("V%d.%d A%d.%d S%d.%d O%d.%d",volts/10,volts%10,shuntvolts/10,shuntvolts%10); } } void checkDirection(void) { if (0) { } else if ( !(PINC & (1<