PWM monitor

List all your sketches here
Post Reply
Martin
Posts: 744
Joined: 16 Feb 2018, 14:11
Location: Warwickshire

PWM monitor

Post by Martin »

This is a bit arcane, but may be of some interest to anyone who needs to read multiple channels of PWM input on an Arduino. It reads up to 18 channels of PWM and displays them by printing to the Serial port (at 115200 baud). It just outputs all 18 channels in order on one line, and repeats as fast as the Serial port can handle.

You can view the values using the Arduino IDE Serial Monitor. Units are half-microseconds, so the normal PWM pulse range of 1ms to 2ms display as numbers in the range about 2000 to 4000 with nominal centre at 3000.

More useful is to use the Arduino IDE Serial Plotter (Ctrl-Shift-L) which then shows a live updating graph of the channels, with a different colour for each channel.



I improved the sketch a little since making that video to reduce the jitter further. If you don't connect all the channels, the jitter improves anyway, because the worst jitter (just a few microseconds) happens when two or more PWM signals change state at almost the same time.
Attachments
PWM18channelMonitor.zip
(2.91 KiB) Downloaded 96 times
Post Reply