Skip to content

Matrix

MATRIX

Type Function module
Input X1 .. X5 BOOL (line inputs)
Output CODE Byte (output for key code)
TP BOOL (TP is TRUE for one cycle when a new Key code is present)
Y1 .. Y4 BOOL (line outputs)
MATRIX is a matrix keyboard controller for up to 4 columns and 5 rows. With each PLC cycle on the MATRIX column switch the output further for a column so that the lines Y1 to Y4 are queried one by one. For each column, the row inputs X1 to X5 are queried and if a button is pressed, the corresponding key code is displayed on the output. The output of TP is a cycle set to TRUE if the output CODE indicating a new value. If the setup variable RELEASE is set to TRUE, then for pressing and releasing a button each sent a key code. If RELEASE is set to FALSE, a key code is generated only when a button is a pressed. The key code of the output is as follows
The matrix controller is wired as follows
This simple circuit can analyze up to 20 (4 * 5) keys. However, it should be noted here that only in cases a number of keys can be pressed simultaneously. The controller can handle with this circuit, several buttons in a column in any doubt, but not when keys are pressed simultaneously on different columns. The wiring may be extended by each button is decoupled via diodes, and thus the influence of different columns to one another is prevented. In the circuit with diodes, any number of keys at a time and be evaluated safely. The outputs of the matrix controller continuously scan the rows of the keyboard matrix. On every PLC cycle one line is read. If in a row more keys have been pressed or changed, the changes are displayed as codes of the following cycles. The module stores the individual key codes and gives each cycle consisting of only one code so that no code can be lost.

| The following timing diagram shows the scanning of rows of keys | | | Setup RELEASE | BOOL (a key code when you press and release of a key generated) |

matrix

matrix_schema matrix_trace

Bit CODE Output
7 1 when key is pressed, 0 when key is released
6 Line number Bit 2
5 Line number Bit 1
4 Line number Bit 0
3 Always 0
2 Row number Bit 2
1 Row Number Bit 1
0 Row Number Bit 0