Laser engraver control: PWM and digital potentiometer

Hi!

For abour a year I've been working on improving my chinese laser engraver and it's now time to upgrade the controller.

My plan is to run the whole shebang with the following setup:

  • Arduino UNO running GRBL 0.9
  • Protoneer GRBL shield ver 3.0
  • My own middleman-board with 6N137 optocouplers to control Laser on and cutting-power

The hardware is working like a charm but I've run into a problem with the cutting-power control.
The PSU of the laser can take either a variable voltage between 0 and 5V or a PWM input to control the power of the laser.

Every forum post or blog article I've found about these laser engravers and their PSUs says that the frequency of the PWM needs to be 21KHz or close to that.

First off, I would like to know if a lower or higher frequency could make a difference or even destroy the PSU?
When experimenting with the timers (timer2) of the Atmega328P i managed at one point to get close to 21KHz but got a very low resolution when setting spindle speed.
Since then i have come up with a few different solutions that i would like to get some feedback on.

Solution 0 - Ditch the optocouplers:
Would it be safe to ditch the optocouplers and control a digital potentiometer directly from the UNO? Maybe there's some semi-safe protection to add with resistors or diodes?

Solution 1 - Seperate PWM circuit:
I could build a seperate PWM circuit with the right frequency and control it with the PWM signal from the UNO. I was thinking of using an Attiny85 or perhaps a good old 555. It seems a bit stupid to control a PWM-signal with another PWM-signal though.

Solution 2 - Variable Spindle SPI output to digital potentiometer:
When not being able to get the right frequency from the UNO i thought of using a digital potentiometer to vary the voltage into the PSU instead. This would be fairly easy if it wasn't for the fact that i want to isolate the two circuits. The digital pots i bought is controlled via SPI and i need a few more optocouplers to make it work.

Solution 3 - PWM to voltage with LPF:
http://www.instructables.com/id/Analog- ... o-Voltage/
I believe this solution is the cheapest and easiest to get what i want with the current setup but I'm not 100% sure. Any thoughts?

Since i'm not that good with electronics, all ideas and thoughts are welcome.

// Parre