Clarity?

Status
Not open for further replies.

hjl4

Member
Hello and thank you for reading this post.

Again I seem to have confused myself after all day of reading 16f88 datasheet.

Here is what I want to accomplish. RA1-RA3, used for driver of 7 segment common anode LED display. PORTB, (RB0-RB7), used as terminals for the cathodes.
Now here where I'm confused.
When RA1 is high, it supplies around 5V to an NPN transistor, on the common anode side of a multiplexed 7 segment LED display, therefore, turning it on.
So, PORTB, would be sinking the current, would'nt it(cathodes)???
Now when I setup PORTB, do I initialize it as all inputs(1), or a 0.(making them outputs).??
Its even hard to explain.
Basically if display is turned on, what state should the pins on PORTB be, high or low. If segment A,B and C, are on, display showing 7, what state are the PORTB pins RB0, RB1 and RB2. High or Low
I know this is basic, but long day here, and I don't want to short my new chip.

Thanks.
 
Last edited:
So, PORTB, would be sinking the current, would'nt it(cathodes)???
Yes
Now when I setup PORTB, do I initialize it as all inputs(1), or a 0.(making them outputs).??
As outputs. (Use clrf TRISB )
Basically if display is turned on, what state should the pins on PORTB be, high or low
To turn a segment on you would make the corresponding bit on PORTB low.
 
Last edited:
hjl4 said:
When RA1 is high, it supplies around 5V to an NPN transistor, on the common anode side of a multiplexed 7 segment LED display, therefore, turning it on.

If you do it this way using NPN transistor, the NPN transistor will never fully turns ON. At most its emitter has a voltage of 4.2V. By using a PNP transistor instead(emittter to +5V, collector to LED common anode), the PIC will turn it ON fully(a LOW on output pin so the logic is reversed) no problem, giving near 5V to the LED common anode.

hjl4 said:
So, PORTB, would be sinking the current, would'nt it(cathodes)???

Only an output port can source (give out) or sink (accept) current, while an input port is usually of high impedance and provides neither.

hjl4 said:
Now when I setup PORTB, do I initialize it as all inputs(1), or a 0.(making them outputs).??

One controls the direction of a port using the corresponding TRIS register. TRISB=0 is for all eight pins as output, while TRISB=0xFF, all pins are input.

hjl4 said:
If segment A,B and C, are on, display showing 7, what state are the PORTB pins RB0, RB1 and RB2. High or Low

Of course they are low=0, i.e. PORTB should be given a value of 0xF8 or 0B11111000.
 
I have had no problems in the past just using the pic to drive the displays, i.e. not using transistors to switch the segments.

I assigned 3-4 pins for multiplexing the displays, and if the display was a common cathode, simply made the corresponding Pin Low for the each display as it multiplexes, and returning it high to switch it off

and of course opposite for a common anode
 
Last edited:


I'm not too sure where that’s going, I’m no electronic guru, but maybe you could explain that too me, I tried simulating 2 transistors, BC550 and BC557, but both are just as efficient given the same load and base resistances, i.e.

**broken link removed**

Notice that both have the same gain, same VCE, and same current outputs. Did I do this wrong, or are both just as good as each other for driving loads?
 
Last edited:
Thanks to all those who took the time to reply.
You've certainly brightened my day.
Sometimes, it is better to get second opinion on certain things.
After all even though the chip was given to me as a sample, from Microchip, I want to make it work, not just go to smoke.
Maybe I will try to switch the displays directly off of Pic pins, and forget the NPN
transistors.

Again thank you.
 
Just be sure to throw a smallish resistor on each of the switching lines, maybe 150-400 ohms, depends how fast the displays are switching, because if the worst was to happen and your program 'locked up', you dont want to fry the 7 segment display/the pic internals
 

You might try consulting my PIC seven segment multiplexing tutorial, which uses PNP transistors to switch the positive to the LED's - it's really VERY simple, for minimum loss you should use a PNP to switch +ve and an NPN to switch Gnd.
 
gramo said:
Notice that both have the same gain, same VCE, and same current outputs. Did I do this wrong, or are both just as good as each other for driving loads?

Cause you did it wrong. Remember the emitter of the NPN is to be connected to the common anode of the 7-segment, not to ground.

I have amended your circuit so you can do the simulation again.

hjl4 said:
Maybe I will try to switch the displays directly off of Pic pins, and forget the NPN

Don't do that. Gramo has got it wrong and his maths don't add up. I'll explain why.

For a segment to light up decent, some displays need about 10mA for each segment in worst case. This is steady state and the current increased with multiplexing if one wants the brightness of the display to be reasonable. In case of 4-digit display, one would needs four times the steady state current to get a similar brightness on the display.

The current requires when an "8" plus a decimal is displayed is the highest. One has to ask whether a PIC port pin is capable to supply that much current. Sinking current from one segment is sort of OK but can the pin source the whole lot of current to the common anode? What does the PIC datasheet says about the max current available from a port pin?
 

Attachments

  • whatsbetter_.JPG
    130.8 KB · Views: 159
Thanks again guys,

eblc1388, that's what I thought, and was reason for putting transistor there in first place.
Nigel, I don't know why I always overlook your tutorials, as I just checked it out, and sure enough the answer to my questions were there.
I need to smarten up.
I will convert everything to PNP transistors, and thank God I did'nt make pcboard yet.
Yes, I've done that before, being so sure of myself and gone ahead with pcb and all. Most of the time success, but a few times failure.

Have a great day.
 

Its around 20mA, I didn’t have an issue though, must have been because of the extremely fast switching between 4 displays. It could very well be running out of specified limits, thanks for the heads up though - don’t know how that slipped my mind

You absolutely right about the circuits - re-sim'd it and got the results as Nigel and eblc1388 explained, here I have used two NPN transistors to switch GND/+ve, and the NPN is more efficient at switching GND as stated! Thanks for clearing that up for me.


**broken link removed**
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…