0:09
hello and welcome to controllers Tech
0:12
today we will continue with our project
0:15
where we were interfacing the dot matrix
0:19
32 in the previous video we saw how to
0:22
connect a single dot matrix display via
0:24
the SBI how to figure out the correct
0:27
configuration for it and finally how to
0:29
display the numbers and characters on it
0:32
today we will cover how to Cascade
0:34
multiple displays together this is how
0:38
the four dot matrix displays are
0:40
cascaded together all the connected
0:43
displays will be powered from the same
0:47
pins we also have the common data Cs and
0:51
clock pins for all of them when used in
0:55
Cascade mode the display where the input
0:57
pins are available is treated as the
1:00
last in number so this is the fourth
1:03
display this is the third second and the
1:06
one on the rightmost end is the first
1:09
one in the previous video we saw how my
1:12
display was accepting the
1:14
data this particular row is the column 1
1:18
register then column 2 column 3 and this
1:23
register if we continue going with this
1:26
logic then this is column 9 column 10
1:30
and this makes the last row is column
1:32
32 although there is no such thing as
1:37
register so column 9 is basically the
1:39
column one of the second
1:41
display column 16 is column 8 of the
1:45
display similarly columns 17 to 24 are
1:49
the columns 1 to8 of the third display
1:52
and columns 25 to 32 are the columns 1
1:55
to8 of the fourth display when we will
1:58
write the data in these cast sked
2:00
displays we will write it like this now
2:04
there is no issue with writing data in
2:06
this manner but the issue might appear
2:09
scrolling to keep things simple I am
2:12
going to call them rows from now
2:14
onwards let's assume that these two LEDs
2:17
in the last row are set to scroll this
2:21
data to the left we need to reset the
2:23
first LED and turn on the other one
2:27
since our data is written as per these
2:29
rows we have to do it individually for
2:31
each row this can be done by Shifting
2:35
the data for each row to the right by
2:38
place well this is because our lower
2:40
data is towards the left side still it
2:44
is manageable to do it for all the
2:47
rows but when the scrolling will cross
2:49
the boundary it will be hard to
2:52
manage we need to remember the previous
2:54
state of the first LED and then modify
2:57
the last LED in the next display
3:00
now imagine doing it for the entire
3:04
displays I am not saying it is not
3:06
possible it is just a lot of work
3:10
instead of doing it rowwise we can
3:12
achieve it easily by arranging the data
3:15
columns let's say we have some data in
3:18
this column to scroll the data to the
3:21
left all we need to do is copy the
3:24
content of this column to the other one
3:27
then again copy it to further left
3:30
when we do it multiple times it will
3:32
have an effect that the entire column is
3:34
scrolling left to arrange the data in
3:38
the column form we will Define a buffer
3:40
of 32 bytes where each column will store
3:43
a data byte for the particular
3:46
column here is the previous project we
3:49
worked on so let's continue to modify it
3:53
we will first Define the number of
3:56
cascaded then Define a column buffer to
3:59
store a bytes per device these eight
4:02
bytes will contain the data for eight
4:05
columns this way we have a buffer which
4:07
can store the data for all the LEDs on
4:10
the cascaded display before we go ahead
4:13
with the ways of writing the data let's
4:15
see how to initialize the
4:17
displays this is the initialization
4:20
function from the previous tutorial but
4:23
now we have four different displays so
4:26
the initialization needs to be done for
4:28
all of them the way we do it is we send
4:31
the same command to all the four of them
4:34
this part in the function where the
4:36
16bit data is sent we call it four times
4:41
note that the Cs pin will go high only
4:43
after the command has been sent to all
4:46
displays this way the command is latched
4:49
to all the displays let's rename these
4:53
functions so there is no change in the
4:56
initialization sequence except that we
4:59
need to send the same command to all the
5:01
connected displays all right sending
5:04
command is easy but the data is not sent
5:07
like this this part is going to be a
5:10
little confusing so pay attention even
5:13
though we are storing the data in the
5:15
column form the data still needs to be
5:18
sent in the rows this is how my display
5:21
accepted it in the previous tutorial and
5:23
this can't be changed now our first
5:26
concern is changing the row data to the
5:29
row form the next issue here is even if
5:33
we manage to change the data into the
5:35
row form how will we write the data to
5:37
the 15th row or 20th row we know that
5:41
the rows are numbered between 1 to 8 and
5:44
it is the same for all the four
5:46
devices here is the actual data sheet of
5:51
7219 if you take a look at the registers
5:54
you will notice that we have covered all
5:56
the registers starting from 1 to 15
5:59
except the register zero the register at
6:02
the address Zer is the no operation
6:05
register and it is specifically used in
6:08
the Cascade mode here is an example of
6:11
how to use this register let's assume
6:14
that we want to write some data to a
6:16
particular row or column of the fourth
6:19
device then we need to First send three
6:22
no operation commands and then send the
6:24
data word for the fourth device all this
6:28
must be done when the C s pin is still
6:30
low when the pin goes high the first
6:34
three devices receive the no operation
6:36
command and the fourth device will
6:38
receive the data let's write a function
6:41
to handle this the max right function
6:44
takes two parameters the row number
6:47
which can range from 1 to 32 and the
6:50
data bite inside this function we will
6:53
first calculate the target device based
6:57
number looking at the device picture
6:59
again this is Row 1 Row 8 row 9 row 16
7:04
and let's say that we want to write the
7:08
18 this Row 18 is actually row two in
7:12
device two this calculation will give us
7:15
the output two indicating the target
7:18
device then offset is basically the row
7:21
from where the data bites for the Target
7:23
device is starting in this example the
7:26
offset will be 16 as this is where where
7:29
the device number two starts then we
7:32
will pull the Cs pin low and send the
7:35
data to all the four devices if the
7:38
device is the target device then we will
7:40
send the actual data word otherwise send
7:44
the no operation command for the Target
7:47
device we will first prepare the 16-bit
7:50
word which consists of the row address
7:52
and the data itself the row minus offset
7:56
will be two in this example and this is
7:58
exactly where want to write the data
8:01
this for Loop will run as many times as
8:03
the number of devices we have defined so
8:06
the other devices can receive the no
8:08
cooperation command finally when the Cs
8:12
pin is pulled High the data or no
8:14
operation commands will be latched in
8:16
the respective devices we will quickly
8:19
test this before proceeding ahead inside
8:23
the main function initialize the display
8:26
then call the max right function to send
8:29
some data to the 18th row here I am
8:32
sending the data zero to some other rows
8:35
so that the data in the 18th row is
8:39
identified let's build and Flash it to
8:41
the board ignore the data on the rest of
8:44
the devices as they will receive no
8:46
operation commands so there will be no
8:49
change in them note that row 17 and from
8:52
19 to 22 all are zeros and Row 18 has
8:57
the data we sent we sent the data 47 hex
9:01
and this is exactly what we have on this
9:03
row let's try sending the data 53 hex to
9:07
19 you can see that we have got the data
9:10
on the row as expected let's try
9:13
displaying the data on all these rows we
9:17
have got the data just as we entered in
9:19
the respective row so everything works
9:22
as expected the max right function is
9:25
able to write the data to the respective
9:27
row as I mentioned earlier we will focus
9:30
on writing the data columnwise so that
9:33
it will be easier for us to scroll it
9:36
but the issue is that the device accepts
9:38
the data according to rows and not
9:41
columns so we need to convert the column
9:44
data to row form let's open our
9:47
character generator again this time we
9:50
will configure it with column major and
9:52
big endian now let's draw the number
9:55
three on it and generate the data for it
9:59
the data is in the column form starting
10:01
with this column here this is column one
10:05
and it has the data zero then column 2
10:08
has the data 22 hex which is arranged
10:11
from bottom to top you can understand it
10:14
better with the third bite 41 hex the
10:18
first four bits are one and the last
10:20
four bits are four so two things are
10:23
clear from here the columns are
10:25
increasing from left to right and the
10:28
data byes are arranged from bottom to
10:30
top but we will send the data in such a
10:33
way that the columns should increase
10:35
from right to left doing it is simple we
10:39
just need to send the data in the
10:40
descending order with the most
10:42
significant bites sent first this
10:45
picture shows how our data is going to
10:48
be the columns will increase from right
10:51
to left but the data is Big endian so it
10:54
will be arranged from bottom to top one
10:57
thing that is fixed is that the device
10:59
accepts the data in the row form and the
11:01
order will be from left to right so now
11:05
we need to change our column data to the
11:07
row form to do that we will take the
11:10
First Column extract its zeroth bit and
11:13
store it in the seventh position of Row
11:15
one then extract the first bit of column
11:18
one and store it in the seventh bit of
11:20
row two then the second bit of column 1
11:23
will be placed to the seventh position
11:26
of Row three this way the entire column
11:29
1 will be extracted and placed to the
11:32
seventh position of all the rows then we
11:35
will extract the bits from column 2 and
11:37
place them on the sixth positions of all
11:39
the rows that is how all the column data
11:43
will be converted to the row data which
11:45
can be then sent to the
11:49
display here is the flush buffer
11:52
function which will flush the entire
11:54
column buffer to the display inside this
11:57
function we will Define a new row row
11:59
buffer where the converted data will be
12:02
stored we have 32 rows in total
12:05
therefore this buffer will also be 32
12:07
bytes of data this function has two jobs
12:12
it will first convert the column data
12:14
buffer to the row buffer and then it
12:17
will send the row buffer to the display
12:20
let's understand the conversion part as
12:22
it is going to be a bit more
12:24
complex here we will call a for Loop for
12:27
all the 32 bytes of the column data I
12:30
will explain this part in a while now we
12:34
will call another for Loop to extract
12:36
each bit from the data bite now we will
12:39
take the First Column to extract the
12:41
data from in this column we will read
12:44
the zeroth bit which is this one right
12:47
here then we take the first row of the
12:49
row buffer and store the extracted bit
12:52
at the seventh position ignore the rest
12:54
of the things mentioned here I will
12:57
explain them in a while so we are
12:59
storing the zeroth bit of the First
13:01
Column to the seventh bit of the first
13:03
row now the J Will increment to one we
13:07
are still working on the First Column
13:10
and now we will extract the bit one of
13:12
this column it is this bit right here
13:16
the J value is one so row two is
13:19
selected and we will store the bit into
13:21
the seventh position of this row this
13:24
Loop will run till the J value is seven
13:27
and we have extracted all the bits from
13:29
column 1 and stored them at the seventh
13:31
positions of all the
13:33
rows now I will increment to one and
13:38
selected here we will extract the zeroth
13:41
bit and store it at the sixth position
13:43
of Row one this is where this I comes
13:47
picture since the value of I is 1 7 - 1
13:53
6 so we will extract all the bits from
13:56
column 2 and store them at the sixth
13:58
positions of all the
14:00
rows then I will increment to two and we
14:03
will extract the bits from column 3 and
14:06
store them at the fifth positions of all
14:08
rows similarly when I will be seven
14:12
column 8 will be extracted and the bits
14:14
will be stored at zeroth positions of
14:16
all the rows this will complete the
14:19
extraction of all the data for the first
14:21
device now we will start extracting The
14:24
Columns of the second device when I will
14:27
be equal to 8 we will be extracting the
14:30
ninth column this value of device will
14:33
be equal to one the dev is one and I is
14:37
8 hence the IUS 8 will give us zero and
14:40
we are basically storing again at the
14:42
seventh positions but the rows are from
14:44
9 to 16 this time so this is how this
14:48
entire Loop will work and we will
14:50
basically convert all the column data to
14:52
the row form note that the data stored
14:56
in the row form start from element zero
14:59
but the device expects the address from
15:01
one therefore the address is passed from
15:03
one but the data starts from element
15:06
zero we are calling the max right
15:09
function to pass the address and data it
15:12
will then pass the row data to the
15:14
Target device and no operation to the
15:16
rest of them Let's test if we are able
15:20
to use the data column
15:22
wise I will display this number which is
15:25
arranged in column major and big endian
15:29
let's copy this array to our main file
15:33
we need to pass the data from the end
15:35
because this is how we have programed
15:43
things but the data generated here is
15:46
starting from this row so when storing
15:50
the data into the column buffer we will
15:52
start storing from the seventh
15:54
bite also note that I am storing the
15:57
data into the first eight bites of the
15:59
column buffer so we will see the data in
16:02
the first device only Now call the
16:05
function flush buffer to flush the
16:07
column buffer to all the
16:09
displays let's also write a function to
16:13
display inside this function we will
16:16
write zeros to all the bytes in the
16:18
buffer and then call the function flush
16:21
buffer to flush these zeros to the
16:24
display let's clear the display after
16:27
initialization so that we only we have
16:29
the number three on the
16:30
display all right let's build and Flash
16:38
board you can see the number three is
16:41
being displayed on the first
16:43
device the rest of the devices are blank
16:46
as we cleared the display after
16:49
initialization so storing the data in a
16:52
column buffer works well we will not
16:55
display this number in the middle of the
16:57
device so that half of it will display
17:00
device this is to check if the data is
17:03
able to cross the device boundary or
17:06
Not Here I Am displaying it starting
17:10
six let's flash it to the
17:18
board we didn't quite get what we were
17:21
expecting here this is because the I
17:24
value is greater than seven and hence
17:26
there are issues because of it let's
17:29
define another index variable with the
17:31
start value of zero and we will pass it
17:34
instead of the I value all right let's
17:36
flash it again to the
17:40
board you can see the number three is
17:43
being displayed on two separate devices
17:45
now so the column data able to cross the
17:48
device boundary without any issues we
17:52
were able to display the data according
17:55
columns this will be helpful in the next
17:57
video where we we will scroll the data
18:00
on these devices we will program the
18:03
functions to scroll a single character
18:05
and an entire string this is it for the
18:08
video you can download the project from
18:11
the link in the description leave
18:14
comments in case of any doubt keep
18:17
watching and have a nice day ahead