At 23:48 05/04/97 +0100, John Waterman wrote: >I am a newcomer to PICs and have been having problems with my first >project. I am using a 16C84 with Port A as all inputs and Port B as all >outputs. Initially the PIC was just controlling LEDs, and although it >worked fine most of the time, occasionally an output would come on for no >apparent reason. The only interrupt I am using is the RTCC overflow one, >and I take the precaution of saving W and STATUS at the beginning of the >interrupt routine and restoring them at the end. > >I carried on with the project and connected the outputs to solid state >relays which in turn control contactors using 110volt a.c. coils. Whenever >the 110volts was turned on the problem became considerably worse. I then >discovered that by replacing a sequence such as > >BCF PORTB,0 >BSF PORTB,1 >with >MOVLW 2 >MOVWF PORTB >the problem decreased dramatically. > >I have a subroutine which redefines the TRISs and OPTION, and I call this >before virtually all I/O read or writes as recommended in the data sheet >for a noisy environment. I also discovered that by putting a delay of >around 50mS at the end of this subroutine the program then became virtually >trouble free. An occasional problem would occur at just one part of the >cycle, but this was 'side-stepped' by changing the sequence of events and >then everything appeared to be fine. > >I carried on further, and connected the outputs from the contactors to >415volt 3phase motors, and with these motors running under no load >conditions everything still appeared to be fine, although testing at this >stage was rather limited. When however the machine was put on load, >problems returned. Sometimes it will work fine but at other times it will >go wrong in an unpredictable manner. I have put varistors across the >110volt coils but with little or no effect. The PIC is inside a metal box >maybe around 10cms from the nearest contactor, and all the input cables are >screened - what more can I do? > >Please help or I think I may soon be looking for another job! > >John Waterman May seem trivial, but are you decoupling properly? In my experience, PICs can behave erratically if not closely decoupled. Note that decoupling capacitors should connect DIRECTLY to the power pins of the IC to be decoupled, NOT simply across a convenient point on PCB power rail tracks - otherwise transient behaviour can actually get worse! Due to PIC power pins being central, my usual preferred option of decoupled sockets can't be used. Don't go looking for another job - unlike the designers of too many products you are actually trying to achieve a solid fix for observed problems. In time, this attitude should bring benefits. Good luck. Tim Tim Forcer Tel: (+44) (0)1703 593362 Fax: (+44) (0)1703 592053 email: tmf@ecs.soton.ac.uk Department of Electronics & Computer Science Room 3005, Building 35 The University, Southampton, SO17 1BJ UK