Electronics > Projects, Designs, and Technical Stuff

PIC 16F877A Port unstable

(1/3) > >>

mukulkhairatkar:
Guys,

I am fairly new to Hardware design and PIC programming currently working on PIC 16F877A. I have initialized PORTA and PORTB in input mode and PORTC and PORTE in output mode. Based on logic present the input port, I am setting logic on output port. In idle condition output ports remain zero. But sometimes it jumps to logic 1 and then back to zero. This behavior is pretty random and I am not able to understand the problem. Do you have any suggestion or possibilities I can try to stop this unwanted oscillation?

I am using simple while loop to run the operation and if/else statements to compare input port logic.

any help is appreciated...   Thanks in advance

MAK

alm:
I'm not that familiar with PIC, but I'll give some general suggestions. Are there pull-up/down resistors on the inputs (or did you enable the internal pull-ups)? Otherwise, noise might couple into the inputs, never let a CMOS input float. Did you decouple the power supply with a ceramic capacitor between power and ground close to each power pin? Did you connect all power and ground pins (not sure if the device you're using has multiple)?

scrat:
I think it is a simple but subtle matter (but maybe you've already checked it)...
It remembers to me when at school we were using CMOS logic ports and a BJT to drive a small lamp... It turned into something like a proximity sensor, since when someone got near the open input the lamp turned on. It was simply because of noise coupling with the open input of the CMOS port (and our body antenna effect).
MOS devices have high input impedance, so any small power signal can create a relatively high voltage at their gate.
If you tie your PIC inputs to GND or Vcc through a low value resistor (or a short) then you are sure to give your input a "0" or a "1", while if you live them floating you dont' know what their input voltage is.
Take also a look at your PIC's datasheet, there you can find the schematics of all I/O ports configurations (pull-ups or other).

mukulkhairatkar:
Thank you for your help.

Yes I do have all input pins active pulled up. I have only one ceramic capacitor across PIC 16F877A power pins. I did hook up oscilloscope on input pins to see any noise spike, but could't find any. Irrespective of that my output port tuns on and back to off for fraction of a second.

One thing for sure that this behavior is random, there is no specific pattern, which I believe is related to noise and not a software error. 

I do have LM311 voltage comparator on the board which is one of the input for PORTA (Digital input not analog), Do you have any idea about how to interface this input? I highly doubt on this interface.

Thanks

MAK

ArtemisGoldfish:

--- Quote from: mukulkhairatkar on June 23, 2010, 06:53:18 am ---Guys,

I am fairly new to Hardware design and PIC programming currently working on PIC 16F877A. I have initialized PORTA and PORTB in input mode and PORTC and PORTE in output mode. Based on logic present the input port, I am setting logic on output port. In idle condition output ports remain zero. But sometimes it jumps to logic 1 and then back to zero. This behavior is pretty random and I am not able to understand the problem. Do you have any suggestion or possibilities I can try to stop this unwanted oscillation?

I am using simple while loop to run the operation and if/else statements to compare input port logic.

any help is appreciated...   Thanks in advance

MAK

--- End quote ---

Does your power supply have a pretty clean output? Like, little ripple and whatnot? I imagine that could be a problem, but it *probably* isn't. Is there any specific port that jumps around? Or is it fairly random?

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod