For quite some time now I wanted to update my CNC with a MPG to control the X, Y and Z axis.
Sure, you can buy one from Banggood and friends for less than 20 EUR but it is more fun to build one yourself.
I had a number of ideas for detecting the pulse:
1. a rotary encoder
2. ball mouse encoder wheel and sensor
3. optical mouse sensor
4. hall sensor
Option 1 is the easiest, directly followed by option 2, but easy is no fun. The 3rd option is more challenging. I have a optical mouse sensor (ADNS-5030) that I saved from a old mouse years ago. But the thing with this sensor is that, since it uses a SPI bus, it will also require some microcontroller. The other problem is that it is BIG (36x25mm, including the required lens and led). That left me with my 4th option, the hall sensor, so here goes.....
I finally got around re-designing the base plate. As I indicated in my last post, it needed to be a bit higher and it needed some hole to mount the MPG. What I also wanted to do was to create a custom PCB for attaching the hall sensor and the wires. It was a while back since I using EagleCad and was pleased to find that this was now owned by Autodesk and integrates nicely with Fusion360. I created a PCB in fusion in the shape of the space underneath the MPG and linked this to EagleCad. After I was finished with designing the PCB in EagleCad, I used FlatCAM and AutoLeveler to generate the G-Code. A couple of tests (read failures) later I was able to get a reasonable PCB using one of my cheap 60 degree engraving bits.
Even under the microscope it looks pretty, no rough edges at all.
When I mounted the hall sensors I noticed that I had the pins of the sensors swapped, so back to EagleCad. Since I needed to change things anyway, I also moved and rotated the pads for the wires.
So, all I now need to do is make 2 more and I can start using my very own MPGs :)
Today I did the first integration test and it works :)
My CNC machine is running LinuxCNC, originally I only had one parallel port and all the inputs where already used. I bought a cheap PCI parallel port card from Banggood and this just worked out of the box, no driver updates, no kernel re-compile, nothing.
Since the parallel port doesn't have a 5V line, I used power from one of the USB ports and connected everything using jump wires and a breadboard.
The LinuxCNC manual describes how to configure the HAL. There are a number of modes and scale settings and I not sure which I prefer yet. The video below show me experimenting with different scales and mode settings.
I need to do some re-designing of the base plate, is at the moment it is to low to fit wires, and I also like to add some mounting holes.
Originally I was planning to use 32 magnets, giving me 128 pulses per revolution. I tried some test prints and came to the conclusion that this was a bit overkill, eventually I continued with 16.
To give some tactile feedback, I added a clicker that clicks on every quadrature step. The clicker consists of a (round) track of 64 shallow (0.4mm) pockets in the base plate and a 4mm spring loaded ball in the dial.
The most common way of detecting pulses & direction is to use quadrature encoding, this is where the pulses are shifted 90*. So how to you create this type pulses with a hall sensor and magnets?
There are a number of types of hall sensors: unipolar, bipolar
switch and bipolar latch, and it is the last one that is ideal for creating a quadrature signal. A bipolar latch hall sensor switches on when it detects one magnetic pole (lets say north) and it switches off when it detects the other (south) magnetic pole. So when you create a circle of magnets with alternating north and south poles facing the sensor, the result is a signal with a 50% duty cycle (when the rotation speed is stable).
I used my 3d printer to create a small disc with 32 (2 mm) holes and I glued in 8 teeny tiny neodymium magnets. I also printed a base for the disc spin on and to hold the hall sensors in place. The sensors are offset by 28.125 degrees (360 / 32 = 11.25, (2 * 11.25) + (11.25/2)), so that when one sensor is directly underneath a north pole, the other one is halfway between a north and a south poll.