AS5600 enclosure
Recently I've bought 4 pieces of AS5600 "12-Bit Programmable Contactless
Potentiometer" as it is
defined by AMS in their corresponding datasheet.
It's a cute magnetic encoder soldered on a small footprint PCB
and it's pretty affordable,
costing just 1.57 Euros per unit, as you can see on Aliexpress listing.
The reason for the purchasing was to give a try to this kind of encoders that
can offer an angle reading of 0.0878... degrees or 360 degrees divided by 4096
readings.
Cool, huh? And it's an absolute encoder, meaning that
it's keeping the reading even after a power cycle (on-off-on).
Getting
back to the item received from Aliexpress, the package contained the PCB with
the actual encoder soldered, a cylindrical magnet and a 7 pins header for
connection.
After soldering the pins on the PCB and powering this
baby up using an Arduino Uno programmed with the example
sketches found in the library, I realized that the cylindrical magnet was rubbish and had to choose
another type of magnet.
Luckily, I've found an industrial grade
magnet used also in an application with magnetic encoder that worked flawlessly and provided stable readings on the serial
monitor.
Doing tests in an improvised manner it's not the best way
to have good results, so I've designed a contraption able to keep the magnet
at 1-2mm above the encoder chip.
To have a better stability on XY axis, I've used 2 604 ball bearings (ID 4mm OD 12mm) I had laying around, together with an M4x18 bolt. To connect the magnet pin to the bolt, I've printed a small adapter part and fixed the magnet on the bolt head by friction.
The encoder PCB was fixed in place with 2 M3 bolts and the results looks like
you see in the picture below.
Having awesome results with this setup, I carried on and made a second design for a more professional looking enclosure that can be used in a real application, such as a robot, a servo, or I don't know...whatever situation you think an encoder would have a good use.
Based on industry grade encoder designs, I wanted to have an enclosure that could be bolted on a mechanical assembly and be actuated by a flexible but play free linkage in order to provide good measurements.
The shape of the whole encoder assembly was choosen to be round, with 4 M4 threaded mounting holes around the input shaft, which is a M4x18 hex bolt.
The bolt is centered by 2 604 ball bearings press-fitted into the main 3D printed housing and retained in position by an M4 nut.
In order to have the magnet held on the makeshift encoder shaft, a 3D printed part with a M4 threaded hole on one side and another 3mm hole in the other side was used.
The magnet was press-fitted on the 3mm side after the 3D printed part was screwed on the remaining threads of the M4 bolt.
Encoder PCB was next to be mounted on the enclosure making sure the magnet can rotate freely without any constrain caused by the lack of gap between the magnet and encoder chip.
Wrapping up. Well, as noone wants the pin headers exposed I've thought that a snap-fit terminal cover would be a good idea to make the whole assembly look professional. So I've cut the whole encoder case, made some extrusions, designed some snap-fitting legs in order to make the end cap to interlock with the main encoder housing.
As I said before, I've used the AS5600 library example sketch which was enhanced a little bit using the FastMap library, because we need to map the values from 0 to 4095 in order to have a human readable value from 0 to 359 degrees.
By using FastMap library, should be easier to implement a PID controller that can react faster.
Here's the code:
#include "FastMap.h" #include "AS5600.h" AS5600 encoder; volatile double pie; volatile double x; FastMapDouble mapper; void setup() { Serial.begin(115200); } void loop() { pie = encoder.getPosition(); mapper.init(0,4095,0,359.99); x = mapper.map(pie); Serial.println(x, 1); delay(1); }
Here's the result of what the code above does.
Final thoughts.
As you could probably see, there are some interesting design choices made for this project to work.
One of them is the output shaft 3D printed part. For proof of concept it's useful, but for a real application, I'm going to design a gear or some sort of linkage to connect the encoder to a mechanical system that needs to send position feedback.
Another design choice is the magnet used in my particular case. If you can find a good quality diametrically polarized cylindrical magnet, you shall definitely give this encoder a try.
However, you can make your own modifications in order to have the best results.
I will try to make the design files available and make them in such way for you guys to be able to recreate and use elements of this project for your needs without constrains.