View previous topic :: View next topic |
Author |
Message |
fuzzy
Joined: 26 Feb 2005 Posts: 64
|
RA4 input or output? |
Posted: Mon Feb 19, 2007 5:51 am |
|
|
Hi, i configured pic16f627A PIN RA4 as output to control a NPN transistor to control 2 led raws. I've some problem programming it.
Using Output_high(pin A4) led flashes for a bit and then shut down.
if i put Output_high(pin A4) in infinite cycle, led flashes but only if in firmware i try to control anyother Port A PIN.
I currently PullUp RA4 with a 10K resistor.
Is there any way to solve this problem?
Do you think it's better to use A4 as In put or OUTPUT do I need to change my pin's configuration and use a push pull pin to control a NPN transistor??
Thanks |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
![](templates/subSilver/images/spacer.gif) |
fuzzy
Joined: 26 Feb 2005 Posts: 64
|
|
Posted: Mon Feb 19, 2007 2:45 pm |
|
|
I had already read that tread.
I was also wondering which is the best use for RA4, input or output?
I'm using a transistor to drive led, so pin not directly on led. Is there a way to solve this problem??
I also put a PIC16F88 on my circuit that has got a push-pull RA4. It works better but I hear a whisper when i press key that is in RA1 and RA3. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Feb 19, 2007 2:57 pm |
|
|
But what about the series resistor described in that thread ?
Describe your external circuit completely. |
|
![](templates/subSilver/images/spacer.gif) |
fuzzy
Joined: 26 Feb 2005 Posts: 64
|
|
Posted: Mon Feb 19, 2007 6:46 pm |
|
|
My circuit is:5V 10K pullup to RA4, from it a series 2,2kohm resistor to NPN Base, NPN Emitter to GND and Collector to led katode. 2 or more led columns from 5V. it's simple. Ra4 doesn't reach 0.8VDD, this is the reason I think. But why i've got a whisper if using 16F88?
I also Use Ra0 as direct led Driver. and ra1, ra2,ra3 as input.
could you sugest me a better configuration?? Thanks |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Feb 20, 2007 4:00 pm |
|
|
I don't know what you mean by a "whisper". You said it's connected
to some LEDs. Apparently you have some audio device connected to
other pins. It could be a read-modify-write problem. Here's a long
thread on that:
http://www.ccsinfo.com/forum/viewtopic.php?t=21825&highlight=16f88+rmw
If you're having trouble with pin RA4 as an output, and you still the
option of using other pins, then go ahead and use the other pins as
outputs. Use RA4 as an input. It's easier. |
|
![](templates/subSilver/images/spacer.gif) |
fuzzy
Joined: 26 Feb 2005 Posts: 64
|
|
Posted: Tue Feb 20, 2007 6:13 pm |
|
|
whisper as a vibration....... as an audible frequency switching in leds. Their luminosity decreases too in that case.as it is driven by PWM.
not audio device. The same happen with 16F88.
Leds on RA4 have a delay time to power off(about 3 seconds) after key switch. With 16f88 leds decrease luminosity but power off after delay. With 16F627A (and the same program of 16F88) leds power off immediately. i cant keep them on for a little period.
Strange behaviour
I think I'll use it A4 as Input. I hope not to have problems.
Do you think PWM can give some problem to RA port??
PWM out is RB3 for 16f627A
should it be any analog problem?? |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
![](templates/subSilver/images/spacer.gif) |
fuzzy
Joined: 26 Feb 2005 Posts: 64
|
|
Posted: Wed Feb 21, 2007 4:12 am |
|
|
the problem is that i'm driving leds only on or off. not in PWM. i can't understand why it seems PWM. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Wed Feb 21, 2007 5:42 am |
|
|
fuzzy wrote: | My circuit is:5V 10K pullup to RA4, from it a series 2,2kohm resistor to NPN Base, NPN Emitter to GND and Collector to led katode. 2 or more led columns from 5V. it's simple. Ra4 doesn't reach 0.8VDD, this is the reason I think. But why i've got a whisper if using 16F88?
I also Use Ra0 as direct led Driver. and ra1, ra2,ra3 as input.
could you sugest me a better configuration?? Thanks |
Think about this for a moment. When RA4 goes 'high', the circuitry inside the chip is basically disconnected. So, you have a 10K to +5v, _in series_ with a 2.2K to the base of the transistor. You will get about 0.3mA flowing into the base, and a voltage at the pin on the PIC of only about 1.39v. If you perform any other write function on the other pins of this port, this pin will not be seen as 'high, and it'll be turned off (the classic 'RMW' behaviour of the PIC). This will then geerate your 'pulse' behaviour, depending on what else accesses the port.
You need something a _lot_ lower as the pull up. To get to 0.8Vdd (the voltage seen as a logic '1' by this input), the pull-up, will need to be about:
2200/3.4 = 647R.
I'd suggest 470R, for reliable operation with a margin.
Alternatively (better), add another transistor. Keep your existing 10K pull up on RA4, and connect this pin to the base of another NPN device. Connect this transistor's collector to the 5v rail, and it's emitter to the resistor feeding the existing transistor.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
|