Trouble with "from machine import PWM"

According to the micropython doc page linked below, “from machine import PWM” should work:

class PWM – pulse width modulation — MicroPython 1.19 documentation (openmv.io)

However, I get “ImportError: can’t import name PWM” when I try to run it.

Any thoughts?

Please use the pyb module. The machine module is loosely supported on our boards.

Mr. Agyeman,

Thanks as always for your response. I have initially been trying to use the pyb.Servo library, but find that the precision/resolution of output is limited or truncated. I can command integer whole degrees out using angle, and I can get integer x10 resolution using the .pulse_width command.I would like to be able to command to fractional-degree precision so I am looking for other options.

Is there any high-resolution way to generate finer increments of PWM adjustment on the H7?

Use the TIM library in the PYB module. This allows direct control of the timers that generate PWM.