7 Segment Display

K9ACT

New Member
I am having trouble finding info on driving 7 segment displays with the Picaxe.
What info is out there seems to always involve other devices to make it work.

I have built half a dozen counters and timers using 16f628a driving multiple digit displays and don't understand why all the Picaxe stuff uses shift registers to do the same thing.

I am having problems really understanding multiplexing of them in asm so I thought it might be easier with a Picaxe but I am at a brick wall.

As an aside, Googling Picaxe Projects produces nearly zero projects using 7 seg displays. Clicking on "images" in the search gets even more depressing.

Am I missing something about Pickaxe and 7 segment displays?

For the record, I am using 18m2 parts.

Thanks,

Jack
 

eclectic

Moderator
Try an Advanced search (above right).
Tick all the top boxes.

Use the search terms

segment multip*

Plenty as a starter.
e
 

Billo

Senior Member
One of the reasons for using shift registers and chips like the MAX7219 is that you can control many display digits while using few I/O lines. For instance, using a MAX7219 you could use an 8 pin PICAXE to run an 8 digit display. As far a multiplexing goes, you would do this basically the same way as you did using asm on the 16f628a, by manipulating the I/O. For instance using a 20M2 you could use one port for the segments and the other port to select the digits. However, since the PICAXE is running an interpreted language, the multiplexing rates (how quickly you roll through the digits) is a lot slower than when using asm. This can lead to noticeable flickering when many digits are being controlled. Which is another reason shift registers and MAX7219s are used.
 

K9ACT

New Member
One of the reasons for using shift registers and chips like the MAX7219 is that you can control many display digits while using few I/O lines. For instance, using a MAX7219 you could use an 8 pin PICAXE to run an 8 digit display.
.
Understood but I am using a 18m2 and have pins to spare.


> As far a multiplexing goes, you would do this basically the same way as you did using asm on the 16f628a, by manipulating the I/O.

OK again but the asm programs were scavenged from the net and I do not understand how they work so I was hoping it would be more understandable with Picaxe.

> However, since the PICAXE is running an interpreted language, the multiplexing rates (how quickly you roll through the digits) is a lot slower than when using asm. This can lead to noticeable flickering when many digits are being controlled. Which is another reason shift registers and MAX7219s are used

That probably answer the question. However, as this is just a learning experience, flicker would not be an issue.

Thanks,

js
 

Paix

Senior Member
Hello Jack, Nothing quite like being frustrated and hitting the wall when looking for ideas.

Eclectic has already pointed at a rich source of threads on the subject, but there are issues to consider.
The naked 18M2 will dirve ONE seven segment LED display. Assuming common cathode, then the individual segment anodes will be driven via current limiting resistors and the common cathode will be connected to Ground. With the decimal point, this will take eight pins, the B port is probably a good candidate, until you want some of the facilities from that port for other things of course, then you will have to start making compromises. This is proof of concept though so use B.0 through B.7.

Even then, you can use B.0 = segment A through B.6 = segment G and B.7 = decimal point. That makes the code relatively simple, but it might not be so smart for the ease of wiring up, which you may consider to be more important. I'm sure that you are getting the idea now. Each character will be an eight bit pattern sent to port B with the pinsB = %11110000 command which will in this case set half the segments on and the other half off. So, whether you use a Select Case statement or whatever to assign the characters is up to you.

The port pins will only drive a maximum of one LED effectively, so if you want to drive more than one display you will have to get a little bit more cute.

A general purpose npn transistor with a 1k base resistor as shown in the diagram in the above link. The collector of which will go to the common cathode and the base resistor will be driven by a suitable (almost any) pin on portC being taken low to enable the display, while the individual segments are high.

If you want more than one display, then you will drive the anodes of all from the portB pins and select the appropriate transistor to take the relevant display cathode low and light the selected display. If you enable a number of transistors at the same time, then lights will go out as the Picaxe drive will be exceeded and could become very unhappy. if indeed the situation was reversed with common anode displays, then that sort of situation would probably cause the Picaxe to smoke somewhat.

If you only have a limited number of pins, such as wanting to drive one or more seven segment displays with an 08M2 for example, then you will need to
think about using a CD4026 seven segment counter display driver and changing the strategy to one of counting.

Using a 4511B binary to seven segment driver allows you to use four pins for the numeric information and one for a clock pulse.

Both these two strategies will cause the display to flicker slightly, so enter the 75HC595 serial in parallel out shift register. Run in your number as a suitable (you choose depending on your wiring) serial seven segment representation, (eight bits) into one or more shift registers daisy chained and when your number is loaded, strobe the chips to transfer the register contents to their outputs. Bang, the numbers are there, without any flicker and you can be loading the next reading whilst watching the current displayed values.

Where you make your compromises is a matter of personal preferences. Issues are parts availability, cost and complexity. but each has it's merits.
At the bottom of the food chain is the 4026 and the 74HC595 shift register is probably one of the more comprehensive options. Of course there are probably more esoteric integrated solutions out there which will really dent the brain cells.

Before you can program such devices, you need to understand how to drive the various options and the timing of things. it's not really something that is initially approached from the programming direction.

This has been general, I hope that it has been helpful and not caused any confusion, but there are literally a number of ways to skin a cat out there and the choice is yours. Bear in mind that if you are looking to source or sink more than 10mA to 15mA from a Picaxe pin, then you need to be thinking about a force multiplier of some sort to handle the current involved.







Ah, but
 

K9ACT

New Member
Not sure why but it worked this time and I have lots of reading to do.

My actual project is back to a posting of a month or so ago with an upgrade.

I have a 4 bit binary counter that displays to leds. I want display this to a 4 digit 7 seg display as one and zeros.

I now have a Picaxe displaying to one digit but that is as far as I have gotten.

Thanks for the help.

js
 

K9ACT

New Member
Well, now I have another problem. It says there are 181 topics but will not let go beyond page 1. says no results.

However, going through all the threads on page 1, I don't see any that multiplex without external devices and it would take a week to go though all the rest if I could.

Does anyone have a link or scheme for muxing multiple digits?

I understand the hardware but don't know how to implement the code to scan and keep both digits running. I don't care about the flicker. The device is 18m2.

js
 

Billo

Senior Member
I don't have any code written, but I would approach it like this.

Assuming you are using an 18M2, then run the segments off of port B (bits 0-7)
Enable the digits through small transistors off port C (bits 0-3)

Sample pseudo code:

Code:
Display:
    N= 0
Loop:
    Blank all digits
    Output segment pattern for digit N
    Turn on Digit N
    Increment N
    If N > 3, then N=0
    If (Exit criteria is met) Goto Done
Goto Loop

Done:
  Return
Make sure the patterns for digits 0 - 3 are set to what you want displayed before calling Display.
 

westaust55

Moderator
There are many chips produced with the aim of making it easier to drive 7-segment LED displays these include various BCD to 7-seg decoders, the Max7219 and the SAA1064.
By easier I mean less microcontroller pins requires, easier/small code (as the external chip handles the multiplexing, and even brightness levels) and in some cases inbuilt mapping to take a digit 0-9 or 0 to F and output the required 7-seg code.

But for a direct driver display with multiplexing even a Google search finds examples specific to PICAXE. The very first of many hits I received on Google is:
http://reviseomatic.org/help/2-picaxe/Picaxe 7 Segment MUX.php
 
Last edited:
Top