Quantcast
Channel: Reprap Forum - Controllers
Viewing all articles
Browse latest Browse all 10211

Re: Need some help with writing code for PWM

$
0
0
... I'm using it to control the pulse width for a laser, so no other code to perform.

The main routine is empty, so the Arduino only waits for an interrupt and then sets a pin HIGH, waits "delayMicroseconds(nnn)" (where 'nnn' is a value set at reset depending on an analog input), then clears the output pin again ... and waits for the next interrupt.

The smallest delay is 1 microsecond, so with all the interrupt service and pin-setting time it could be around 2ms or 500kHz fastest response.

With a constant frequency as interrupt-input this would result in a harmonic PWM frequency, as long the delay+service-time is smaller then the input step time.

But it's basically reacting on my CNC-controller, so the output 'frequency' is synchrone to the moving speeds ...

Viewing all articles
Browse latest Browse all 10211

Trending Articles