In this Instructable we will be learning how to use interrupts on the Arduino to track the hall effect sensors in a motor to track position. This is Part 1 of a 3 part series, next week we will learn about synchronizing the speed of two motors so they move together and in the third part we will cover more advanced PID control.
Part 3: Coming Soon!
For this Instructable, we will need:
- MegaMoto motor control shield
Let's get started!
Step 1: Hall effect sensors
Hall effect sensors measure the strength of a nearby magnetic field. By attaching a magnet to the shaft of the motor, the sensors can detect when the shaft is parallel to them. Using a small circuit board, this information can be output as a square wave, which can be counted as a string of pulses. By counting these pulses you can keep track of how many times the motor has spun and how the motor moves.
Some hall effect boards have multiple hall effect sensors on them. It is common for them to have 2 sensors (A and B) at 90 degrees. By counting these pulses and seeing which comes first (A before B, or B before A) you can tell the direction that the motor is spinning. Or you can just monitor both sensors and get more counts for more precise control.