Electrical – Analyzing 24V fast PWM signal in Arduino

arduinolevel-shiftingpwm

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?

Best Answer

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.