Allegria ! the mad watchmaker is back !!
The title is deliberately provocative because it would have been:
I DISPLAY A MATRICE: HW SW TECHNICAL AND USE
This is because what I am going to describe are the dot matrix display 8×8 (7×5 8×5) seeking to understand the methods both hardware and software for their use. For this I produced some prototypes (were these state of the art) digital clocks that use just these matrices. It states that the HW characteristics are almost identical (it just changes the pin) both COMMON ANODE that COMMON CATHODE. So before entering specifically in’ basing it on some video to show some of these prototypes.
NB: to display videos: fate click sul link: will open a dialog box asking you whether to open or save the file. The videos can be seen with Windows Media Player or similar for wmv files.
This video demonstrates how a simple matrix 8×8 You can display a clock “BINARY”. If it had thought in mind time ago instead of the one already presented in another article of mine !
In this video, the individual clock values are displayed point by point: the sequence shows the formation of values starting from the left with the tens of hours and then to follow up to the minute. The second scan is displayed by a LED / pixel third from the left on the display.
Big characters that make up the hours, the minutes and the seconds to scroll from right to left indefinitely. Given the time taken for the formation of character, you lose about 2/3 seconds between the full and the subsequent display.
In this latest video a watch “a parole”. In this case do not use a dot matrix display, but a particular device: the DL2416T. It is a display “intelligent” composed of 4 digits with multiple segments that can display numbers, letters and some special characters. This device, now obsolete, It is now available in updated versions but unfortunately quite “Dear”. Those in my possession derive from the cannibalization of some dot matrix printers the years 80/90. As you can see from the video, this is the only prototype finished (pcb with both the display and the part “main” with micro Arduino_Nano and the control electronics).
CHARACTERISTICS OF MATRIX DISPLAY
On the Internet there are many images and examples on the use of these matrices: They may be a help to appronfondire their specific use. However, many examples are superficial and, in my opinion, not comprehensive. So what I will describe is only the result of studies and personal experiences. Any reference is purely coincidental.
In the figure below it can be seen: il display 8×8, the module that houses both the display its controller (MAX7219), the logical layout assigned and managed by sketch, and finally the pin assignment of the matrix on the module. L’ housed on the orientation of the display module has a single position (8 right and pin 8 to the left) whereby if it is placed upside down obviously it will not turn on properly. From the fourth figure you can verify the assignment of the display pin with those of the controller (MAX7219), One can therefore deduce which are the cathodes (I will call “DIGIT“) and what are the anodes (I will call “SEGMENTS“). The display in question is COMMON CATHODE.
The reason why I called the cathodes “DIGIT” and anodes “SEGMENTS” It comes from how it is managed from the hardware or software, the display and the associated controller. These displays can be compared to the display 7 segments + 1 defined as “A”, “B”, “C”, “D”, “E”, “F”, “G”, “DP” (decimal point or eighth segment). Each column 8 LED / pixel of the matrix (see third figure) It can be a display 7+1 segments and then an array can be likened to a chain of 8 display a segmenti. To turn on a single LED / pixel is sufficient to apply the pin “cathode” of the column to ground and pin “anodo” the single segment to a logical value “1” (+5V fall through R). E’ clear that in order to form a character or a number is necessary to turn on led / pixel according to a predetermined format at the same time (Persistence del'immagine to the eye): or use multiplexing. It makes no sense to connect digits and segments (8+8 pin) to the outputs of a microcontroller (with resistors obviously fall) and unnecessary programmatic complications.
In my projects I always used to think that the “principe” from “shift register” because with only 3 pin able to drive a chain of 8 matrices connected in cascade to each other or 8 display a 7 segments. With a limitation (Then we will see that it is not) : solo moduli a “COMMON CATHODE”. This chip (low costs if a module with so much of the display is worth 1,5 a 5 euro) and the MAX7219. The main features:
- 3 PIN for driving (LOAD/CLOCK/DATA_IN).
- Multiplexing integrato.
- scheduled Dimmable.
- Pin DATA_OUT for connecting another display.
- Manages indifferently both to segment display that the matrices.
- 7 registers for operating controls and 8 per i digit.
- Limitation of brightness even from the outside with trimmer.
HOW TO USE AND PROGRAM THE CHIP MAX7219
Using this chip now for all projects involving the management of the display is a matrix or segmented LED array also for RGB. About RGB LED shortly I publish the “CHRISTMAS STAR” although it is not the season !. We deepen then with the chip and pin the various registries:
DG0/DG7 drive the cathodes of the display, SEG_A / SEG_DP Flying the anodes of the display. Per i display a matrice DG0/DG7 They refer to the columns while SEG_A/DP They refer to the individual LEDs / pixex column. L’ Segment allocation / Led and its binary value must be configured in the registry “DATA” bearing in mind that the bit “DP” vale 128 (0x80). The pin FROM It is relative to the input data , pin Load/Cs select the chip, pin CLK provides clock and finally the pin DOUT It is what allows the cascade connection of another chip for a maximum of 8. Last pin “ISET “to adjust the brightness value by connecting a R 10K (one one trimmer) to the positive pole.
Let's see the records:
Use and meaning of individual registers:
- Registry 0: put to “0x00” It serves only to display in chains. (0VVER no operation for the specific display).
- Logs 1/8: These are the registers that address the individual segments for ignition of individual segments (see format DATA REGISTER).
- Registry 9: Decode_Mode: It needs to chip to see if it is used the BCD code or none.
- Registry 10: Brightness Change. value to 0 a 15. With a value of zero will not get off the display but its minimum brightness. You can make luminous effects bringing this register from 0 a 15 in a progressive and cadenced way.
- Registry 11: Scan limit: indeed it must indicate how many digits are scanned: a table on datasheet shows the values to be assigned.
- Registry 12: operating mode (ShutDown). Alternating the value of this register (gives 0x00 a 0x01) You are obtained by switching on or off the display (without losing any present value). It may help to create the effect flashing alternating the two values measured way.
- Registry 13/14: no.
- Registry 15: Device Test: you get the lighting of all the LEDs connected.
Basically to execute a specific command, please send to the chip 2 byte: the register address and the value which must assume as a function of the same command: for example normally start you must send the sequence: “0C00“.
THE MANAGEMENT SOFTWARE
Here's the most interesting part: how to manage these displays. Network, obviously, you can find numerous examples and libraries and at the beginning I had downloaded a few of these libraries: LEDCONTROL e LEDCONTROLMS and used for the first tests . I'm not satisfied are valid but pesonalmente why I developed my benefit a “Library sui generis” able to manage both cathode display ANODO domune. I defined “Sui generis” because it was not written on the lines but is actually a file (.ino) which contains all the necessary functions and implemented for both matrices that for 7 segments. E’ just include this file in the sketch and then make the calls. (I reserve the right to convert this file in a library genuine). As the opening words of this article regards the matrices we see how they can be managed.
First, you must define how many matrices must be treated: one or more. If for a single array, there are no particular problems, when it comes to connetterne more than one should be adopted or a pcb or make flying connections. We see this figure:
The first matrix is connected to the micro with the classic pin LOAD/DIN/CLOCK: so if it is the only need nothing. From the second onwards connections LOAD/CLK are connected together but the second array (or the third and so on) his FROM It is connected to DOUT of the previous matrix. E’ task of the software correctly target matrices. (Remember the register “zero” ?) . The use of this tiny module facilitates connections:
The inputs are those seen before and the output pin are VCC, GND, LOAD, CLK, DOUT. For the sliding clock prototype or in cascade, I used 4 display accommodated in this pcb:
To the left of the main entrance pin, at the bottom right of the output pin to connect any other matrices. The space of each module is bounded by rectangles in red. Do not miss the VCC pin and GND.
We are having said that we do the first steps for managing. The first operations to be carried out in “setup” of any sketches are: (Henceforth for “DEVICE” identify the chip and “DISPLAY” the single digits or columns of the matrix). All these operations must be performed for each “device” here I'm. It should be noted that when the system is, in most cases, you will have a self-test of the chip that will turn on all the LEDs for which it may be a good idea to carry out these operations before any other otherwise you will have the persistence of LEDs lit.
- Pin assignment of the micro chip as output.
- Make the Shutdown to initialize the chip.
- Set the brightness.
- Set to the coding.
- Set the test mode.
- Set the “Scan Limit”.
All these operations are managed through a function in my library defined as “Led_MX_Init” that sets up the pins, performs initialization and assigns the method “CATHODE” O “ANODO” common. For convenience for debugging of this library I also added (through flag in the init) the ability to view serial output the values to be sent to the records. For the development of the library I implemented a sketch that, serial, set up a dialogue through a menu that allows the execution of all functions of the library for both matrices for display 7 segments.
I had specified that the chip can only manage the display COMMON CATHODE: true to a certain extent because you can also use those COMMON ANODE but the following measures:
- A livello HW: invert the signals DG0 / DG7 interposing a HEX INVERTER (74LS04). In this way ANODES arrives to the correct logic value.
- A level SW: activate the flag “ACMODE” INIT function in the library. In the presence of this activation functions that manage the leds / pixel invert the value passed through the’ special function (Led_Value = ~ Led_Value;).
- At the state of’ art library uses this function only for display 7 segments.
Let us now specifically for each of the clock early prototypes described the methods and tricks used in the development of the same. As it comes to watches it is clear that we need a RTC from which to read the time and date. There are no particular specifications: you can use DS1307 O Ds3231 or the PCF8583 (model vetusto). The only differences are the reading of registers and decoding method. Incidentally I did not use any library for managing these RTC: I access directly to register with the library functions “wire“.
The binary clock: This is the simplest of all others. The sketch manages one device (matrix 8×8) and after initializing the device and checked for proper operation of RTC, executes a loop in the function “loop” reading from the registers RTC time values, minutes,seconds,day, month. As these values are formed “BCD” (the hours 12 They are in binary 0001 0010) no decoding is not required for their visualization. Let's step back: I said that the matrix can be seen as a set of 8 display in which each column represents the 8 segments (7+1) whose encoding is assigned in the register 1 for the column 1, 2 for the column 2 (and so on for the other columns) respecting the coding imposed by the chip (see figure “register data“). So the trick is: for each selection column and then the value is uploaded “famous 12 hours” They are assigned as follows:
And so on for all other columns. And the mask covers the bits whose display is not necessary. It is then to control the chip column by column (from 1 a 8 but if only the specific 1, 2, 4, 5, e 7) and this provides the library function “LEDMTX_Setcolumn” which provide the device number, the number of the column and its value.
The sliding clock: This is more complex than the previous but not complicated and it is only reason on’ algorithm that determines the sliding of the values. It fits into this context another file (Led_Tabel.ino) which is in the form of arrays, what are the binary configurations which must assume the individual columns for the representation of a numeric character (nine to zero) for both matrices for display 7 segments. Now if these displays the configuration is determined and unambiguous, for matrices having available a grid of 8×8 LED / pixel becomes free choice of the developer to configure the various numbers as most pleases.
Here's an example: for segmented display the number zero has the following configuration: 0111 1110. Any decimal point (Segment “DP“) It can be inserted leading to “1” bit 8 or by enabling the flag in the appropriate function. So one byte for each number and the function that performs the display pointed to by the array as a function of the number. (zero tip of the first byte of the array, the second one, and so on).
Different is the system for arrays: In fact, for the same number it takes well 8 configurations, namely one byte for each column. The same number zero is defined as follows: “0,60,98,82,74,70,60,0“. The values are expressed in decimal and configuration is a personal choice. It follows that the function that displays the number must point to the first byte of each series * 8 (“0” * “8” = “0” and pointing to the first byte; “1” * “8” = 8 and pointing to the first byte that configures the number one). Then column / column makes viewing. The figure below is an example of how they can be composed of the characters in the grid 8×8.
Having said this we see what is the algorithm devised by me, to display the values of a clock by sliding from right to left column by column. Sliding is on 4 devices for a total of 4*8 = 32 column: You then create an array of 32 column. I omit the initial part of the setup (RTC, the init 7219 etc) and then in the cycle “loop” you make:
- Reading the RTC registers
- Decoding of hours values, minutes and seconds in order to obtain the individual values of the tens and units. These values are used to point you in the beginning of the character table of the individual groups 8 byte.
- Starting from the value of the tens of hours a routine extracts the relative byte by byte from the table configuration and inserts in position 32 array the value extracted one at a time. Start at this point the array scan from position “zero” displays the contents of the first column of the first device to the left and continues for 32 positions (The devices are 4 connected in series). Once this scanning is it shifts to the left by one position throughout the array, and the cycle begins again with the next byte of configuration. When the cycle is finished 8 bytes it continues with the units of hours until’ of the second unit with the same system. It is thus obtained the sliding effect. But between readings of the other’ RTC and its complete display are lost 2/3 seconds per cycle.
At this point comes in one aspect still not considered in the Display management. As I said the devices are 4 connected in series. Then also to direct the entire device (from first to last) knowing that each command consists of 2 byte (address / value) We need to send a set of bytes equal to the number of the device on which target values and commands:
Or if the device is the fourth sequence is as follows: “0000 0000 0000 xxxx“. (If the device was the first sequence would: “xxxx“)
Dove: “0000” It is the code of NULL OPERATION, “xxxx” is the command to be sent to the fourth device (first right). But the serialization from the fourth group of bytes (in practice the last). The chip receives the first 4 but since bytes in cycle also receives subsequent to zero, sliding the various bytes from one device. To all this it provides a specific function by reading from a table (prepared for 8 device) i 4 values obviously starting from the last. E’ But the same function that determines based on the device number to send many bytes.
Sorry, but it's easier to do than to say. I hope I was clear but CAUTION everything is relative to the first device position to which is assigned the number 1.
The cascade clock: Here we are more complex, from implementation point of view, those persentati until now. I confess that I had some problems in building the right algorithm to achieve the effect that you saw in the movie. Skipping also here the standard operations that are performed in “setup” to go directly to the invention method. Then the cycle “loop” You start reading the RTC values, converting them into dozens of hours and minutes, units of hours and minutes. The seconds are displayed by flashing in the third device from left, lED “DP” of the first column based on the value of the bit “1” seconds. From the movie can be seen as initially all matrices are set with the values, ma, each matrix changes only if the value that should display changes compared to the previous. If every value read from the RTC (tens of hours or minutes, units of hours or minutes) change, then upgrading its display is activated. So every 60 seconds (“circa” because the full display of a matrix occupies a little time) It updates the minutes or hours, etc.. To achieve the effect “waterfall” of the individual LEDs of each column you have to be taken from the table (were produced three so you can change the data source) the single byte (first to eighth) and it starts flashing the first LED (bit 1) per 15 ms, then continue with the second but doing so that said previous LED stays lit (according to the configuration of the character). The zero bytes is skipped. The cycle is repeated until the completion of the eight bytes. When this cycle is passed to the next character until the completion. I 15 ms delay between one flash and the other are a compromise between speed of execution and desired effect. Clearly, the flashing of the seconds will not be accurate especially if they change at the same time the hour and the minute.(gives 23.59 a 00.00).
It is not easy to describe this mechanism, myself even after having produced and modified by adding variable parameters, I can hardly ricomprenderlo (!!!). If you are a beginner in programming, the routines are sufficiently commented to be understood.
The speaking clock: And here's the’ last (hoping in the meantime not to have you bored). I also wanted to mention this in order to make a comparison between different display modules: in this case, pulled out of the drawer of the old stuff but still fully functional, it is the DL2416T a particular display today replaced by DLR2416. Unfortunately, the latter is expensive.
The difference between the two models we can see it with this figure:
The first consists of 4 display a segmenti (14 if I have not counted wrong) while the second is a matrix 7×5. The display characteristics of these, compatible as both pin functions, They can be summarized as:
- 4 digit individually addressable (“00”, “01”, “10”, “11”).
- Device individually addressable (two selection pin)
- Erasable individually.
- Set of special characters, alphanumeric and numeric.
- Automatic multiplexing Management.
- Food 5 a 6V max.
- Cursor Management
- Other features in the datasheet of each.
In the figure below valid for the two models, the connecting pin:
We check: 2 pin for selection (CE1 / 2), 2 pin for the management of the cursor (CUS,CUE), two pins for the selection of digits (A0 / A1), pin CLR cancellation, pin BL for shutdown without loss of values (useful for the blincaggio), 7 pin (D0/D6) and to DATA INPUT, Finally, the pin WE for the writing of the value. A HIGH-LOW-HIGH transition enables the writing of what is set. experienced optimal value: 5us.
then the complexity of connection to two displays (as in the prototype), I had to produce a pcb like this:
I have designed a circuit as said PCB only serves the housing of the two displays by connecting pins in parallel D0/D6 and bringing to connect to “main” i pin A0 / A1, WE, CL1, CL2, BL1, BL2. I pin CUS e CUE in this context they are not used and are set to default values (logic level “0” e “1”). A particular note concerns the pin CL1/2 e BL1 / 2: according to the datasheet for the cancellation of a display or its abblencamento we are independent from the selection of the same display: they can not be (but it is a choice) connected in parallel if you want to delete or turn off the single display. What I expected later in the software. Here instead the pcb on the main board for the micro Arduino_Nano and the two 74HC595.
Let's move on then to the heart of the prototype.
It is clear that given the number of connections (6 per i DATA INPUT) e 9 for commands, They would run out all ARDUINO pin (One or Nano to be leaving out the Mega etc.), so we need a different approach as can be seen in this circuit diagram:
In the chart we can see 2 74HC595 (shift register) where in the first they are defined in the pin outputs D0/D6 relative to the DATA INPUT of the display while in the second the command pin are defined: When / A1, CL1/2,BL1/2, CE1 / 2. The two chips are connected in cascade and according to the rules of the shift register (receiving data in serial to transmit them in parallel). Signal QH that connects to data input the second.
The scheme is related to the first version in that it is not strictly necessary to separate the signals OE, THE, CLK because it takes the signal is individually OE which controls the output Support / Q7 (otherwise they are in high impedance). E’ however my choice the separation of signals. The signal MR (master reset) It serves to reset the chip. The command pin are connected to the Arduino pin; the signal “WE” It is independent from the rest and is attributed to another micro pin.
As for chips 7219 You can be defined “intelligent” because in addition to the shift register function, need of commands for the activation of functions, i 74hc595 I'm “stupid” because they just limited to receiving the serial bits and if these are > 8 pass successive bits to the next chip, and so on. Taking advantage of this system, the algorithm for controlling the display individually may consist in:
- Send to a chip the 8 bits relating to the character configuration (8 always zero bits).
- Send to the next chip of the control bit to select the display configuration and its digit; operations, these, carried out in sequence.
- Stabilize the signals enabling the’ OE the two chips.
- Switch signal “WE” for the actual writing on display.
E’ clear that having to write about 8 digit (2 display per 4 digit) sigole the letters that make up the complete text (as you may have seen the movie) necessary to determine the precise sequence of commands and the character to be sent . In this regard I have constructed the following table.
As you read this table ?. Example: you want to load the display “1” digit “0” with a character: then you are sent to the first chip and the value of the character according to the decimal value chip “62“. The layout bit output (Q0 / Q7) It corresponds to the signals A1 / A0, BL2, CL2, CE2, BL1, CL1, CE1 which I am at logic level “1” (non-operating) or logic level “0” operating. Do not deceive the numbers shown in the table as I have been used to calculate the value correctly when they are zero or one. Another thing to bear in mind is that depending on how the chips have been connected to the signals, and then to display, it is not said that the first chip must necessarily be the one for the data or that for the signals.
Still a little patience: Also we complete this prototype with its software. As you also know in this case it comes to managing a clock. The sketch is not complex but it can be briefly described as follows:
- Solita activation of’ RTC with the usual presence controls and efficiency that in the absence of the system.
- Configuration of the pin connected to the 74HC595 chip.
- In the loop “loop” reading of the RTC values, transcoding of the same and preparation of a string consists of the words “IT'S ” the time values (tens and units) interspersed with a point, then “OF THE ” day value, transcoding of the month and transcoding of the week. So at the end of the string will contain:
- ARE THE HOURS OF xx.xx xx May FRIDAY —-> example. The spaces between one word and another are obtained with the character “00” binary that produces nothing visible.
- After building the string, according to its actual length is inserted into an array d 8 byte position 8, the first character of the string.
- It performs a loop 8 cycles to send the values of the array to 8 digit dei display (set of specific commands to display and digits and data_value).
- It maintains the array of shift 8 bytes from right to left.
- It repeats the cycle.
It is obtained in this way, the sliding effect which the programmed speed of 250ms may be considered optimal for viewing.
CONCLUSION:
I recognize that this article is quite long and probably I describe obvious things and risapute. But from my point of view to see ways and implementation choices, They can always be a good source of information especially for those who are beginners or simply a hobbyist like me.
If then I wrote some inaccuracies, please excuse not.
Thanks for the attention.
GVSOFT May 2018
PS: if you are interested in the sketch and related documentation write to gvsoft75@hotmail.com.
I was seeing things, or in one of the previous crazy clocks there was an explanation of how to decode the DCF77 signal?
I tried the item but can not find it.
No, I've never used in any of the DCF77 mei items.