I am currently trying to fit a 3d printer head on a cheap chinese CNC mill. So far I have successfully been able to control the fan, heating element (including reading a thermistor) and the feeder motor using an Arduino Uno.

The CNC itself has a terminal that connects to the mill spindle motor. This produces a 24V 2MHz PWM signal meant to control the speed of the spindle motor.

After I install the printer head, I would like to be able to control the speed of the filament feeder motor by using the spindle speed setting of the CNC. For this, I need the Arduino to be able to read the output of the spindle speed terminal.

Now to my question: how is it possible to shift a 24V PWM signal down to 5V so I can read and measure the duty cycle with my Arduino?

My first thought was to use an opto coupler: this seems like a possible way, but my opto couplers (LTV-817A) have a cut off frequency of 80 kHz, so as far as I understand, they are too slow for a 2MHz PWM signal.

What alternatives do I have?

  • 1
    \$\begingroup\$ Are you 100% sure it's a 2MHz carrier frequency for the PWM? \$\endgroup\$ Commented Jan 23, 2018 at 23:26
  • \$\begingroup\$ I'm voting to close this question as off-topic because it is an old abandoned XY problem. Mills make bad 3d printers, and filament feed requires more precision than just rate. There is a whole art and body of knowledge to this you are overlooking in an attempt to duplicate an experiment that might have seemed interesting in the hobby realm 15 years ago when there was little awareness of FDM outside a few companies, but is long obsolete today. \$\endgroup\$ Commented Feb 19, 2019 at 17:55
  • \$\begingroup\$ I agree that the mill is never going to compete with purpose-built printers, be it only because the Z distance it is able to cover is far too small to print anything meaningful. That's why I asked about the electrical problem of processing a PWM signal, which I am sure has other applications outside of 3D printing. The first paragraph of my question was just for context. \$\endgroup\$ Commented Feb 19, 2019 at 21:31

2 Answers 2


My suggestion is:

  1. Low-pass filter the 2 MHz PWM signal to produce a 0 - 24 V DC signal proportional to speed. A simple RC circuit should suffice. At 2 MHz the time constant will be much shorter than the run-up / run-down speed of the motor.
  2. Buffer this signal.
  3. Drive an analog opto-isolator.
  4. Feed the analog output to your micro-controller's analog in.

Step 2 needs to work without loading the filter too much.

Wouter van Ooijen has some suggestions in his answer to Need an optocoupler for getting directly proportional output galvanically isolated from the DC input. In particular the HCPL-7510 linear isolation amplifier looks interesting.


If ground is common between the PWM controller and Arduino then you can just use a resistor divider.


simulate this circuit – Schematic created using CircuitLab

  • \$\begingroup\$ Not at 2 MHz with those values! \$\endgroup\$ Commented Feb 19, 2019 at 17:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.