summaryrefslogtreecommitdiffstats
path: root/content/zettel/5a1a.md
blob: aca3fe784b875ba6eb18ec39ada6177ee6ae3843 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
+++
title = "Matrix scanning"
author = "Yann Herklotz"
tags = []
categories = []
backlinks = ["5a1"]
forwardlinks = ["5a1b"]
zettelid = "5a1a"
+++

The main idea of how the keyboard circuit works together with the
embedded processor, is that instead of requiring an IO pin for each of
the keys on the keyboard, it instead really only needs one IO pin for
all the keys in the matrix. The keys are placed in a matrix circuit such
that when a key is pressed, the columns of the matrix can be scanned
sequentially to figure out where the key is.

This can be done, for example, by connecting all the keys, which are
also switches, into on column with the other keys, and then also
connecting the keys in the same row together. To then identify if a key
has been pressed, the micro-controller has to scan all the rows and
columns. This is done by setting all the columns to high sequentially,
and then scanning which rows receive that signal. This means that one
can then get a matrix representation with a bit set for each key that
has been set.

However, there are situations when keys can be ghosted, where pressing
three keys connects all the lines in the matrix, which means that it
then is not possible to distinguish a key from the others. The larger
the matrix, the more often keys can be ghosted. To solve this issue, we
therefore have to stop current from flowing backwards in the matrix,
which is the original cause of the ghosted keys. This can be done by
adding diodes after each key, before the key connects to the row. This
means that ghosted keys are therefore not possible, as the only way to
go from one row to the other is if the switch in the current row is set.