' Count geiger ticks, convert to microrems/hour, display the ' current, average and maximum readings on a one-line LCD ' display and send the data through a serial port. This ' project is low power and can run continuously for up to ' two months on a nine volt battery. ' Requires circuit with CD4040 and 74C157 ICs and ' Vellemen Geiger/Muller counter kit #K2645 and ' Radio Shack LCD panel meter Cat #910-4913. ' Note: The maximum that can be displayed is 2560 urems/hr ' with an effective resolution of 6.6 urems/hr. ' The conversion formula was taken from the response ' table included with the Vellemen kit. It is: ' microrems/hour = ticks per minute*100/15. ' The readings are updated once per minute. ' This program uses every variable and every location of ' a Basic Stamp rev D. Symbol E = 5 ' Enable pin, 1 = enabled Symbol RS = 4 ' Register select pin, 0 = instruction Symbol AB = 6 Symbol clr = 7 Symbol mxa = w0 ' For maximum reading Symbol char = b2 ' Char to send to LCD Symbol txt = b3 ' Select Text from eeprom statement Symbol temb = b4 ' Temporary working byte variable Symbol mint = b5 ' Counts the number of minutes for averaging Symbol tens = b6 ' Temporary holding byte for extracting digits Symbol ones = b7 ' Ditto Symbol mast = w4 ' Contains urems/hr to be displayed Symbol accm = w5 ' Accumulates counts for averaging Symbol nsub = w6 ' Only useable as temporary register outside ' of a subroutine. ' Set up the Stamp's I/O lines and initialize the LCD. eeprom 0,(228,"rems/hr Avg Max ") begin: let dirs = %11111111 let pins = %00000011 'Set to 8-bit operation. pulsout E,1 'Send data three times pulsout E,1 'to initialize LCD pulsout E,1 let pins = %00000010 'Set to 4-bit operation. pulsout E,1 'Send above data three times. pulsout E,1 let pins = %00001000 pulsout E,1 let char = 12 'Set up LCD in accordance with gosub wr_LCD 'Hitachi instruction manual. loop: let dirs = %11100000 'Set up I/O directions. low ab let nsub = pins & %00001111 'Take low and high nibble high ab 'readings from the 74C157 let nsub = pins & %00011111 * 16 + nsub pulsout clr,2 'Clear CD4040 let mast = nsub * 100 / 15 'Convert to microREMs per hour let accm = accm + mast 'Keep track of Average let mint = mint + 1 'Increment minutes if mint > 0 then skio 'Clear if wrapped around accm = 0 skio: if mast < mxa then skip 'Keep track of Maximum let mxa = mast skip: let dirs= %11111111 let txt = 0 gosub wr_mt 'Display last reading sleep 40 'in urems/hr for 40 secs serout AB,N2400,(#mast,10,13) 'Send out through Serial Port let mast = accm / mint 'Average of all readings gosub wr_mt sleep 10 'Display Avg for 10 secs let mast = mxa gosub wr_mt sleep 10 'Display Max for 10 secs goto loop ' Write the ASCII character in char to the LCD. wr_CCD: let char = char + 48 'Call if converting # to ASCII wr_LCD: let pins = pins & %00010000 let temb = char / 16 'Put high nib of char into temb let pins = pins | temb 'OR the contents of char into pins pulsout E,1 'Blip enable pin let temb = char & %00001111 'Put low nib of char into temb let pins = pins & %00010000 'Clear 4-bit data bus let pins = pins | temb 'OR the contents of temb into pins pulsout E,1 'Blip enable pin return wr_mt: low RS 'Clear display let char = 1 gosub wr_LCD high RS 'Extract each digit let char = mast / 1000 'Extract 1000's gosub wr_CCD let temb = mast / 10 let ones = mast // 10 'Extract 1's let tens = temb // 10 'Extract 10's let temb = temb / 10 let char = temb // 10 'Extract 100's gosub wr_CCD let char = tens gosub wr_CCD 'Display digits let char = ones gosub wr_CCD let char = 32 for ones = 0 to 35 'Position to other half of LCD gosub wr_LCD next ones clop: read txt, char 'Write text from eeprom gosub wr_LCD let txt = txt + 1 if char > 32 then clop 'Use a space as delimiter return