Understanding the hall sensor input matrix
We're using "multiplexing" to read our grid of 16 hall effect sensors.
This means we don't need to use 16 individual input pins for reading inputs (which would just about max out an Arduino, and would be too many pins for a NodeMCU ESP8266 type microcontroller).
Instead, we split our grid into "rows" and "columns".
Then we activate each row, and read the values from each column. This means we need four i/o pins for the rows (outputs) and four i/o pins for the columns (inputs). Let's look a little closer....
Each hall sensor needs power (3.3v-5v supply) a ground connection and has a "floating" signal pin.
When a magnet is presented to the sensor, the signal pin is forced "low" (to ground).
When the magnet is removed, the signal pin is left floating (note, it is not driven "high" but allowed to "float" to whichever default value we want it to take - the technical term is "open drain" but we don't need to worry about that right now).
Because the signal is "open drain" and isn't driven both high and low, it means we can connect multiple signal lines together without fear of damaging any of the sensors if there is a "clash" (if driven both high and low, and one sensor was driven high and another low, this could cause damage to the hardware - by driving them low and then allowing them to float, we may get corrupted data if we read the devices incorrectly, but we won't damage the hardware).
So let's say we put power on just the first column (closest to the left). If we get a low signal on the first row, it can only be sensor number one that generated the signal (the signal pins on sensors 2, 3 and 4 would be "floating"). The only active sensor on the top row is sensor number one; so if there's a signal on top row, it ca only have been generated by sensor number one.

Comments
Post a Comment