' Solar fountain program ' ' (C) 3/07 A. Stein, MedCosm, LLC ' ' Info: ' For MedCosm Solar Fountain circuit v1 ' ' Solar fountain sprays nice stream from side of pool, aware of battery charge level, user switch. ' ' Modes: ' Water modes: ' - short subsecond pulses, full power ' - short subsecond pulses of increasing duration ' - continuous stream ' - 10 seconds of random pulses ' ' Battery sensitive modes: ' - 10 cell (12v) NiCD should charge to 13.8v, abs max 14.5v, rest at 13.4, when used, will remain flat at above 12v. ' May discharge to 10v, then repeat cycle starting with charge to 13.8v ' Note the "memory effect" attributed to NiCD is just a myth! ' ' - Lead-Acid should charge to 13.8, rest at 13.4, don't deep discharge for extended battery life. ' Keep above 12v ' ' BATSNS adc values correspond to battery voltage as follows: ' from recording voltage and ADC values ' 'ADC Val(v) Voltage 'X Y calculated '160 10.97 10.85857355 '179 12 12.18165676 '180 12.1 12.25129272 '185 12.68 12.59947251 '187 12.8 12.73874443 '189 12.87 12.87801634 '193 13.2 13.15656018 '196 13.38 13.36546805 '200 13.72 13.64401189 '202 13.75 13.7832838 '203 13.84 13.85291976 ' 'Curve fitting 'M B '0.069635958 -0.283179792 ' 'using linear regression, the following are extrapolated values '150 10.16 '165 11.20 '170 11.55 ' ' ' 'Note that pumping disables below a certain voltage threshold to ensure that batteries remain mostly charged ' ' Switch modes: ' - Turn fountain on at preset duty cycle for a preset period ' - Turn fountain off entirely ' ' ' LED indicator: ' - Flash every few sec - normal automatic mode ' - Off - no power, problem ' - Continuously on - error ' ' Version History: ' ' v1 - Initial version just flashed LED, reads battery voltage, and turns PUMP on/off ' v2 - different modes available ' v3 - doesn't use PWM since electrical noise kept resetting picaxe, only HIGH/LOW ' v4 - eliminated duty cycle concept, now runs badded absolute min/max settings ' v5 - LED indicates charge level ' ' ' 08M variable table (for convenience) ' b0:b1 b2:b3 b4:b5 b6:b7 b8:b9 b10:b11 b12:b13 ' w0 w1 w2 w3 w4 w5 w6 'pinouts symbol LED=0 'LED pinout symbol BTN=pin3 'UI control symbol BATSNS=4 'battery voltage sensor (voltage divider), approx ADC=Vs*255/(5*3), so Vs=ADC*15/255 symbol PUMP=2 'fountain pump symbol EXTRAIN=1 'vars symbol tmpW1=w0 'tmp word variables (overlap with byte vars) symbol tmpB1=b0 'tmp byte variables symbol tmpB2=b1 symbol tmpW2=w1 symbol tmpB3=b2 symbol tmpB4=b3 symbol tmpW3=w2 symbol tmpB5=b4 symbol tmpB6=b5 'symbol pumpVal=b6 'pump strength 'symbol pumpDuty=b7 'pump duty cycle (100=max, 0=off) symbol rndW=w4 symbol rndB1=b8 symbol rndB2=b9 symbol batV=b10 symbol counter=b11 'cycle counter keeps track of mode, 0 if off, or set by manual, autopump, or overvolt modes symbol pumpOnLen=w6 'duration (ms) when pump on full 'constants symbol showLen=10 'duration of each short show (sec) symbol spurtLen=1000 'duration of each spurt (ms) symbol voltMin=150 'min ADC val, below this pump won't operate, allows NiCD to stay charged symbol voltAuto=200 'at this level, pump cycles symbol voltMax=203 'at this level, pump runs continuously symbol autoPumpCnt=1 'number of cycles for autopumping mode symbol switchPumpCnt=3 'number of cycles to count after switch pressed (manual run mode) symbol overPumpCnt=switchPumpCnt+2 'number of cycles when overvoltage (runs battery down a bit) symbol defaultRest=5 'default rest period symbol overRest=1 'rest when overvoltage symbol briefpause=750 'brief pause to let water stop during pump routines symbol flashOnDly=75 'delay between LED flashes symbol flashOffDly=175 'delay between LED flashes symbol chargeMid=185 'approx 12v symbol chargeHi=198 'approx 13.4 'initialization routines init: input BTN input BATSNS input EXTRAIN output LED output PUMP low PUMP rndW=12345 'give rnd a little help pause 2000 'main execution starts here start: readadc BATSNS, batV 'read bat voltage and act appropriately serTxD("B=",#batV, " C=", #counter, 13, 10) ;show charge level by flahsing LED gosub flashLED if batV>chargeMid then gosub flashLED if batV>chargeHi then gosub flashLED 'set action based on battery voltage if batV