CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

RA4 input or output?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
fuzzy



Joined: 26 Feb 2005
Posts: 64

View user's profile Send private message

RA4 input or output?
PostPosted: Mon Feb 19, 2007 5:51 am     Reply with quote

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
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Feb 19, 2007 12:49 pm     Reply with quote

This post talks about your problem in detail:
http://www.ccsinfo.com/forum/viewtopic.php?t=27227
fuzzy



Joined: 26 Feb 2005
Posts: 64

View user's profile Send private message

PostPosted: Mon Feb 19, 2007 2:45 pm     Reply with quote

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.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Feb 19, 2007 2:57 pm     Reply with quote

But what about the series resistor described in that thread ?

Describe your external circuit completely.
fuzzy



Joined: 26 Feb 2005
Posts: 64

View user's profile Send private message

PostPosted: Mon Feb 19, 2007 6:46 pm     Reply with quote

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
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Feb 20, 2007 4:00 pm     Reply with quote

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.
fuzzy



Joined: 26 Feb 2005
Posts: 64

View user's profile Send private message

PostPosted: Tue Feb 20, 2007 6:13 pm     Reply with quote

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??
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Feb 20, 2007 6:27 pm     Reply with quote

Apparently, audible noise in LED arrays is possible if the PWM frequency
is in the normal hearing range. This page suggests using a 30 KHz
PWM frequency to prevent the problem:
http://www.national.com/news/item/0,1735,1085,00.html

The LM3519 data sheet has some additional comments on audible noise
with an LED driver. See the section on PWM dimming:
http://cache.national.com/ds/LM/LM3519.pdf
fuzzy



Joined: 26 Feb 2005
Posts: 64

View user's profile Send private message

PostPosted: Wed Feb 21, 2007 4:12 am     Reply with quote

the problem is that i'm driving leds only on or off. not in PWM. i can't understand why it seems PWM.
Ttelmah
Guest







PostPosted: Wed Feb 21, 2007 5:42 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group