PDA

View Full Version : 16F877 Flickering LED



koossa
- 13th May 2005, 14:22
I have this strange problem with a RFID Scanner module that I connect to my PIC.

If I connect the RFID Module directly to a 9volt battery and a 7805, it is working fine.

On the RF Reader module I have a LED Witch goes on and off when I scan a RFID.

When I connect the RF Reader Module to PORTA.3 of my PIC through a transistor (To make the current a bit more), the Module's LED Just starts flickering?

Any ideas what the problem could be?

mister_e
- 13th May 2005, 14:35
can you post your whole schematic for some 'visual based' person like me?

koossa
- 13th May 2005, 14:39
Here is my Circuit

koossa
- 13th May 2005, 14:40
Here is the Pin Names for the RFID Reader Module.
I'm ussing a 2N2222A Transistor at the RF Module.

mister_e
- 13th May 2005, 14:57
Depending of your actual code but... did you disable internal adcs?

ADCON1=7

set PORTA.3 to outpuit, set here to LOw at the begining?

are you sure of your actual schematic? looks weird.. What is the part number of your RF module?

koossa
- 13th May 2005, 14:59
Here is my code:




Include "Modedefs.bas"

DEFINE OSC 20 ' Set the Xtal frequency to 20mHz
RFVDDPin VaR PORTA.3 ' RF Module Power Pin.

Main:
ADCON1 = 7 ' Set Analog pins to Digital.
TRISA = 0 ' Set all PortA Pins as output
high RFVDDPin ' Switch RF Module On.
end

koossa
- 13th May 2005, 15:04
What is looking weird about my circuit?

mister_e
- 13th May 2005, 15:06
by using end this make your pic to stop or goto lalaland IMHO.

what about

DEFINE OSC 20 ' Set the Xtal frequency to 20mHz

ADCON1 = 7 ' Set Analog pins to Digital.
TRISA = 0 ' Set all PortA Pins as output
RFVDDPin VaR PORTA.3 ' RF Module Power Pin.


Main:
high RFVDDPin ' Switch RF Module On.
here:
goto here


also be sure you set the oscillator configuration fuse to HS.

koossa
- 13th May 2005, 15:08
"also be sure you set the oscillator configuration fuse to HS."

How do I do this?

mister_e
- 13th May 2005, 15:12
in your PIC programmer software or into your code
click here to know set fuse into your code (http://www.picbasic.co.uk/forum/showthread.php?t=543)

be sure you have a PIC who can handle the 20Mhz clock. PIC16F877-20

koossa
- 13th May 2005, 15:29
Is _XT_OSC for a Crystal, because that is what I am using and that is what the Inc file's default is?

mister_e
- 13th May 2005, 15:43
XT_OSC is used for 4MHZ crystal/oscillator speed. HS_OSC is used for crystal/oscillator over 4MHZ. The default setting is XT_OSC. There's no difference for a PIC to see ceramic resonator or crystal... since it generate pulses.

So in your case you'll have to change it to HS, in the .INC file or as i suggest, comment the config lines in your .INC file and place all fuses setting in your code. Really handy.

koossa
- 13th May 2005, 16:00
Hi Steve

I have done the following:
Edit C:\pbp\16F877.INC, Replace _XT_OSC to _HS_OSC

And edit my code as followings:


Include "Modedefs.bas"

DEFINE OSC 20 ' Set the Xtal frequency to 20mHz
RFVDDPin VaR PORTA.3 ' RF Module Power Pin.

Main:
ADCON1 = 7 ' Set Analog pins to Digital.
TRISA = 0 ' Set all PortA Pins as output
high RFVDDPin ' Switch RF Module On.
here:
goto here
end



But with no luck, it is still flickering?

mister_e
- 13th May 2005, 16:07
is the actual circuit is on a bread board? If so try removing the capacitor around your crystal and post your result. Also, 0.1 uF capacitor sould be as close as you can of the PIC and of the RF module betwenn VDD and GND.

what about if you change your resistor from RF module otput to VDD? If the problem is still there, what about if you remove your RF module?

koossa
- 13th May 2005, 16:13
It's doing this in my circuit as well as in the bread board.
I have also connect my Crystal and caps directly to the 40 pin ic socket and not through the bread board's holes.

Although if I connect the RF Module directly to the 5volt and GND of my circuit, it is working, but as soon as I connect them to the Pic's Pin, it starts flickering?

koossa
- 13th May 2005, 16:17
Thank you all for your feedback, I have found my problem.

I'm feeling like an idiot, the Transistor was the wrong way arround.

Some datasheets show it one side around and other datasheet the other way arround?

It was strange because I have measured 5v @ 49mA when it was the wrong way arround.

Steve, thank you with all your patience!!

mister_e
- 13th May 2005, 16:18
Hehe it happen ;)