All,
I am having problems with the below code when the subroutine warning is executed. PortA.0 is pulled high with a 1k. When the bin is full the limit switch pulls PortA.0 low. The buzzer and light will blink 2 times then the PIC will reset. I have used 2 different PIC's. - F84A and F819. Both PIC's do the same thing. 5V is solid and I have plenty of decoupling and bulk capacitance sprinkled throught the circuit. For the warning lamp and buzzer driver I use 1k to the base of a 2N4401 transistor's to drive the light and buzzer. I tried Tris statements and ADCON setup with the F819 with no help. I have tried HC and XT osc drive settings. Both parts are rated for 20MHz operation. I set power up timer to off and brownout off. All I want is the buzzer and light wo toggle 5 times then if the switch is still low at PORTA.0 then just have the binlight on until PORTA.0 hoes high. I'm about to smash this with a hammer soon as something this simple should not cause this much trouble.
Any help here is appreciated.
Code:'**************************************************************** '* Name : Combine.BAS * '* Author : [select VIEW...EDITOR OPTIONS] * '* Notice : Copyright (c) 2009 [select VIEW...EDITOR OPTIONS] * '* : All Rights Reserved * '* Date : 8/15/09 * '* Version : 1.0 * '* Notes : * '* : * '**************************************************************** define OSC 20 'ADCON0 = %11000001 'ADCON1 = %10001110 'trisa = %00001110 'trisb = %11110111 binlight var porta.1 buzzer var portb.2 backup var porta.2 alarm var byte define LCD_DREG PORTB DEFINE LCD_DBIT 4 DEFINE LCD_RSREG PORTB DEFINE LCD_RSBIT 1 DEFINE LCD_EREG PORTB DEFINE LCD_EBIT 0 DEFINE LCD_BITS 4 DEFINE LCD_LINES 2 DEFINE LCD_COMMANDUS 2000 DEFINE LCD_DATAUS 50 low buzzer low binlight low backup PAUSE 500 alarm = 0 high buzzer high binlight high backup pause 500 toggle buzzer toggle binlight toggle backup LCDOUT $FE,1 LCDOUT $FE,$80, "TattleTale X" LCDOUT $FE,$C0, " Monitor" pause 5000 LCDOUT $FE,1 monitor: LCDOUT $FE,$80, " No Alarms" LCDOUT $FE,$C0, " " if alarm = 1 then goto light endif if PORTA.0 = 0 thEN alarm = 1 GOsub warning ELSE GOto monitor endif warning: LCDOUT $FE,1 LCDOUT $FE,$80, " BIN FULL!!!" LCDOUT $FE,$C0, " " high binlight high buzzer pause 200 toggle binlight toggle buzzer pause 200 toggle binlight toggle buzzer pause 200 toggle binlight toggle buzzer 'pause 200 'high binlight 'high buzzer 'pause 200 'low buzzer 'low binlight RETURN light: if PORTA.0 = 0 then high binlight else alarm = 0 GOTO monitor endif






Bookmarks