Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

LABORATORY PRACTICE REPORT Version 1.

0
MECHATRONICS ENGINEERING PROGRAM Period 2022-1

Dynamic visualization
Espejo David
{Est.david.espejo}@unimilitar.edu.co
Profesor: Puerto Jorje

Resumen—In this practice we wanted to configure the input row and column are connected through the pins outside –
and output pins of the micro controlled system to perform a pin R1-R4 as labeled beside control the rows, when L1-
dynamic display of the output signals. To comply with this, a L4, the columns. A 4×4 matrix keypad consisting of micro
calculator was developed using a matrix keyboard for data entry
and 5 multiplexed screens for data output. Finally, the reasons switch buttons.How Keypads Work. Pressing a button closes
why a membrane keyboard is not the best option for this type the switch between a column and a row trace, allowing current
of application are given, and all the advantages offered by the to flow between a column pin and a row pin.
use of variables such as flags are also highlighted.
Palabras clave—Keyboard, display, flag, variables, conversion.
II-B. Multiplexed 7-segment display
By multiplexing seven-segment displays the number of pins
I. I NTRODUCCI ÓN required to drive the displays can be reduced. In the scheme of
Figure 4 the segments are driven high by the micro-controller.

I n tools like a micro controller and any system involving it


is very important the space use, for example, for this lab
practice, have 2 or more displays individually connected takes
The required segments for digit 1 are set on lines A to G and
Q1 strobed (turned on briefly). The key idea of controlling
multiple 7-segment displays is to use the same 7 IO output
up too much space and hardware, and this is something that is pins for all the segment lines. And also an additional control
not just in outputs cases, like the displays are, but for get into pin (transistor) to activate each 7-segment unit one at a time.
data exist the same problem. Over the years there have been
different ways to read data inputs but one of the most efficient
ways so far has been the matrix keyboard a circuit made up of II-C. Calculators
an arrangement of buttons in the form of a matrix where it is
possible to precisely locate which button was pressed [1]. It is Calculators (and computers) combine inputs using electro-
usual that eight pins is used to connect the single-chip with 4 nic components called logic gates. As the name implies, a
× 4 matrix keyboard by the method of scanning.but One of the logic gate acts as a barrier in an electronic circuit; it takes
most hardware efficient methods to read a matrix keyboard is in two electric currents, compares them and sends out a new
a method without any other active element is raised. Only one current based on what it finds. The memory chips inside the
pin, four capacitors and four resistances are used to connect calculator contain thousands or millions of bytes of program
the single-chip with 4 × 4 matrix keyboard without any other code that allows the calculator to do the work. In some cases,
chip and active element [2]. However, it is a complex method the chips may contain some information in table form, while
and it is not the one used in the development of this practice. in others, they contain sequences of steps that can be used to
An other thing to solve is the output data optimization, in this get to the answer.
case, with displays, a solution for that is multiplexing. For a
micro controller the code for this goes something like this [3]: III. O BJECTIVES
Program computes a number to display.
Configure the input/output pins of the micro controlled
Program retrieves the 7-bit code from memory.
system to perform dynamic display of output signals.
The code is then sent to the I/O pins or port.
The data is then latched into the register with a control
signal on another MCU output pin. IV. P RACTICE DEVELOPMENT
Number shows up on the display.
IV-A. Displays Multiplication
II. M ARCO TE ÓRICO Displays Multiplication is a different and more efficient
way to show a process and monitoring the different interest
II-A. Matrix Keypad
variables. Exist different ways to do a display multiplexing,
The 4 x 4 Matrix Keypad Module is a non-encoded matrix as can be seen in the figure 1, in this lab has been used 7 PE
keypad consisting of 16 keys in parallel. The keys of each outputs for all displays inputs, a mean, every .aı̈nput of every
displays is interconnected, so the same number is sending to
El presente documento corresponde a un informe de práctica de laboratorio
de “nombre de la materia” presentado en la Universidad Militar Nueva all displays. Also we used 7 PF pins more for the enables of
Granada durante el periodo 2022-1. every display.
How it Works
LABORATORY PRACTICE REPORT Version 1.0
Matrix keypads use a combination of four rows and four columns to provide button states to the host
MECHATRONICSdevice,
ENGINEERING PROGRAM Underneath each key is a push button, with onePeriod
typically a microcontroller. 2022-1 to one
end connected
row, and the other end connected to one column. These connections are shown in Figure 1.

PE0 PE0 PE0 PE0 PE0


PE1 PE1 PE1 PE1 PE1
PE2 PE2 PE2 PE2 PE2
PE3 PE3 PE3 PE3 PE3
PE4 PE4 PE4 PE4 PE4
PE5 PE5 PE5 PE5 PE5
PE6 PE6 PE6 PE6 PE6

PF4

PF3

PF2

PF1

PF0
Figura 1. Display multiplexing

In this way you can make a dynamic visualization with the


help of two vectors, a vector contains the 0-9 numbers code
in every position, but as all displays pins are the same, enable
is used to turn on only the display that corresponds to the
number being sent.
In the figure 2 the number 9801 is observed, where all the
displays are receiving both the number, such as 8, 0 and 1 but
only the displays corresponding to these numbers are turned
on at a very fast speed

Figure 1: Matrix Keypad Connections


Figura 3. Display multiplexing example
In order for the microc ontroller to determine which button is pressed, it first needs to pull each of the
four column s (pins 1-4 ) either low or high one at a time , and then poll the states of the four rows
(pins 5-8). Depending on the states of the columns, the microcontroller can tell which button is pressed.
IV-C. Programming
For example, say your program pulls all four columns low and then pulls the first row high. It then reads
the input states of each column, and reads pin 1 high. This means that a contact has been made
Figure 4 looks how int main work, as you can see there is
between column 4 and row 1, so button ‘A’ has been pressed.
not much work here since most of the work is done in the
interrupts themselves.

Start

4x4 Matrix Membrane


Declare variables Int VectorF, numero, Vector_Numero_1, Keypadidentificador, resultado, Operacion.
Posicion_Vector_numero_1,

Declare variable double ResultadosMDT

Declare variables char Vector_Numero_1[2], numeroC, Resultado_Display[5]

Declare variables char * Resultado_Display_1.

Start GPIO and


interruptions watch.
Configure PD like output and
Pull-up PC like input and
Pull-up.

Figura 2. Display multiplexing example Declare interruptions in 0, 1, 2,


3, 4 and 5 port C pins, remove masks
and an declare on falling edge

Configure a cycle that move by 5 VectorF positions and assign every value to
GPIOD->ODR Interruptions

Yes

IV-B. Matrix keyboard


Reflect vectorF on PD, the 0
vector visualisacion position is always the
number in that instant, reflect to Vector_Visualizacion at its

in the figure 3 it is possible to observe how the rows and position "r" in port E and Vector_PruebaEn at
its position r in port F

columns of a membrane matrix keyboard that was used for


this practice are organized.There are different ways to read a
matrix keyboard, for this practice 4 interruptions were made Figura 4. Infinite while flowchart
with 4 conditionals inside each one in order to cover the 16
possible cases of the keyboard. if a pull down configuration is figure 5 corresponds to the follow chard to the 4 matrix
done on the keyboard buttons and the rows are connected to keyboard column. It can be seen, as mentioned before, that an
a micro controller pin configured as an output, it is possible interruption has 4 cases within itself, in order to achieve the
to vary a 0 between each row at high speed, each conditional 16 cases of the matrix keyboard. Every conditional assigns,
within the interrupt compares the output of the port to which in the case of this column, a code for each operation and
the rows are connected to know the exact position where it this is very important. Since the calculator operates numbers
was pressed, this is seen in more detail later in the subsection with a maximum of two digits, the largest number that can be
with flow charts that explain this process in more detail. obtained is:
LABORATORY PRACTICE REPORT Version 1.0
MECHATRONICS ENGINEERING PROGRAM Period 2022-1

99 ∗ 99 = 9801 (1) Interruption 3, 6, 9, #


The first position of
No Vector_Numero_1 is
equal to numero

Lower pin 2 flag


Vector_Visualizacion scrolls 1
position to the left and the first
Identificador > 0 Yes
numero = 3 become numero in Vecor_Visualzacion position is
the enabled Yes equal to numeros in the 3 position
row is 1 a char variable.

No The first position of


No Vector_Numero_1 is
equal to numero
the enabled Yes
numero = 6 become numero in
row is 2 a char variable.
Vector_Visualizacion scrolls 1
position to the left and the first
No Identificador > 0 Yes
Vecor_Visualzacion position is
Therefore, to shield the system a little from errors, it was the enabled numero = 9, become numero in
equal to numeros in the 6 position

Yes

obtained by providing the following codes for each operation: row is 3 a char variable.

No
The first position of
Vector_Numero_1 is
No equal to numero

Operación = 9805, stock the


the enabled current number value in Vector_Visualizacion scrolls 1
Yes
row is 4 numero_1 and become position to the left and the first
number=0. Become numero_1 Identificador > 0 Yes
Vecor_Visualzacion position is
to a vector, reset identificador equal to numeros in the 9 position

Sum 9802
Subtraction 9803 While a
colum button is Identificador < 2
Multiplication 9804 pressed
No

Division 9805 Yes Yes

Sine 9806 Identificador


Finish {}
Cosine 9807 ++

Tangent 9808
Figura 6. Column 1,2,3 interrupt

In the figure 5 you can also see how when you press a button
that is an operation, the number is stored at that moment in
a separate variable and the first variable is reset to be able to
receive another number.
And in this way in how numbers can be read, as seen in
the figure or know the desired operations.

Start interruption A, B,
C, D

Lower pin 3 flag

The enabled row is 1 Yes Operación=9802

No

The enabled row is 2 Yes Operación=9803

No

The enabled row is 3 Yes Operación=9806

No

The enabled row is 4 Yes Operación=9807

Finish

No

numero=0, turn off all store in number to


The button numero_1 and store in
that gives the interruption displays except the first and
{} Sí numero_1 to
is pressed reset to 0 to
Vector_Numero_1 Vector_Numero_1

Figura 5. Column 4 interrupt


Figura 7. Column 1,2,3 interrupt example

For the case of columns 1,2 and 3 it is quite similar. In 1


and 3 the first three rows correspond to numbers and the last
to signs. As can be seen in the figure 6, the first 3 cases are knowing the operations and the numbers that we are going
for the variable number and the last case is for an operation to operate, we just needed to know the result and view it on
because a symbol is found in that position on the keyboard. the displays, the logic to do this can be seen in 8 figure.
LABORATORY PRACTICE REPORT Version 1.0
MECHATRONICS ENGINEERING PROGRAM Period 2022-1

Start Display vector will be


Resultado
Yes equal to the result
has 1 digit
vector

Division result Transform No


between numero_1 Start a
No variable ?i? in i menor 5 Yes Vector_Resutado
and numero_2 to a char
contains 0
vector
decimals Display vector will be
Resultado
Yes ((i*-1)+1) times the
has 2 digit
result vector
Yes

Become
numero_1 No
and 2 to
double

Display vector will be


Resultado
Yes ((i*-1)+2) times the
has 3 digit
result vector
Operacion=9805 Yes Resultado=numero_1/Numero_2

No No

Operacion=9806 Yes Resultado=sen(numero_1) Display vector will be


Resultado
Yes ((i*-1)+3) times the
has 4 digit
result vector

No

Operacion=9807 Yes Resultado=cos(numero_1)

No

Operacion=9807 Yes Resultado=tan(numero_1)

Figura 8. equal button interrupt

V. A NALYSIS OF RESULTS
Sometimes when one button is press just one time, is
read twice
Sometimes when one number is entered through a ope-
ration button, the number is not save
The multiplexing display was successful
The results are correct

VI. C ONCLUSIONS
A calculator has an error range so low that it can be
taken as zero, it must be such a symmetrical process
that each possible case, indeterminacy or contradiction
must already be foreseen and solved by a generality
specifically for each problem to be dealt with.
Display multiplexing reduces the amount of hardware but
keep in mind that this does overloading the software
The keyboard quality is not sufficient and sometimes read
twice the number.

R EFERENCIAS
[1] Rubasinghe AP. Connect a 4X3 matrix keyboard to a microcontroller
using two I/O pins. EDN Europe. 2013;6:44-45. Accessed March 17,
2022.
[2] Lin, Z & Shi, X 2016, ‘4 × 4 matrix keyboard interface circuit achieved
by single port lines’, Electronics Letters (Wiley-Blackwell), vol. 52, no.
11, pp. 803–805, viewed 17 March 2022
[3] Frenzel, Louis E., Jr. 2020. “APPENDIX B: Solutions to Design Projects.”
Chap. B in Practical Electronic Design for Experimenters. 1st ed. New
York: McGraw-Hill Education. viewed 17 March 2022
LABORATORY PRACTICE REPORT Version 1.0
MECHATRONICS ENGINEERING PROGRAM Period 2022-1

VII. A NNEXES

Figura 9. Dynamic Display of number 9801 with low speeder, number 9

Figura 10. Dynamic Display of number 9801 with low speeder, number 8
LABORATORY PRACTICE REPORT Version 1.0
MECHATRONICS ENGINEERING PROGRAM Period 2022-1

Figura 11. Dynamic Display of number 9801 with low speeder, number 0

You might also like