Encoder Tester - Incremental Quadrature
I use a lot of motors with encoder feedback and also linear glass scales in my CNC machines. And for the latest project, I got a manual pulse giver that pumped out the pulses in quadrature format. Usually I hook the encoder up to some servo controller, preferably my SnapAmp/KFlop combo, but its a lot of work for just checking an encoder, especially when the servo controller is hooked up to some other project.
So, I wanted a quick test device that is very small, partially, because I am thinking of making on-axis DROs in the future. Like this:
So, because most encoders seem to run from 5V, I wanted the board to be 5V compatible. And the Sparkfun ProMicro comes in a 5V flavor.
Together they make a small microcontroller board with a screen. However, one problem with the PmodOLED is that it is not 5V rated. There is a 5V version made by Adafruit using the same Solomon Systech SSD1306.:
But, I have the Digilent units. They have been lying around for a while and I probably won't find a use for them in the foreseeable future. When used as a tester, this screen will not run very long stretches of time on 5V, so maybe it will work for a while. To test this, I ran a PmodOLED on 5V for over 20 hours with no signs of damage. Good for now. If the screen gives up I can replace it, and if the replacement gives up, then I can just get some units from Adafruit, or go with and LCD screen...
It turns out that the Adafruit_SSD1306 Arduino library can drive the Digilent screen just fine. Also there is a well written Encoder library capable of using change interrupts.
The code was, therefore reduced to periodically reading the counter of the Encoder library and outputting it on the screen. In addition I outputted the counter in the serial stream. This way, If the screen breaks or is in an unreadable position, I can always display the data in a serial console.
I made some pieces on a laser cutter to have a case for the tester.
I tested this on two Dynamics Research Corporation linear glass scales, an SST short stroke linear encoder, and a manual pulse generator hand wheel. Both the tester and the devices work great. One great thing about this is that I did not know exactly what the resolution on the glass scales was. With the tester, I could figure that out easily. Move the scale from one end to the other and divide that distance by the count shown on the tester.
originally forgot to post code.
I just got in a BEI MX21 encoder for my lathe spindle and used this tester to check it out:
Works great, but since the encoder is so enclosed, I needed to use an eraser to grab it and turn.
Many encoders are differential, and so we need a modification to the system to allow for testing them. Do do this I used a TI AM26LV32E Differential Line Receiver. This chip is made for 3.3V supply voltage, but its maximum recommended exposure is 6V, and much like the OLED, it seems to work fine at 5V operation.
I superglued it to a small breakout board which has both an RJ45 socket and a screw terminal.
Next, I designed a case with Fusion360.
This then allows for testing of both single ended and differential encoders. For single ended ones one simply needs to connect the inverted channels to Gnd.