Chip Output Limitations

MoonGoon

Member
Question?

If you have a 28X and you make all 8 outputs HIGH and all driving LEDS with the same resistances, will the PICAXE be able to provide the same amount of current to all 8 outputs as it would if just 1 output was high?

I have a code which is driving a 7 Segment display.
When i am displaying "1" (2 segments) it is significantly brighter than if i am displaying "8" (7 segments). All lines have the same R value. The segments are connected straight to a PICAXE 28X1.

Can anyone shred some light onto my observation please?
 

Dippy

Moderator
I'll try and shred some light.

PIC chips are semis and will have voltage drops / internal resistances / power losses causing internal heating depending on the load.
You will see (if you look in PIC Data Sheets [go on, dare you]) that the total max output is less than the sum of individual pins/ports.

If you lowered the individual segment current you would see less change in brightness as you increased the number of segments illuminated.

So, BE AWARE of max output per pin AND per port AND total. This is why external drivers were invented.

As far a brightness is concerned, compare it with a weedy battery. Stick one bulb on and it will be a certain brightness, stick 10 bulbs on and each individual bulb brightness will be reduced.
 

westaust55

Moderator
Can anyone shred some light onto my observation please?
And not a pun is sight

Some questions:
1. What is the power supply. 4.5V battery or 5V from mains plug pack?
2. What is the value of resistance in series with each LED

if you are operating with the typical 330 Ohm resistors you will have about 11.5 to 12mA into each LED so the PICAXE is being overloaded.


Typical/"normal" LED’s as opposed to the super bright types can handle around 20mA.
However you will find they are generally bright enough at around 10 to 12mA and some on this forum have operated as low as a few mA. I can vouch that at 0.3mA an LED is visible straight on but very dull and not visible an any real angle.

Maybe a slight generalization here but from past looking at some of the PICAXE datasheets, the PICAXE chips can sink (draw) a total of 95mA from the power supply into Vdd.

Each output can source up to 25 mA but the total load on a port (all 8 pins) AND the total load of all external devices is 90mA.

So, if you have absolutely nothing else connected you could operate all LED’s at say 10mA max better still a little less.
To directly drive all 8 LED’s directly form a PICAXE port I would suggest starting with something like 470 Ohm 0.25W resistors which would give about 8mA to each LED.

Next,, there is no internal means of accurately limiting the current from each PICAXE output so some variation will always occur.

A further question . . .
While recognizing that compactness might be your goal, why not consider either a 74HC595 shift register or one of the 74xx or 4xxx digital BCD to 7-seg display decoder /driver chips to take lighten the load on the PICAXE.

EDIT:
hmmm Dippy is in there with a response while I was typing.

A further thought since you have a 28X1, why not consier a PCF8574 i2c 8-bit expander IC. That whay you keep the max number of IO pints for other devices and the PCF8574 can also sink 25mA per pin on a LOW output. Mind you, even these have a total/max current into Vdd or Vss of 100mA - so again about 8 to 10mA per LED at best. I am running 8 discrete LEDs with a PCF8574 via interface transistors (to avoid logic inversion). Roughly 8mA into each LED and when all are on no discernable variation in brightness.
 
Last edited:

MoonGoon

Member
Thanks guys. I was afraid you were going to say that.
Ill have to use a way of getting all 8 LED's to pull max Amps. To get max brightness.

I think maybe an octal transciever or similar to what Westaust55 mentioned.
I just need all the LED's to be bright.

For anyone interested. This is part of a Charlieplexing Display, which is working great (NO flicker, which is typical) except for the draw back mentioned. But i can easily fix that now i hope.

Thanks for the advise. AS always, this forum is very helpful :)
 

manuka

Senior Member
Well of course you can just select some super bright LEDs, bang in a higher dropper R (1k?) & run them on lower current. Cooking LEDs from the 20th Century usually needed a good 5-10mA, but modern LEDs are often SO bright that currents in that range will burn holes in your retina. Lower drain currents are now almost standard practice, & it additionally prolongs battery life. It makes no sense to have a status light drawing more than the circuit of course!

I've had some (especially green) still perfectly visible in room light when drawing under 1mA, & recall using a 10k dropper once (by mistake) without immediately being away of the resulting LED "dimness". I= V/R = ~4.5 V/10,000 = ~½ mA was being drawn
 

moxhamj

New Member
Westaust55, where are you getting your PCF8574 chips? These look nifty. I am using two HC595s to get 16 IO then using some of those lines to drive LCD displays - it all works fine but it only types a couple of letters per second on the display. The PCF8574 could really speed things up!

Re the original question "All lines have the same R value" - it very much depends on what that R value is. 330R, and yes, the brightness will vary. 1k and it won't so much but the leds will be a lot dimmer. If you really want brightness there are lots of alternatives - led driver chips, even individual transistors.
 
Last edited:

BCJKiwi

Senior Member
Dr,
These are 100k bus only.
Many Picaxters have used the Microchip MCP23017 and 23008 16 port and 8 port expanders (high speed bus).
SPI versions also available.
 

MoonGoon

Member
Thanks guys

i like the idea of using super bright LED's at lower currents. Except i am finding it particuarly difficult to source super bright 7-segments displays.

My knowledge on LED specs apparently isnt very high so i think ill go expand on it to find out what really is out there.

It makes no sense to draw high current into other chips and that likes when there is no need. And my overall goal is to have a minimalised board so ill see where this leads me.

So thanks again everyone.

PS. Anyone know a good source for bright 7-Segment displays?
 

westaust55

Moderator
Dr Acula

Westaust55, where are you getting your PCF8574 chips? These look nifty. I am using two HC595s to get 16 IO then using some of those lines to drive LCD displays - it all works fine but it only types a couple of letters per second on the display. The PCF8574 could really speed things up!
I bought some PCF8574 chips at $2-55 ea from Aztronics at 170 Sturt Street, Adelaide, SA 5000.
http://www.aztronics.com.au/Default.asp
did not find a source here in Perth.

They had over 3800 in stock when I purchased some a week ago.
As others have indicated, the PCF8574 are 100kHz speed, but I have not found that to be a problem.

Aztronics do not stock the Microchip MCP23017 and 23008 16 port and 8 port 400kHz speed IO expanders . They can get the MCP23017 in for about $3-80ea from memory at 1 weeks notice.
 
Last edited:

BCJKiwi

Senior Member
You guys are fortunate to source anything of this nature locally. In NZ (unless I've just not found the right sources) pretty much anything I want has to come from overseas.

Have found Futurlec to be useful as they seem to carry most components I 'm looking for (eg those MCP23008/17s) at reasonable prices and sensible freight charges. Typically take about 5 days to arrive.

Also found it is less expensive to import most of the items I can get locally as the local prices are generally (but not always) 2 to 3 times the cost of imports.
 

moxhamj

New Member
Very interesting. And a great price. So is the 100khz a problem - some people seemed to think it is. Which picaxe chip are you using with them? And do you have a code snippet by any chance :)
 

westaust55

Moderator
Hi Dr,

here is a code snippet as requested. bit buried within my default program template. This is my code modified from 74HC595 version. Lot of the symbol statements at top are irrelevant to actual program code.

I am using a 40X1.

To date I have not had any problems with comms speeds but still early days testing bits and pieces. SO maybe just have not caused a conflict as yet.

Code:
; =================================================
;   File....... LED Test
;   Purpose.... test operation of the set of 8 LEDs via i2c comms 
;   Author..... Westaust55
;   E-mail.....
;   Started.... DD-MM-YYYY
;   Updated.... DD-MM-YYYY
;  ===============================================
;
; -----[ Program Description ]---------------------------------------------
;
; A program to test operation of the set of 8 LEDs via i2c comms
;  causes the leds to light as a moving dot zig-zagging back and forth.
; 
;
; -----[ Revision History ]------------------------------------------------
;
; 
;
; -----[ I/O Definitions ]-------------------------------------------------
;
; - - - DIGITAL INPUT PINS  - - -
SYMBOL key_data = 0         ; keypad serial data input
;      val_data = 1         ; keypad valid data signal - interupt 
SYMBOL tempsens = 2         ; DS18B20 temp sensor data input
SYMBOL us_echo  = 3         ; ultrasonic sensor data input pulse duration == distance
SYMBOL irdetect = 4         ; infrared detector data input

;
; - - - DIGITAL OUTPUT PINS - - -
SYMBOL speaker  = 0         ; piezo speaker output
SYMBOL ir_outpt = 1         ; infrared LED data output
SYMBOL us_trig  = 2         ; ultrasonic sensor trigger signal
SYMBOL ledclock = 3         ; clock pulse to shift data into 595 with high pulse
SYMBOL ledlatch = 4         ; latch to set data on 595 outputs with high pulse
SYMBOL led_data = 5         ; serial data line to 595 shifted in with clock pulses
SYMBOL shiftled = 6         ; keypad SHIFT led control on Output 6
SYMBOL lcd_data = 7         ; serial data to LCD display
;
; - - - ANALOGUE INPUT PINS  - - -
SYMBOL adc_pot = 5          ; potentiometer analogue input
SYMBOL adc_ldr = 6          ; light dependant resistor analogue input
SYMBOL adc_mag = 7         ; hall effect magnetic field sensor analogue input
;
;
; -----[ i2c Devices ]-------------------------------------------------------
;
; 24LC256 EEPROM's
SYMBOL eeprom_0 = %10100000  ; %1010 = EPROM, 000 = Addr 0 & 0 = control bit
SYMBOL eeprom_1 = %10100010  ;                001 = Addr 1
SYMBOL eeprom_2 = %10100100  ;                010 = Addr 2
SYMBOL eeprom_3 = %10100110  ;                011 = Addr 3
SYMBOL eeprom_4 = %10101000  ;                100 = Addr 4
SYMBOL eeprom_5 = %10101010  ;                101 = Addr 5
SYMBOL eeprom_6 = %10101100  ;                110 = Addr 6
SYMBOL eeprom_7 = %10101110  ;                111 = Addr 7
;
; PCF8574 8-BIT IO EXPANDERS
SYMBOL expand_0 = %01000000  ; %0100 = Chip ID, 000 = Addr 0 - For the 8 Red LED's
SYMBOL expand_1 = %01000010  ;                , 001 = Addr 1 - For Keypad Shift LED
;
; DS1307 REAL TIME CLOCK with 56 bytes of RAM
SYMBOL rtc1307  = %11010000  ; %1101 = Chip ID, 000 = hard addr
;
;
; -----[ Constants ]-------------------------------------------------------
;
SYMBOL shiftky = 64

;
; -----[ Variables ]-------------------------------------------------------
;
SYMBOL keypd =  b27
SYMBOL keyval = b26
SYMBOL shlock = b25
SYMBOL keychr = b24
SYMBOL pattern = b23
SYMBOL delaytime = b22
SYMBOL tone = b21
;
; -----[ EEPROM Data ]-----------------------------------------------------
;
;
;
; -----[ Initialization ]--------------------------------------------------
;
Init:   pattern = %00000001
        delaytime = 500
        
;
;
; -----[ Program Code ]----------------------------------------------------
;
Main:	  HI2CSETUP i2cmaster, expand_1, i2cslow, i2cbyte ; Set up for 9th LED
        HI2COUT (0) ; SHIFT LED off
        PAUSE 500
        HI2COUT (1) ; SHIFT LED on - just blink LED on and off
        PAUSE 1000
        HI2COUT (0) ; SHIFT LED off
        PAUSE 500
        HI2CSETUP  i2cmaster, expand_0, i2cslow, i2cbyte ; Set up for set of 8 LEDs
        HI2COUT (255) ; turn on all LEDs for 1 second
        PAUSE 1500
        HI2COUT (0)
        PAUSE 500
        
        
      DO    
		GOSUB shwpattn
		PAUSE delaytime
		pattern = pattern <<1
		tone = pattern-1
		SOUND 0, (tone, 50)
		PAUSE 500
	LOOP UNTIL pattern=%10000000
	DO
		GOSUB shwpattn
		PAUSE delaytime
		pattern = pattern >>1
		tone = pattern+1
		PAUSE 500
		SOUND 0, (tone, 50)
	LOOP UNTIL pattern=%00000001
	GOSUB shwpattn
	PAUSE delaytime
	GOTO main


;           END
;
; -----[ Subroutines ]-----------------------------------------------------
;
shwpattn: HI2COUT (pattern)
          PAUSE 10
          RETURN
;
; -----[ Interrupt Routines (if used) ]-------------------------------------
;
;Interrupt: 
	     


;           RETURN
; =================================================
;      THE END
; =================================================
 
Last edited:

MoonGoon

Member
Does anyone know if there is such a thing as a "Tri-state Transistor" ?

Eg, one that i can make HI, LOW, or Hi Z ??

Because doesnt a transistor when not biased simply go to ground? I want one that can go Hi-Z aswell.

im showing my lack of component knowledge here :eek:

Anyone care to enlighten me?
 

westaust55

Moderator
Tri-state Outputs

I am not aware of any transistors or even darlington like packages that provide tri-sate outputs.
transistors can be considered as either simple switches if driven into saturation or otherwise as analogue devices (eg amplifiers).

Tri-stare devices need an additional signal to control when the outputs are active or high impedance.

If you are looking to have tri-state outputs for multiple signals, then why not consider some of the hex (6) or octal (8) buffer type digital IC's

For example 74HC367 is a hex tri-state buffer and
74LS240 (inverting) and 74LS241 (non-inverting) octal tri-state buffers.

Or if less signals are needed then the 74LS126 is a quad (4) tri-state buffer

Usually the more discrete buffers in teh package, the more pins the IC has to accomodate the singals in and out plus the output enable control pins.
 

Mycroft2152

Senior Member
Be aware.

The hex and octal buffer type IC's will have the same power limitations as the PICAXE.

You may have to go to high power driver chips for the displays.

Myc
 

moxhamj

New Member
I used heaps of 74HC373 tri state latches back in the days of 8 bit microprocessors. They work best with an 8 bit bus system and you need 8 output lines plus 2 or 3 address lines and a read and latch line. So maybe 13 lines which limits it to the bigger picaxes. But once you have a bus, you can add as many devices as you like and expand the outputs to large number. Still, the current limitation is there as mentioned above.
 

MoonGoon

Member
Octal Tri-state buffers.
Sounds like my kind of device. Ill definately look into it.

As for extra lines, the beauti of Charliplexing is the fact that i only need 8 lines. 7 segments and ground. I can run up to 8 displays still only using the 8 lines. I think its a great technique. If i can work the kinks out at my end that is. ;)

Maybe I can find a Quad buffer, and have 2 of them to get my Amp requirements.


Thanks again for the advice.
 

hippy

Ex-Staff (retired)
Charlieplexing is great and can give a minimal solution to complex display problems if you can live within the limitations of that solution.

Because each segment is only on for a short time ( 1/56th for an 8x7-seg display ) the display will be much dimmer than one where all segments are continually powered or are on for 1/8th of the time. You can overdrive current into a segment and through and I/O pin or port to make it brighter but that only works when the average current remains below spec ( and that's only a simplistic interpretation ). This is how projects work which drive LED's directly from 5V without any R's.

You can improve things by replacing I/O with external tri-state buffering which can sink and source higher currents but you need to find or design them and then you need to 'double-up' on I/O lines to control that buffering - two lines are needed to select high, low, tri-stated.

As you add more control lines it becomes simpler to use standard multiplexing using high-side and low-side transistors / FET's to handle higher currents.

Also, the more segments you are multiplexing the longer it takes the software to complete a cycle and that can start to introduce flicker on a PICAXE when charlieplexing a multi-digit display.

As always it's a question of trade-off. Because of PICAXE/PICmicro limitations it's a choice between a simple to use charlieplexing setup with limited capabilities or a more complicated multiplexing system with better capabilities. The alternative is to go to a dedicated display multiplexor / driver designed to do the job.
 

Mycroft2152

Senior Member
Charlieplexing is great and can give a minimal solution to complex display problems if you can live within the limitations of that solution.
As always it's a question of trade-off. Because of PICAXE/PICmicro limitations it's a choice between a simple to use charlieplexing setup with limited capabilities or a more complicated multiplexing system with better capabilities. The alternative is to go to a dedicated display multiplexor / driver designed to do the job.
It is important to look at the big picture when using multi character displays.

Yes, it is easier to understand what is going on with a Charlieplexed or a '595 shift register driver. But, add in the time to wire them up, the extra size of the board, the flickering, the processer overhead, and the trouble shooting. Then a dedicated display /driver chip make a lot of sense.

It like the old adage, you CAN cut a tree down with a pen knife, but it is soo much easier with a chain saw.

Myc
 

MoonGoon

Member
Can i please have some tried and proven examples of dedicated drivers / chips examples that will run 5x 7segment displays ?

Iv tried 4026's and they dont have the specs im hoping for.


Thanks everyone
 

MoonGoon

Member
By specs I simply mean that i dont want flicker in the transition between numbers.

I tested 4026's with 3x 7 segments and counting into the hundreds there was flickering during the count up. I dont want any flickering. And also using 5x 4026 takes up a Significant amount of board room.

I want 5x 7 segments to run with no flicker. and max brightness. Thats all.

The only problem im having with my current display is that it isnt bright enough.

Sorry if this thread seems to be draging On and On.
Im just hoping there is a simple solution out there in the big wide world.
 

manuka

Senior Member
Your needs may well be contradictory - fast refresh rates (~hundreds of Hz) will tame flicker, but the brightness may suffer. PICAXE driving of course means slow (mSec level) execution rates. How rapidly do the digits change? More outputs (20M has 8 I/O)? Considered overclocking?
 

moxhamj

New Member
If you really want full brightness and no flicker then each led needs its own dedicated driver. And for full brightness I presume that means about 20mA and that will go over the current limit of many HC chips. Wiring up 5 HC595s and (35 transistors or 5 dedicated driver chips) by hand would test my patience, though I'd be ok about doing it with a PCB. So this does lead to the conclusion that dedicated chips are the best. Others on this forum have more experience with these and I seem to recall this question came up a few months ago and there were lots of great suggestions. ? do a search.
 

BCJKiwi

Senior Member
An option is I/O expanders which have been discussed before.
2x16port and 1x8port will give you the 5 off 7seg plus dp modules you are looking for.

Just put the number patterns in scatchpad and bang them out directly to the I/O expanders (7seg displays) via i2c.

e.g. MCP23017 will sink/source 25ma per port (segment) with a total of 125/150ma for the 16 ports if all full on at the same time = 7.8ma/segment. If you pwm it to < 50% on then you will 'see' full brightness without overload.

If however you run with 5 MCP23008s then you will get the full 125/150ma over 8 ports = 15ma per port(segment) will all full on or 17.8ma if you don't use the dp.

No flicker and these latch so you only need to send data when you change a 7seg unit. Each 7seg can be addressed individually so if the hundreds does not change then it does not need updating.
 
Last edited:

MoonGoon

Member
Thanks for everyones help.
There are plenty of suggestions. Now i just have to go and see which one is best for me.

Thanks heaps.

Moongoon
 

hippy

Ex-Staff (retired)
If flicker is the main problem, then from worst to best on a PICAXE I would expect to be -

Charlieplexing
Segment-by-segment multiplexing
Digit-at-a-time multiplexing
Each Digit latched

Where a 4026 falls in there is hard to say as it depends on how it is implemented. Resetting to zero and incrementing using ripple-carry will cause flicker, incrementing each digit separately will have a lot less, clever software and resetting individual digits will minimise it further.
 

MoonGoon

Member
I have just been reading the datasheet for the 28X1.

It says:
"Maximum output current sunk by any I/O pin = 25mA"
"Maximum output current sourced by any I/O pin = 25mA"
"Maximum current sunk by PORTC and PORTD (combined)(2) = 200mA"
"Maximum current sourced by PORTC and PORTD (combined)(2) = 200mA"
"Maximum current into VDD pin = 250mA"

Are these values somehow changed when PICAXE code is installed?
Because based on the datasheet shouldnt I be able to light my 7 LED's on PORTC at 15mA each?
 

BCJKiwi

Senior Member
Well, yes you could but only just - you need to carefully balance the per pin and per port current availablity without overloading the 28X1, and you would need an output pin for each and every segment in each of the 5 x 7seg displays = 35 outputs.

While there are more chips involved, its simpler overall to leave the 7seg driving to something else while the 28X1 deals with the inputs, logic, timing etc and sends the output info off to the dedicated drivers whatever they might be.

If you had a simple circuit and only 1 7seg to deal with it might be a different story and a 20M would be ideal. But you have indicated that you want to drive 5 x 7 seg displays at once to full brightness (post#22).
 

MoonGoon

Member
Im really sorry. I am clearly not explaining this very well.

I have 5x 7 segments. YES.
But they are being multiplexed using the Charlieplexing system. So that means that only 1 display is on at any one time.
That means i can run all 5 displays off just 8 lines. No D.P. No driver IC.
The highest load scenario would be displaying a figue 8 (7segments HI)
All my pins are on PORTC.
So highest load scenario would be 7 output pins HI delivering approx 20mA each.
Total = 140mA + Chip overhead current.

Should this be possible or am i interpreting the datasheet wrong?
Or is it more likely im missing something completely here?
 

inglewoodpete

Senior Member
MoonGoon, You don't need to drive the segments at 15mA. You should find there is very little decrease in brightness at 3mA. That should give you a lot more flexibility.
 

Mycroft2152

Senior Member
Im really sorry. I am clearly not explaining this very well.

I have 5x 7 segments. YES.
But they are being multiplexed using the Charlieplexing system. So that means that only 1 display is on at any one time.
That means i can run all 5 displays off just 8 lines. No D.P. No driver IC.
The highest load scenario would be displaying a figue 8 (7segments HI)
All my pins are on PORTC.
So highest load scenario would be 7 output pins HI delivering approx 20mA each.
Total = 140mA + Chip overhead current.

Should this be possible or am i interpreting the datasheet wrong?
Or is it more likely im missing something completely here?
That would be true if the sements were on all the time. But you are scanning through each of the displays and each will be on for a fraction of the time. this will result in a very dim display.

When you multiplex a display, the brightness is dependant on the average current.

To see how this works, breadboard it using a couple of displays.
 

BCJKiwi

Senior Member
@MG,
From a load perspective you could drive them all via charlieplexing as you describe via 8 output pins.
However, as has been advised previously, each display will only be on for 20% (less overhead) of the time so will not be fully bright and will probably flicker.

At some point you need to decide exactly what the requirements are;
If you want 'cheap and cheerful' and can tolerate dimmer & perhaps flickering displays than charlieplex and drive directly.

If however you want no flicker, full brightness, and flexible control options, then you need latching driver circuits of some sort.
 

hippy

Ex-Staff (retired)
Good point about charlieplexing driving whole digits at a time, that makes it better than segment-by-segment multiplexing in terms of less flicker.
 

MoonGoon

Member
i do understand about scanning a display and LED's only being on for partial time periods and not being alowd to get to full saturation.

But iv been fault finding by slowing the multiplexing rate down to 1sec per display. Thats well in excess of what the LED's need to fully turn on.
Im still getting figue 8's (7 segments) considerably dimmer than a figue 1 (2 segments)
Which brings me back to my original quarry of whether or not my datasheet interpretation is correct in that the chip itself can sink 25mA per I/O and total of 200mA per PORT ?

Is this whole thing probably just a case of not being able to provide enough current when 7 pins are HIGH? even though i only need a total of around 140mA ? (worst case scenario)

To avoid flickering, im plexing whole digits at a time, aswell as my code which scans the displays multiple times during each whole cycle of the code. plus im overclocking at 20MHz. Which helps considerably.

Im sorry if this thread is getting repeatitive. i really am greatfull for all the advise, just want to get to an answer so i can solve the problem.
As do we all.
 

MoonGoon

Member
I also dropped the current to each LED from 15mA to 5mA as suggested.

i got a decrease in brightness overall, but it was still visible.
But my figue 1's and 7's are still way brighter than my figue 8's and 9's. regardless of which display the numbers are being put on.

The code to display all the numbers is identicle for each number, (except for the individual patterns obviously) So i cant see how that can be an issue.

please help, im running out of ideas.
 

BCJKiwi

Senior Member
This should not be happening.

How did you drop the current?
You need an R for every segment, not a single R on the charlieplexing common.

Perhaps you could post the actual circuit as wired.
 
Top