Driving multiple 7-segment displays, matrix/multiplex style. Help!

Brandon_K

Member
Join Date
Mar 2016
Location
Pittsburgh, PA
Posts
150
I have a project where I need to drive a dozen 7-segment LED displays from values of 0-9.

Initially, I was doing to use panel mount digital volt meters driven by 0-10v analog output cards, but in effort to try to reduce cost I thought of other ways to do this and decided to give a matrix output a shot.

This would use a total of 19 discrete outputs, 12 to drive the sink leg of each display and 7 to drive the actual segments. I would use a counter to cycle through the outputs that drive the common leg of each individual display so that each display updates every 12ms (assuming a 1ms timer to cycle the counter).

My issue is that I know how I would go about it and it would end up being hundreds of rungs and incredibly inefficient. The basics of cycling through the displays is easy enough, but getting the output correct to drive the segments has me stumped. I would end up doing this with a ton of compare contacts and I know that's not the right way to do it. I *think* the right way to go about this is to create an array or shift register or something, but I have no practical experience doing this. Those are things I've never needed to use before and I'm all self-taught on ladder logic, owing my knowledge to trial and error or you fine gents here.

I know I need to create a table of some sort, the following is about to get very verbose;

If; Top center = DO.1; top left = DO.2; top right = DO.3; center = DO.4; bottom center = DO.5; bottom left = DO.6; bottom right = DO.7

So to create "4", outputs 2, 4, 3 and 7 need to be on. Again, short of a metric *** load of compare contacts, I don't know how to go about this.

So that's the output side.

The input side is super easy, it's a continuous rotary switch (IE, rotary lamp switch with no stops), each rotation will cycle a counter from 1 to 10, then rollover. When switch 1 counter is "2", a "2" needs displayed on switch 1's display (each display will have a rotary switch under it).

Now with my novel of a post done, this may all be for nothing but an exercise in learning. I have a Productivity 2000 rack in front of me that I'm using for development, but ultimately this game will be deployed on a Click for cost reasons. The Click has a very limited instruction set, with the most advanced instructions being Shift Register (which I don't understand how they work, at all) and a drum (which may be the correct way to go about this). Past that, I don't know that a Click will scan fast enough for the outputs to update at a fast enough rate so that the switching of the displays aren't discernible to the human eye. If I have to move to a faster system, I'll just use a Click with three 0-10v analog cards to direct drive voltage meters as I was initially going to do. Just to get my foot in the door with a P2K system (backplane, power supply and processor) will cost more than the entire Click setup, including the analog cards)

Sorry for the novel of a post, but I figured the more details, the better. I would love to hear what everyone thinks!
 
Rung 1 - reset 7 bits

Rung 2 - if '0' then set the 6 required bits
Rung 3 - if '1' then set the 2 required bits
... for a total of 11 rungs.

Move all 7 bits to the output (or intermediate holding bits)

Put this into a subroutine to be called for each display.

If you were using a BCD to 7 Segment Latch/Decoder/Driver chip for each display then you would have fewer outputs and probably wouldn't have to worry about the update rate as much.

Otherwise too bad you aren't using the DL or the Do-more lines with the SEG command.

You say that the counter will cycle from 1 - 10 with a count of 2 showing a '2' on the display. What will the count of 10 show?

Does each switch have only 1 input line? One rotation pulses this line 10 times? If not what type of switches are they?
 
Last edited:
Too late to edit my other post ...

If you want to use tables then in the P2000 create an array with an entry for each value (0 - 9) containing the segments to be set. Since the index is '1' based you may have to add '1' to your count to index to the correct column.

In the Click refer to the 'Pointer Addressing' option in the 'Single Copy' instruction for the method of array-type use.
 
Bernie, the first bit of your reply I'm not fully understanding. I assume these subroutines are being called by a counter running in the main program?

I had actually thought about using a BCD driver, but after looking at the spec sheet, it looked to need just as many inputs as directly driving the display. I did not realize that it latched them on until the next update. That's definitely interesting, though I'm not sure that labor involved of soldering breadboard or having a PCB printed would be worth it as I'll likely only ever make this device once.

I have no issues using a DL06. Cost different is only ~$120 more than a comparable (for I/O) Click setup. I have very little experience with the DL line, my only hands on was from a 3 day training course using DL205 trainers.

Though I will say at that point, a Click setup with three 0-10v analog cards is only $100 more than the DL06 setup. That route (analog Click) would be the simplest way to go as far as wiring and writing the code goes, but on the physical build side I need to find a way to mask the trailing 2 characters of a 3-digit panel mount volt meter. I'm only interested in 0-9 "volts".

I have DirectSOFT 6 on my PC. I popped the SEG instruction in and by no means understand it. Their help file isn't very helpful. That's one of the reasons I love P2K and Click, they (usually) give real-world scenarios of why and how the instruction works.

I was mistaken on the counter, I tend to forget that it rolls to zero, so the counter would be 0-9. A count of zero would equal zero on the display and increases on up the line. But in my initial example of 1-10, a count of 10 would have equaled zero on the display.

The switches are just a simple rotary switch, just like a lamp switch. One rotation turns the contact from off to on, the next rotation is on to off. I use a simple leading edge switch to increase the counter.

I've attached a Click program of how I initially thought about going through with this, but then became concerned with how huge it would be. I'm unsure if the Click is fast enough to do it the way I was writing it, so I figured I might try to make this into a learning process. The program is very incomplete as A) I'm still not sure how to "finish" certain parts of it and B ) much of it is very, very repetitive .
 
I popped the SEG instruction in and by no means understand it.

Going from memory, the SEG instruction takes a four-bit input and converts it to a bit pattern which would represent on a display, the four-bit value. It does the same thing as a 7447 decoder driver.

Remember, you'll need some mechanism to 'dwell' on each digit display long enough to have the human eye register the value. A self-resetting timer driving a counter should work nicely to cycle through the digits.
 
I am sure the click is too slow for this, so i would suggest to use a microprocessor like Arduino.
It is very cheap however very fast and easy to program.
On this you can put a display with 8 numbers, and only 3 lines to connect.
and also you can cascade them to get more.

and yes you will need a simple array of 10 rows of type byte to hold the numbers as bernie is telling.
 
What size are the 7-segment displays? How far are they located from the PLC and each other?

I've not 100% decided on size, but most likely they'll be 1" overall height. The game interface will be somewhere in the area of 36" wide x 18" tall. The PLC will mount to the underside of the game interface, so at max ~24" of wire from the PLC to the display.
 
I have a test prog that uses C0-11DRE-D cpu and C0-16TD2 for both output cards. It is what I had on the bench.
The 16TD2's are 12-24V cards, I did NOT consider COMMON ANODE/CATHODE configuration, just the logic involved for converting 12 single digit values into a matrixed LED display scheme.
I have the 7SEG bit patterns in DH10-DH19 and the 12 individual digit values in DH21-DS32. You would have to copy your GAME values into DH21-DH32 for this example.
A timer with a variable preset does the scanning interval of the outputs and the cycling of the math involved to pump the desired bit patterns from the DH table to the two output cards.
Brandon, let me know if you would like to see the test program.

Oh, it is 8 rungs of CLICK code.
 
Last edited:
I have DirectSOFT 6 on my PC. I popped the SEG instruction in and by no means understand it.
SEG is easier on a DoMore. In the SEG instrution, provide the registers for the NUMVAL and the BITPATTERN and you are DONE!
On the DL, you would need to have your LED NUMERIC value in the CPU ACCUMULATOR, run the SEG instruction and then the 7 SEGMENT bit pattern would reside in the accumulator. You then need to get the bit pattern OUT of the accumulator. Very easy for the uninitiated, NOT - lol.

I have likened programming a DL to assembly language, where it is VERY helpful to know HOW THE CPU WORKS - instead of just HOW THE PROGRAMMING LANGUAGE WORKS. Don't get me started on the DATATYPE-BASED instructions.

Their help file isn't very helpful.
And this hasn't changed in years.

That's one of the reasons I love P2K and Click, they (usually) give real-world scenarios of why and how the instruction works.
I like the CLICK, other than the infrequent software crashes.
I 'like' the P2K/P3K family - other than the Version/Revision-based quirks (from annoying to showstopping) that the devs have easter-egged in to it.
 
Going from memory, the SEG instruction takes a four-bit input and converts it to a bit pattern which would represent on a display, the four-bit value. It does the same thing as a 7447 decoder driver.

Very good and very close.
The manual says it takes a 4 - DIGIT HEX value from the accumulator and places the 7SEG bit pattern back on the accumulator.
If so, it would act as four 7447 chips. with an accumulator of 32-bits and that 4 digits would be 28 segment bits, that would leave 4 bits left over, maybe DP bits??
 
Kwade - since I was coming from a background of programming microprocessors in assembly language the stack oriented math of the DL line was no problem for me. It's interesting how background experience colors our opinion.
 
Kwade - since I was coming from a background of programming microprocessors in assembly language ... . It's interesting how background experience colors our opinion.

Bernie, I agree.
Further, I've always appreciated your posts -- here and in the other forum. I get that 'I think it is time to learn something new' feeling when I see that you have a new post.
Thanks!
 

Similar Topics

We have a handful of nearly identical flywheel-driven machines. About a year ago, we installed a 15HP Powerflex 525 drive in simple V/Hz mode...
Replies
2
Views
883
Is there any issue with running a VFD-controlled 3-phase induction motor in torque control mode in the braking region continuously (back-driven by...
Replies
14
Views
4,033
Hello everyone, we're trying to get some information from our screwdrivers. - The control chain is IqR plc with RD77MS16, connected to MR-J4 and...
Replies
1
Views
836
Hi All, trying to restore a runtime application that i have been reliably informed was created in version 10 ftview, i get the below error:-...
Replies
1
Views
986
This is the tab order I have in the e-sign component in Rockwell. Is it set in stone can this be modified? The ideal set up would be to get to...
Replies
1
Views
1,286
Back
Top Bottom