' ================================================================================ ' ' File........MAS Probe.BSP ' Purpose.....Interface with MAS Probe, collect and store data ' Author......SWRI, Chuck Ellis ' E-mail......charles.ellis@swri.org ' Re-started..6-14-07 :-P ' Version ' Updated ' ' {$STAMP BS2P} ' ' ================================================================================ ' -------------------------------------------------------------------------------- ' Program Description ' -------------------------------------------------------------------------------- ' Sequentially compares each pin of a MAS Probe for anodic or cathodic potential, ' amplifies it through a nanovolt amplifier, converts to a digital format and ' stores the results with a date/time stamp on a SD card through a Hitts Consulting ' data logger. ' -------------------------------------------------------------------------------- ' I/O Definitions ' -------------------------------------------------------------------------------- ' -------------------------------------------------------------------------------- ' Constants ' -------------------------------------------------------------------------------- SigStabl CON 500 'delay to allow signal to stabilize Interval CON 60000 '1 min. delay DS1307 CON %1101 << 4 'sets up comm for I2C bus T19K2 CON 188 pacing CON 30 ' * 100uSec between characters Inverted CON $4000 Baud CON T19K2 + Inverted ' Use fast serial mode 19.2K baud ' -------------------------------------------------------------------------------- ' Variables ' -------------------------------------------------------------------------------- MSTIntvl VAR Word 'number of minutes delay ProbeCtr VAR Nib 'relay # to be energized PinValue VAR Word 'output of A22 Counter VAR Word SaveReg VAR Byte ' SaveReg1 VAR Byte result VAR Byte ' error result from data logger ' -------------------------------------------------------------------------------- ' Initialization ' -------------------------------------------------------------------------------- 'MSTIntvl = 1 ' -------------------------------------------------------------------------------- ' Program Code ' -------------------------------------------------------------------------------- Pinvalue = $08 FOR Pinvalue = $08 TO $1F 'loop through RTC RAM addresses I2COUT 0, ds1307, PinValue, [$00] 'writes zero's to ADC RAM NEXT DEBUG "RTC RAM cleared", CR Main: Measure FOR ProbeCtr = $0 TO $9 DEBUG HEX ProbeCtr IF ProbeCtr > $9 THEN CycleEnd 'continues measurement until all done AUXIO HIGH ProbeCtr 'energize relay GOTO Stabilize GOTO Convert GOTO Upload GOTO Save ProbeCtr = ProbeCtr + 1 NEXT 'increments ProbeCtr and goes back to 'Main '--------------------------------------------------------------------------------- ' Subroutines '--------------------------------------------------------------------------------- Stabilize 'subroutine for signal stabilization PAUSE SigStabl 'wait .5 seconds DEBUG "getting signal", CR RETURN 'return to main program Convert 'enable conversion process DEBUG "Converting", CR MAINIO 'switch to auxioliary I/O pins LOW 2 'set low to tell ADC to convert SHIFTOUT 3, 4, LSBFIRST, [%0001] 'sends config to ADC RETURN Upload PAUSE 500 'extra time for ADC to work DEBUG "retrieving", CR SHIFTIN 5, 4, LSBFIRST, [pinvalue] 'brings in data from ADC HIGH 2 'conversion complete Save '*******NEEDS MATH CORRECTION FOR CORRECT RTC REGISTER******* '(probectr x 2)+8 SaveReg = Probectr * $2 + $8 'sets register in ADC RAM for data lowbyte SaveReg1 = SaveReg + 1 'sets register in ADC RAM for data highbyte I2COUT 0, ds1307, savereg, [pinvalue.LOWBYTE] 'saves data to ADC RAM I2COUT 0, ds1307, savereg1, [pinvalue.HIGHBYTE] 'saves data to ADC RAM DEBUG "saving data for pin", ProbeCtr, CR 'status report CycleEnd ProbeCtr = 0 'resets value of ProbeCtr 'FOR Counter = MSTIntvl 'last # is number of min. between cycles DEBUG "Wait One", CR PAUSE Interval 'waits for one minute 'NEXT Counter 'missing stuff GOTO Main