In this Instructable we will be expanding on what we learned last week in the hall effect introduction Instructable. We will use the hall effects on two actuators to synchronize the motion of the actuators. We will track both counts, and if the counts get too far apart, one actuator will slow down to equalize positions. This is Part 2 of a 3 part series. Last week we covered the basics of interrupts and hall effect sensors and next week will will cover more advanced PID control.
Part 3: Coming Soon!
For this Instructable, you will need:
- Arduino Due (The Due is needed for extra interrupt pins)
Let's get started!
Step 1: Hardware Setup
The first thing that's different from part 1 is that we are using an Arduino Due. The Due has 2 processors on it, with one that is dedicated to interrupts. This allows us to attach interrupts to any pin as long as we initialize it correctly in the code. The Due also is needed if you are synchronizing more than 2 motors. The encoder counts are too fast, so if you have more then 2 motors supplying pulses, you will need the Due's faster processor to not miss counts.
The second difference is that we're using a bigger power supply. Check the power consumption of all the motors you are controlling and ensure that the PSU can provide enough current. There was also be a much larger start-up current to accommodate for multiple motors.
We need to wire the hall effect sensors the same way we did in Part 1. We are only going to use 1 hall effect signal per actuator.
Wire them as follows:
- Red wire to 5V
- Black wire to GND
- Yellow wire to Arduino interrupt pin
- Actuator red wire to MOTA of the MegaMoto
- Actuator black wire to MOTB of the MegaMoto
Check the beginning of the code in the next step, and ensure that the jumpers on the MegaMoto are set to the correct pins and that the hall effect sensors are set to the correct pins. Ensure that "hall0" and "hall1" correspond to the correct MegaMotos (PWMA0 and PWMA1, respectively).
Once the motors are wired correctly to the boards, wire as follows:
- Connect 12V to BAT+
- Connect GND to BAT-
- Connect 12V to Vin on the Due
- Wire two buttons between pins 7 and 8, connecting them to GND