I've been away from programming for a while now and need a little help if you will. I have a 40 watt CO2 laser cutter/engraver that requires water flow to keep the tube cool, the flow is provided by a small "waterfall" pump. If the flow were to stop the tube will be destroyed so I'm installing a flow sensor to monitor the flow. If the flow drops too low or stops, I will have the PIC activate a relay to instantly shut off power to the tube.
The flow sensor I'm using has a turbine with a magnet and a hall sensor on the outside, this of course produces pulses which vary with flow rate. I can program the PIC (12F675) with a COUNT value that will work but I would like to be able to adjust that value with a pot for future uses and I'd just really like to learn how to do this.
I'm using PBP, not sure which version, my manual is copyright 2003 which is when I purchased it.
I have the COUNT working fine and Im using ADCIN to read the pot, (also used it for reading a thermistor I may want to add to monitor temp of the water too). I'll post both codes below, again, I'd like to know how to make them work together using the pot to adjust the "pulse" value in COUNT if anyone can get me on the right track.
Thanks !
COUNT
When flow is good, Green LED is lit, when no flow or too little flow, Red flashes routine. I'll add a relay to another pin.Code:@ DEVICE pic12F675, INTRC_OSC_NOCLKOUT @ DEVICE pic12F675, WDT_ON @ DEVICE pic12F675, PWRT_ON @ DEVICE pic12F675, MCLR_OFF @ DEVICE pic12F675, BOD_ON c var byte pulse var word Green var GPIO.2 Red Var GPIO.0 low Red Low Green flow: count GPIO.1, 500, pulse if pulse > 120 then high Green goto flow else gosub alert endif pause 100 goto flow alert: for c = 1 to 4 low Green high Red pause 100 low Red pause 500 next
ADCIN
I did the four LEDs just to see it work.Code:CMCON=�000111 ANSEL=�000000 @ DEVICE pic12F675, INTRC_OSC_NOCLKOUT @ DEVICE pic12F675, WDT_ON @ DEVICE pic12F675, PWRT_ON @ DEVICE pic12F675, MCLR_OFF @ DEVICE pic12F675, BOD_ON define ADC_BITS 8 define ADC_CLOCK 3 rdpot var word Green var GPIO.2 Red Var GPIO.0 Blue var GPIO.4 Yellow var GPIO.5 low Red Low Green flow: adcin 1,rdpot if rdpot > 20 then high Green else low Green endif if rdpot > 80 then High Red else Low Red endif if rdpot > 110 then high Blue else low Blue endif if rdpot < 20 then high Yellow else low Yellow endif goto flow





Bookmarks