At 11:48 PM 5/04/97 +0100, you 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 John, This sounds like a noise problem which may also be unpredictable in many cases. I had similar problems with switching motors and relays and this was only at 12 volts!! I found a lot of problems disappeared when I delayed performing any instructions after switching a motor or relay. I also put non-polarised capacitors from both terminals of the motors to ground. Screened cables were used throughout. When I look back in hindsight a lot of problems were due to not enough care being taken with isolating the motors (power) from the microprocessor side. I was given a lot of useful suggestions from this mailing list. Another suggestion I remember is to optically isolate the motors and their drive. Putting the drive signals through ferrite cores can also help as can a liberal sprinkling of 0.1uF caps. If after having done as much isolation as you can and the noise still persists you may care to implement the delays as mentioned above. Try delays initially of 0.5 secs and then reduce them as necessary. Another thing to try is back to back schottky diodes on all I/O lines as well as a diode in line with the signal. Again, more bypass caps may also assist. I hope this may provide some help and things to try. Best of luck, Peter Grey Neosystems Australia