Jump to content
Users will currently see a stripped down version of the site until an advertising issue is fixed. If you are seeing any suspect adverts please go to the bottom of the page and click on Themes and select IPS Default. ×
RMweb
 

Train Describes using 4 digit 7 segment displays?


St. Simon

Recommended Posts

Here's a simplified example showing how you could feed power to individual LED segments. It displays two codes using a 2-way switch, so six codes would need a 6-way switch. You can have as many digits as you want, of course. OK, you'll need a shedload of diodes, but diodes cost 1p each or something. (Some of the diodes in this example are redundant, but you get the idea)

 

led_display.png

(To a man with an Aduino, every problem is a nail digital)

Hi Merlinb,

 

I could do that, and if it comes to it I will, it's just that I would have at least 3 TD's to do, possibly up to 5, I was trying to think of a way to it easily, while having great flexibility for future expansion, and The chances of me getting all my soldering right once, let alone 3 times is slim!

 

Simom

Link to comment
Share on other sites

  • 10 months later...

Hi,

 

Long time, no update, I have purchased some multiplexed 4 digit, 7 segment displays from Rapid Electronics and have been looking at how to control them, I can either write a program into an Arduino (alhough none of the example code I've seen shows anything like what i want!) or see if there's a commercial product.

 

Suggestions?

 

Simon

Link to comment
Share on other sites

  • 2 months later...

Hi,

 

Long time, no update, I have purchased some multiplexed 4 digit, 7 segment displays from Rapid Electronics and have been looking at how to control them, I can either write a program into an Arduino (alhough none of the example code I've seen shows anything like what i want!) or see if there's a commercial product.

 

Suggestions?

 

Simon

 

By far the easiest way to drive 7-seg displays using an Arduino is to use a MAX7219, for which the Arduino playground has a wealth of information. Each chip can drive up to 8 digits (or a single 8x8 matrix, or 64 individual LEDs if you’re sufficiently masochistic), and can be daisy-chained to drive more.

The down-side is that ‘real’ 7219s go for around the £10 mark, but you can get erzatz clones on eBay/AliExpress/etc for substantially cheaper if you don’t mind them occasionally freaking out†.

 

An alternative is the snappily-named Holtek HT16K33, which will commonly drive 16 digits (or a 16x8 matrix, etc) and is substantially cheaper. They’re only available as SO packages, but Adafruit does a really nice breakout board which is a great platform for messing around. (Also, Adafruit has a 4x14-segment LED backpack in various colours, which might just fit this project to a ‘t’).

This still isn’t 100% perfect, as the HT16K33 uses I2C, and is therefore limited to wire lengths of about 2 metres…

 

In the interests of balance you can also drive 7-seg displays using shift registers, although I can’t say I’d recommend it. Some people swear by it, I’d personally spend a little extra on the Holtek chip and preserve what remains of my sanity :)

 

Hope this is helpful,

J

 

 

† as far as cheapy MAX72xx clones go, I’ve used a couple dozen of them across various projects without any real problems that couldn’t be solved with judicious use of decoupling caps. Obviously, YMMV, and you might not want to deploy a cheap clone in a place that’s not easily accessible, just in case…

Link to comment
Share on other sites

  • 7 months later...

Hi,

 

I've come back to this little project and now I've nailed down my requirements a bit more:

 

  • Controls a 4 Digit 14 Segment Display showing 4 character headcodes e.g. '2R17'
  • Selection of Headcode by Rotary Switch
  • Re-programmable
  • A Standalone unit which doesn't require a connection to a computer to operate other than for programming
  • Doesn't necessarily the increase of head-code numbers, but provision could be made for it
  • A solution that an idiot like me can implement

I believe that this is actually a fairly simple matter, but I can't for the life of me find it! I like the look of your prototype Kev, would you be willing to give some more details on it?

 

Simon

Link to comment
Share on other sites

  • RMweb Gold

Yes, all details schematics, Gerbers (don't worry), pitfalls (not many), firmware (Source and HEX) and advice (plentiful) - I will freely post upon request.

 

I have used my display for DCC experiments (probably useful only to me), vacuum measurement displaying (anyone need to display a billionth of  Bar?) and lately the motorising of my fathers x-axis on his milling machine. (More to follow.)

 

I am going to use it on my own layout (in build) "Tenbione" too.

 

 

But.

I do urge you to look at the following solution where you will not be reliant on other people (good intentions aside!).

 

An easily - cheap - programmable uController board that does not need a programmer or a (bought) Compiler.

https://shop.mikroe.com/development-boards/starter/ready/pic

 

A 4*7segment display - rtr.

https://shop.mikroe.com/add-on-boards/display/serial-7-seg-display

 

The "Basic" Compiler (free for none commercial use that compiles into 2k or less) - that uses simple syntax.

https://shop.mikroe.com/compilers/mikrobasic/pic-electronic-license

 

With the addition of a POT or two plus some switches, to the patch area of the PIC Ready board, you will be away and running.

The most difficult bit will be configuring the PIC but code can be pasted here by me, (and others), you copy/compile/bootload and away you go. What's more, is you will see what I/we've done and before you know it you will be modifying the program to EXACTLY what you require.

 

 

Enjoy.

 

 

Kev.

 

 

Link to comment
Share on other sites

If you go the PIC route, I and probably others write C code for them for a living.

 

I have no experience of Arduinos or rPi's but again someone will no doubt be able to offer assistance whichever route you take.

Link to comment
Share on other sites

  • RMweb Gold

See - there you go.

 

The "MikroElektronika Compilers" are available for Basic, Pascal or C.

All free below the 2k compiled limit - quite generous and will easily accommodate your code/requirements. Just download whichever you want.

 

 

Kev.

Link to comment
Share on other sites

  • RMweb Premium

Hi

 

A Raspberry Pi zero and the MicroDot Phat might provide everything you need.

 

https://shop.pimoroni.com/collections/raspberry-pi-zero/products/microdot-phat

 

You could use one of the GPIO pin (there are plenty spare) to act as the trigger if you just needed the display to cycle through a set sequence or use multiple GPIO pins to select the codes.

 

Cheers

 

Paul

Link to comment
Share on other sites

Hi,

 

Thank you for the all the suggestions, they all look quite good, I would prefer an Arduino solution (I probably should of put that in the post, but I am open to suggestion), as my interlocking is based on Arduino programming language, so an Arduino solution would mean I can de-bug it fairly easily, where as a more 'professional' programming language would be harder for me to de-bug on my own.

 

Simon

Link to comment
Share on other sites

  • RMweb Gold

As promised, here is the schematic for my display board.

 

post-12815-0-36658100-1493560912_thumb.png

 

Apologies for the poor resolution.

I will post better pics, of each section, along with an explanation of what it does and any design requirements.

 

 

Kev.

 

Link to comment
Share on other sites

  • RMweb Gold

I'll start with the Displays - after all, they are what the board is all about.

 

16 segments plus the Decimal Point.

These come in the usual LED colours but I recommend the Red ones as they are the brightest.

post-12815-0-85307400-1493565256.png

Farnell P#: 2290427

 

I got mine from Farnell Electronics.

post-12815-0-67456400-1493565257_thumb.png

NOTE - the price breaks. £2.31ea or £1.37 for 10+ quantities.

No brainer really!

 

Some greater detail but you are better off reading the Data Sheet.

post-12815-0-06976300-1493565259.png

Pertinent Points:-

0.8" display height - ie BIG!

30mA DC Forward Current (NOT 20mA!!!)

155mA Peak Forward Current. If multiplexing then you can give it some more 'welly' to compensate for the off dark-time.)

Common Cathode - ie I have to supply a positive voltage (current) to light up the LED. Switching the uC output to logic ZERO will switch off the LED segment.

 

Connection details per Display.

post-12815-0-46003600-1493565260.png

NOTE - All, but one pin, go to every Display. ie. 17pins, of the 18, daisy-chain from one display to the next. Only pin11 (Common) is unique to each component (this pin will have all the LED currents added up so this can be quite high - more on this later.)

 

I chose 6 digits for my display board.

post-12815-0-74893900-1493565259_thumb.png

Just copy and paste - (Nearly!)

 

 

Kev.

 

Link to comment
Share on other sites

  • RMweb Gold

The Power Supply is nothing fancy and IS the standard linear PSU design used ever since the 7805 voltage regulator was invented.

 

post-12815-0-49664900-1493568707_thumb.png

Nominally, it is a 1 Amp circuit but this is very dependent on what voltage is coming in and what heat sink you fit. Basically, the higher the voltage in then the bigger the heat sink required.

BUT - I did not leave/have much room for a heat sink on the PCB!

 

Related to the PSU are the decoupling capacitors.

You basically have one 100nF (high speed!) cap/IC plus some extra.

I like to 'fill' all spare PCB space with power and ground 'copper pours' which are ideally suited to decoupling caps being sprinkled around the board.

post-12815-0-82181800-1493568706.png

 

 

Kev.

 

Link to comment
Share on other sites

  • RMweb Gold

Next is the Reset circuit:-

 

post-12815-0-21655000-1493569809.png

 

This can do three things:-

Power on reset, (~ 3nSeconds but my value of R1 is bigger than the max 40k specified in the Data Sheet!)

Manual Push Button Reset, and

a normal Push Button Input to be used by the application.

R2 just needs to be 1k or bigger.

Although the Pic has built in noise immunity circuitry, on this input, I still did not want to fit a diode in parallel with R1 to "quickly" discharge the capacitor C1.

 

These reset modes are set by the devices Configurations bits but, most usefully, can also be changed in software on the fly.

 

 

Kev.

 

Link to comment
Share on other sites

  • RMweb Gold

Interestingly, I couldn't find that particular type of display on Aliexpress, but did find a slightly larger version. As the lot is 10 pieces, probably considerably cheaper too! Link <- note, other vendors available, prices may vary due to exchange rates!

 

Thanks for the Link. It's peculiar that you could not find them there!

 

Looking at the Farnell display prices - and price breaks - I think they have made a mistake!

I am thinking of putting an order in for 25 of them straight away, as Farnell has just sent me a %10off code.

 

 

Kev.

Link to comment
Share on other sites

  • RMweb Gold

Now to make the digits "light-up".

 

There is a resister each for every LED segment and YES you do need one / LED!

Each Display's common is then 'controllably' connected to 0v to switch that particular digit on. Because there are 17 segments going into 1 wire, the switching device must be capable of switching all that current on and off safely. I chose the Industry standard ULN2803A Darlington Drive IC which is eight channels and can switch 0.5A on/off per channel. It also has the input 'base' resisters built in thus saving PCB space, money and soldering time.

post-12815-0-09027000-1493571520_thumb.png

 

The Pic can sink or source 25mA per digital output pin. This is a lot.

Nominally, the output swing is from 0 to 5 volts but, in reality, this will be a little bit less.

The calculation for the LED limiting resisters (R7 to R23) is :-

 

R = V / I

R = (supply - LEDvDrop) / LEDcurrent

R = (5 - 2.2) / 0.023 

R = 121.7 Ohms

R = 120 Ohms (Nearest preferred value - ie, easy and cheap to buy)

 

Working back...

I = V / R

I = 2.8 / 120

I = 23.33mA per LED

 

Thus, each digit (fully lit) will draw 17 * 23.33mA = 397mA!! (I have measured this and the board is drawing much less than this - but still more than 0.3Amps.)

 

Also, each limiting resister will dissipate I * I * R = 0.023 * 0.023 * 120 = 64mWatts ie nothing, so I selected the smaller 1/8W 0.3" resisters - saves a load of PCB space!

 

 

I have six displays.

Therefore there are two Darlington Driver outputs spare. I have brought these out to the boards edge as general purpose output control lines capable of driving anything from an LED to a relay. (Snubbing options and pull-up resisters are also included in the design to aid flexibility.)

 

 

Kev.

 

Link to comment
Share on other sites

  • RMweb Gold

3 more circuit snippets to be described plus a software description. The I can describe the PCB design!

 

But first I'll take a break...

 

 

Kev.

Link to comment
Share on other sites

As promised, here is the schematic for my display board.

 

attachicon.gifAND1_1a.png

 

Apologies for the poor resolution.

I will post better pics, of each section, along with an explanation of what it does and any design requirements.

 

 

Kev.

Wow, that's some circuitry, thank you for posting it!

 

I've been looking at these: https://www.adafruit.com/product/2159 these seem to have fairly simple code which I think I can modify, any I write in thinking would be suitable for my project?

 

Simon

  • Like 1
Link to comment
Share on other sites

  • RMweb Gold

Now for the main event - the Micro Controller (uC).

 

The PIC18F4550 is a 40 pin device with 32k Bytes of program space, 2k Bytes of RAM and 256 Bytes of EEPROM (Memory that's remembered even when the power is lost).

Plus it has a whole raft of in-built peripherals - 35 I/O pins, Serial Comms (USB, (a)synchronous, I2C, SPI), 4 timers, 13 * 10bit ADC inputs, lots of RESET choices, lots of CLOCK modes, In-Circuit-Serial-Programming, Comparators, powerful (flexible/self contained) PWM, loads of Interrupt sources, etc etc...

 

Many great features but a lot are mutually exclusive, (selecting pins for I/O means that the peripherals assigned to that pin can not be used, USB uses half the available RAM, etc etc),

all of which means that VERY careful checking of the Data Sheet MUST be done when assigning which functions/pins are needed for a particular project. You not just "copy and paste" - yes I know I do but...).

 

Yes the PIC is complex BUT you will have to make careful reference to the Data Sheet for any device/micro-controller/single-board-computer that you select!

 

post-12815-0-10485900-1493626151_thumb.png

 

Pin assignments :-

 

A, RA4 = LED Segment "a"

B, RA0 = LED Segment "b"

C, RB5 = LED Segment "c"

D, RA3 = LED Segment "d"

E, RA1 = LED Segment "e"

F, RD1 = LED Segment "f"

G, RD0 = LED Segment "g"

H, RE1 = LED Segment "h"

K, RE0 = LED Segment "k"

M, RA5 = LED Segment "m"

N, RB4 = LED Segment "n"

P, RB6 = LED Segment "p"

R, RB7 = LED Segment "r"

S, RB2 = LED Segment "s"

T, RC2 = LED Segment "t"

U, RE2 = LED Segment "u"

(note the missing letters to avoid confusing O with 0, or I with l with 1, etc)

These segments assigned to I/O pins have been moved/swapped many times, during the PCB layout process, to minimise many track-lengths and thus the PCBs overall size.

 

 

The digits are individually' switched on via the following pins :-

DS0, RC0 = the first (left most digit)

DS1, RC1 = the second digit

DS2, RD4 = the third digit

DS3, RD5 = the fourth digit

DS4, RD6 = the fifth digit

DS5, RD7 = the last (right most digit)

Again, these I/O pins were selected to line up with the Darlington Driver IC to minimise PCB track lengths and complexity.

 

Vdd = +5volts

Vss = 0volts

 

Osc1 = not used as I am using one of the built in oscillator/clock modes. (This frees this pin up but I don't use it here.)

Osc2 = not used.

 

Vusb = not used

D- = not used (This frees this pin up for general I/O use but I don't use it here.)

D+ = not used (This frees this pin up for general I/O use but I don't use it here.)

 

Rx, RC7 = asynchronous serial comms in

Tx, RC6 = asynchronous serial comms out

 

Sin1, RB0 = an I/O pin which can be digital or an analogue input

Sin2, RB3 = an I/O pin which can be digital or an analogue input

Dout1, RD2 = an open collector (Capable of 0.5Amps) output 

Dout2, RD3 = an open collector (Capable of 0.5Amps) output 

 

Reset/PB, RE3 = RESET/Push Button in

 

 

Again, ALWAYS refer to the Data Sheet MANY/EVERY time and be prepared to "swap pins" during the PCB layout CAD work.

For example some output pins can be Open-Collector outputs which CAN NOT source any current!

 

 

Kev.

Edited by SHMD
Link to comment
Share on other sites

  • RMweb Premium

Also, each limiting resister will dissipate I * I * R = 0.023 * 0.023 * 120 = 64mWatts ie nothing, so I selected the smaller 1/8W 0.3" resisters - saves a load of PCB space!

Sorry to be pedantic but 64mW is half the rated power of a 1/8 W resistor (125mW)

Link to comment
Share on other sites

Yes, but you must realise the size of the digits is quite small, especially compared to the ones Kev and I referred to.

 

For size, see this image:

https://cdn-shop.adafruit.com/1200x900/2159-00.jpg

 

The holes in the breadboard are 0.1" apart. Do the rest of the maths yourself ;)

It is a good thought and I hadn't considered that, but having now looked at them, they are the size that I was looking at using (around 14mm), the displays are going to be a small unit next to the main panel, so I didn't want them to large.

 

Simon

Link to comment
Share on other sites

  • RMweb Gold

One signal I forgot to document in the uC post above (post49) was the analogue input RB1 labelled "POT".

 

This is a very simple circuit...

post-12815-0-80353000-1493640516.png

Yep, that's right. Just one component.

 

It can be used, in software, to allow the user to 'input' a variable in to the program. Calibration, LED brightness, update speed, debugging, value setting, etc etc.

 

Not much else to say about this except that it can be set to (effectively) an 8bit (256 steps) ADC or a full 10 bit ADC (1024 steps).

(Although, with hindsight, this POT input would have been better/more-useful if I had allocated it to RA3 (VRef+) where it allows many more ways to implement the ADC values. Doh!)

 

 

Kev.

Link to comment
Share on other sites

  • RMweb Gold

I try to make my designs as useful as possible.

To do this, I like to add features/flexibleness especially when they cost little (in design time, PCB space and component cost).

 

This circuit has two channels and although I have labelled them as inputs they can just as easily be used as (low power) digital outputs.

post-12815-0-21970000-1493641892_thumb.png

 

Each channel has five components but they don't all have to be used.

I could just use the input resister and capacitor as a simple RC input filter.

I could use a (high value) input resister and the Zener Diode to input higher voltage signals.

I could use the pull-up and pull-down resisters, along with the input resister, to set default input values for when the input wire becomes open circuit.

I could replace the pull-up and pull-down resisters with clamping diodes.

I could use the pull-up resister with external Push-Buttons (with a resister across each PB) to input lots of PBs into one I/O pin.

etc, etc...

 

Or, just not fit them!

 

 

Kev.

 

Link to comment
Share on other sites

  • RMweb Gold

Finally, it's comms time!

 

post-12815-0-84456600-1493642761.png

(NOTE - the clear labelling of the FLASH port that is carried over to the PCB.)

 

The top circuit is the FLASH port, or In-Circuit-Serial-Programming port.

This is used to 'program' the uC WHILST it is still in your circuit.

Again, the uC's pins are multi function and the ICSP clock and data line are also used to light up the "P" and "R" segments. This is no bad thing as you can literally see the device being programmed! Stlll, care need to be taken when assigning PGC and PGD to other uses. (Refer to the Data Sheet.)

 

 

The lower port is assigned (exclusively) to the a-synchronous serial port - (RS232, in olden times, but with different voltage levels.)

This port just uses standard TTL levels with a couple of input resisters for a little flexibility/protection.

This is the least designed part of (all) my circuits as I want the most flexibility here. ie, I can use any bus standard I like/need by just connecting the required interface to these pins. (USB, CAN, RS232, RS422/423, RS485, etc converters to and from TTL are cheap and freely available.)

 

 

Kev.

 

Link to comment
Share on other sites

  • RMweb Gold

So electronics, whilst not exactly easy, is easier if you break it down into smaller chunks!

 

Now when you look at the circuit (read the circuit diagram?) you can see what each bit does. Much easier.

 

post-12815-0-70987300-1493644180_thumb.png

 

My nine year old son calls my circuit boards "daddy Lego"!

I like that.

:)

 

 

Kev.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...