Random DC Motor PWM Experiments + Encoder Troubleshooting

Introduction: Random DC Motor PWM Experiments + Encoder Troubleshooting

About: What's up everybody?! I am a self-taught hobbyist that loves DIY projects. I like to make food, drinks, décor, repurpose/recycle and some fandom type items. I learned a lot from books, friends, YouTube, and Te…

There are often times when someone's trash is another's treasure, and this was one of those moments for me.

If you have been following me, you probably know that I took on a huge project to create my own 3D printer CNC out of scrap. Those pieces were made from old printer parts and various stepper motors.

This printer carriage came from a Texas Instruments dot matrix printer from the 1980's. Unfortunately I do not recall what the model was but I do have the motor number, 994206-0001. This DC motor is equipped with an encoder as well, which would be helpful to use for modern applications. In my haste to recover this assembly, I only removed it and took a picture of where it was connected.

In this Instructable, I will attempt to see if the motor and encoder actually work and what the pin-outs are for.


DC motor with Encoder

Arduino UNO, NANO

L298N H-bridge

DC Buck Converter

Power supply capable of the associate voltage(s) you may need (an old PC ATX could be a viable option)


PC with arduino IDE



Step 1: A Quick Look at the Assembly

Picture 1 shows the main half of the carriage. It was equipped with the assembly, the motor with the encoder, and the tracks for the old dot-matrix paper feed. I removed the tracks and part of the bottom assembly. The bottom piece I removed was the steel support bar, which was quite heavy, actually (they don't seem to make them like that nowadays).

Picture two shows where J8 (the encoder connector) & and J6 (the motor connector) were removed from the control board. I took a picture of it to school myself on the traces and ICs from the "mother board."

In pictures 3 & 4, you can see the motor and encoder connectors, respectively.

After mapping out the traces on the encoder and reproducing the schematic, I was able to produce my own diagram that I could have readily available. The encoder pin out was the most important thing for me to determine and is the focus of this instructable for troubleshooting. We will see this in the next section.

Step 2: Understanding the Encoder Pin-out

Now, I have to figure out what the pin-out is on the encoder. I arbitrarily marked pins 1 through 8 and I describe them in the last pic. What I hypothesize, from looking at the control board and the traces on the encoder itself, is that pin 1 & 6 are ground & 5 is Vcc (power, 5V). The connection for 2 is blanked off so that is useless and 3, 4, 7, & 8 are the outputs for the diode array.

WARNING: I am making a bold assumption with my test! I connected ground to ground on my power source but then I connect 5 V to the encoder directly. Starting at this high a voltage could feasibly destroy your encoder if you don’t know what the voltage is that it needs (like how I didn’t know). So you may want to start at a lower voltage like 3.3 V.

After connecting my 5 V power source to the encoder pin 5 and ground to pin 1, I stick my multimeter ground to pin 1 and pin 5 to ensure the power is present, pic 2. Then I start testing pin 3, which is what I assumed was one of the photo diode arrays, pics 3-5.
As you can see the voltage cycles from close to 0 V to close to 5 V as I spin the motor shaft. That was a good sign to prove that my hypothesis was correct! I did the same for pins 4, 7, & 8, and got the same results. So now, I have determined what the output pins are for my encoder.

You could do the same with any optical sensor you pull from a printer that you may be salvaging parts from since most don't come with 8-pin connectors. For modern home printers, they seem to be 3 or 4-pin types. HomoFaciens has a great YouTube video on how to determine an unknown pin out for optical sensors.

Step 3: Simple Arduino Sketch for Moving the Motor Back & Forth

Now that I have data for the motor encoder, it is time to see how the motor itself will run. To do this, I wrote a very basic sketch for the Arduino, pics 3 - 5. I define my input for Pulse Width Modulation from the L298N as 'enB.' For pins 3 & 4, I set it up to enable the motor to swap directions, as necessary. This will

A. Turn the motor on

B. Move in one direction for 2 seconds

C. Swap direction for 2 seconds, and

D. Repeat

I just want to test the set-up and functionality and this proved successful (after changing the pulse from 50 to 100, see pic above).

Next sketch ramps up the acceleration, pics 6 - 8. I start PWM from 100 (as determined from the first sketch run) and accelerate to 255. This will

A. Accelerate pin 3 (CW direction) from 100 to 255 on PWM for 0.1 second

B. Decelerate from 255 to 100 for 0.1 second

C. Swap direction, pin 4 (CCW)

D. Accelerate/Decelerate, same as pin 3

E. Repeat

This process is (sort of) seen in the last pic but refer to the video for a better visual.

These basic sketches can be adapted to your DC motor as well. I believe a lot of people use this type of sketch for controlling robots or some other type of rolling apparatus. I just wanted to verify operation and get a better understanding for myself as to whether or not this motor will run.

Step 4: Final Thoughts (for Now)

This is where I would say, Phase 1, is complete.

I know the encoder works and the motor will run with PWM on the Arduino.

Next thing for my ultimate application would be to:

1. Determine the pulse per revolution (PPR) of the encoder for its A & B path, Top & Bottom. I am sure there is a sketch somewhere where I could run my PWM along with a counter for encoder pulses, CW & CCW, but I have yet to find one. (Any comments on where to find an Arduino sketch will be greatly appreciated!)

2. Determine how to operate this DC motor/Encoder on GRBL and inevitably calibrate the axes. (Again, please comment if you know anywhere) I would like to do this with a Microsoft run laptop. I have found some using Linux but that won't help me.

3. Design the machine to operate as part of a whole CNC.

Any thoughts for this goal are definitely recommended if you would like to leave them in the comments section. Thank you for looking and I hope this helps/inspires someone.

Anything Goes Contest

Participated in the
Anything Goes Contest

Be the First to Share


    • Photography Challenge

      Photography Challenge
    • One Board Contest

      One Board Contest
    • Jewelry Challenge

      Jewelry Challenge