Recently on Instructables, lingib demonstrated a angle encoder using 10 magnets and 2 hall effect sensors. This project takes this concept and turns it into a usable tool for your workshop.
One of the issues with trying to use the original design is that the arms were not on the same plane. One arm was 9mm higher than the other making it difficult to use. In this updated design, each arm is the same height. All other dimensions are the same as the original design. The extra height gave enough room to fit a microprocessor, OLED display and battery in one of the arms.
To make the final unit fully self-contained, the software has been rewritten to allow you to do the calibration without needing a serial terminal. Calibration settings are stored in EEPROM so there is no need to modify the code after calibration.
The final unit has a single button. Pressing the button will wake up the microprocessor. The splash screen is displayed for 5 seconds. The display shows the current angle and will automatically enter sleep mode if no movement is detected for 15 seconds. It will also enter sleep mode if you press the button.
Holding the button down for more than 3 seconds before releasing it while "Shaft angle" is displayed will enter calibration mode. Rotate the arm back and forth until the number shown is stable. Close the arms and press the button again to record the settings. You should only need to do this once or when the battery has been removed.
DemonstrationHow it worksRather than repeat the detailed explanation by lingib, I recommend you read the Theory section in his Instructable Neodymium Angle Encoder.
3D printingAll parts are printed using a 0.2mm layer height and no supports.
Assembling the angle encoderHammer in a M3 x 4mm x 4mm brass insert into the center hole of "arm.stl".
Using super-glue, glue in the 10 neodynmium magnets. Swap the pole polarity on each adjacent magnet. The image shows north poles marked with red paint and south poles marked in grey paint.
If you have a magnetic field viewer on hand, use it to check that the magnets have been inserted with the correct polarity. The magnetic field viewer should show a flower shaped magnetic field.
The hall effect sensors are inserted flat side down. Cut any extra leads and join the VCC pins of both sensors and the GND pins of both sensors.
Use 30 AWG Wire wrap wire when wiring the up the two OA49E linear hall effect sensors. Run the wires through the provided hole into the PCB compartment.
You can screw both parts together using a 12mm M3 screw. Don't forget to add the spacer between the two parts. The spacer is required between the magnets and the Hall effect sensors to prevent the Hall effect sensors saturating.
Assembling the PCBAs the ATtiny1614 microprocessor only comes in a SMD package a PCB board is necessary. It also supports the switch and OLED display. The Eagle files have been included should you wish to get the board commercially made or you can make it yourself. I used the Toner method to make mine
Start by adding the SMD components. I find it easier to use solder paste rather than use solder from a reel when soldering SMD components. I used my SMD Hot Plate to reflow the solder paste.
Add the links if your board is single-sided and cover the wires with a piece of Kapon tape to prevent any shorts when the OLED screen is added.
Due to the limited space, the black plastic on the header of the OLED module needs to removed so that the OLED screen can sit closer to the PCB. Solder the OLED module onto the PCB and cut off any excess pins.
Add a 6mm x 6mm tactile switch with a 6mm shaft length onto the PCB. Only solder the outer two pins and cut the inner two pins as close as possible to the PCB. This allows you to solder the battery connector to the copper side of the PCB. The socket should sit flat on the PCB.
Solder the sensor wires to their respective pads.
At this point you should program the ATtiny1614. See the next section.
Plug in the 120mA/hr Li-ion battery and screw in the PCB using two 4mm M2 screws.
Glue on the button top ensuring the glue does not run down the shaft and into the switch.
Final add the cover screwing it on using two 6mm M2 screws.
ProgrammingThe ATtiny1614 is part of the new breed of ATtiny microprocessors. Unlike the earlier series such as the ATtiny85, the new breed use the RESET pin to program the CPU. To program it you need a UPDI programmer. I made one using a Arduino Nano. You can find complete build instructions at Create Your Own UPDI Programmer. It also contains the instructions for adding the megaTinyCore boards to your IDE.
Tack some wire to the GND, VCC and UPDI pads and connect them to the UPDI programmer.
Select BOARD: ATtiny3224/1624/1614/1604/824/814/804/424/414/404/...
Select Chip: ATtiny1614
Select Programmer: jtag2updi (megaTinyCore)
Open the sketch and upload it to the ATtiny1614.
ConclusionThanks lingib for publishing a very interesting and highly educational Instructable. It was a rewarding and enjoyable build.
Comments