Variable PWM TTL via Arduino?

So to start, I have an old (manufactured in 2004) 40W CO2 laser from an engraver that requires a PWM input to initiate lasing. It used to be digitally controlled with a software suite and proprietary hardware, but those items no longer function. Id like to begin making my own engraver starting with the laser. Digging up the users manual, I need to provide a TTL signal (nominal 0v low/5v high square wave, 5mA, @5kHz with a 95% duty cycle) for modulated operation. 95% duty is the max for this mode, but the internals will accept down to 0/1% for intensity control. Can I try to save a couple of thousand dollars by providing this signal with an Arduino? I'm looking for something along the lines of a physical knob to control PWM, since the X/Y axis control options I'm looking at for the engraving surface won't be super fancy either. Can someone point me in the right direction?

I'm looking for something along the lines of a physical knob to control PWM

I get knobs, wood, brass, and ceramic, at the hardware store. I have the feeling that you have something different in mind.

More like a potentiometer.

You can use a pot to adjust a PWM signal.
I have made 20KHz signal using blink-without-delay, 5 KHz is 4 four times slower, 200uS period.
Every 200uS, you change the output from low to High, then bring it low again based on the pot reading from 0 to 1023.
Since an ADC reading takes 110uS, you could take a reading and use it to adjust the High time of the following cycle.
Or use a faster external ADC with SPI reads and apply them immediately after a rising edge.
Use direct port manipulation to toggle the IO for fastest results.
How much granularity did you want?

CrossRoads:
You can use a pot to adjust a PWM signal.
I have made 20KHz signal using blink-without-delay, 5 KHz is 4 four times slower, 200uS period.
Every 200uS, you change the output from low to High, then bring it low again based on the pot reading from 0 to 1023.
Since an ADC reading takes 110uS, you could take a reading and use it to adjust the High time of the following cycle.
Or use a faster external ADC with SPI reads and apply them immediately after a rising edge.
Use direct port manipulation to toggle the IO for fastest results.
How much granularity did you want?

Granularity in terms of duty cycle precision? Honestly if it stepped in 5% increments I wouldn't mind, but full range 0-95% would be optimal. And in terms of constant pot readings, I don't need it to read on the fly. Beam intensity would be static while lasing. I'm looking to have an engraver for stuff like metal/plastic signs, and maybe PCB fab. So most tasks I'd do with it wouldn't change.

I'll look up my 20 KHz code with fixed 50-50 duty cycle and think about how to add variable pulse width. I have a concept in mind, will take a little bit to get it all typed out.

From ArduinoNextSteps

#include <TimerOne.h>

void setup() 
{
  pinMode(9, OUTPUT);   
  pinMode(10, OUTPUT);   
  Timer1.initialize(1000);  // <<<<<<<< period in micro seconds 1000us or 1Khz, 200 for 5Khz
  Timer1.pwm(9, 512);     // 0-1023 adjust for desired duty cycle
  //Timer1.pwm(10, 255); 
}
 
void loop()
{
}

LarryD:
From ArduinoNextSteps

#include <TimerOne.h>

void setup()
{
  pinMode(9, OUTPUT); 
  pinMode(10, OUTPUT); 
  Timer1.initialize(1000);  // <<<<<<<< period in micro seconds 1000us or 1Khz, 200 for 5Khz
  Timer1.pwm(9, 512);    // 0-1023 adjust for desired duty cycle
  //Timer1.pwm(10, 255);
}

void loop()
{
}

So the PWM input on the laser unit has a PWM send and return. I'm assuming the return is just GND on the Arduino? Also, how would I incorporate a potentiometer from, let's say A0 into " Timer1.pwm(9, 512); "?

So the PWM input on the laser unit has a PWM send and return. I'm assuming the return is just GND on the Arduino?
Yes.
You'll have to drive the laser with a MOS fet or transistor if > 20ma.

Also, how would I incorporate a potentiometer from, let's say A0 into " Timer1.pwm(9, 512); "?
int x = analogRead(A0);
Timer1.pwm(9,x);
You may have to limit/constrain your duty cycle to some value.
.

LarryD:
You'll have to drive the laser with a MOS fet or transistor if > 20ma.

int x = analogRead(A0);
Timer1.pwm(9,x);
You may have to limit/constrain your duty cycle to some value.

The recommended amperage is 3-10ma on the PWM. The laser itself is 30Vdc@18A. I'll probably put some sort of notch or block on the pot knob itself. I'm still pretty new to the world of Arduino, so all this code can get confusing. I'll make good ol' fashioned modifications to physical components before I go off and try to learn a bunch of code all at once.

A simple "if" can help you limit things

if(x >= someNumber)
{
x = someNumber - 1;
}

You could use constrain:
constrain(x, a, b)

.

So it should look like this?

#include <TimerOne.h>

int x = analogRead(A0);

void setup() 
{
  pinMode(9, OUTPUT);     
  Timer1.initialize(200); 
  Timer1.pwm(9, x); 
  constrain(x, 1, 971);
}
 
void loop()
{
}

If I have this right, what ever value from A0 is what the duty cycle will be output from pin 9, assuming A0 has a 1-1023 range (how do I ensure this?) like the Timer.pwn range? And It will constrain the readings from A0 to read then output now less than 1 and no more than 971 (95% of 1023)? Is this correct?

Let me also note I do not have access to an O-scope, so I'm going to have to run off of faith.

Here you will get a positive pulse: ~10%(~20us) to 90%(~180us) DC
In this case, the pulse train will appear on pin 9 continually.
Pulse width will vary from 20us to 180us as you vary the potentiometer on A0.

#include <TimerOne.h>

unsigned int x;

void setup() 
{
  pinMode(9, OUTPUT);     
  Timer1.initialize(200); //~5Khz
}

void loop()
{
  x = analogRead(A0);  // x will be 0 to 1023
  x = constrain(x, 100, 920); //gives ~ 10% to 90% DC
  Timer1.pwm(9, x); 
}

Does the pot matter in this case? 1k, 5k, or 10k for example?

All your values will work.
10K is what most would use as it draws less current from +5V.

I just checked the cct. out with a scope and the frequency is 5Khz and the pulse width changes from 19.6us to 179us for the numbers in my sketch.