# Trouble with "from machine import PWM"

**URL:** <https://forums.openmv.io/t/trouble-with-from-machine-import-pwm/8120>\
**Category:** OpenMV Boards\
**Created:** [March 22, 2023, 7:40pm UTC](https://forums.openmv.io/t/trouble-with-from-machine-import-pwm/8120 "2023-03-22T19:40:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JHS](https://avatars.discourse-cdn.com/v4/letter/j/c67d28/32.png) [@JHS](https://forums.openmv.io/u/JHS)\
**Post date:** [March 22, 2023, 7:40pm UTC](https://forums.openmv.io/t/trouble-with-from-machine-import-pwm/8120/1 "2023-03-22T19:40:50Z")

</div>

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)](https://docs.openmv.io/library/machine.PWM.html?highlight=pwm#machine.PWM)

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

Any thoughts?

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [March 22, 2023, 8:19pm UTC](https://forums.openmv.io/t/trouble-with-from-machine-import-pwm/8120/2 "2023-03-22T20:19:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![JHS](https://avatars.discourse-cdn.com/v4/letter/j/c67d28/32.png) [@JHS](https://forums.openmv.io/u/JHS)\
**Post date:** [March 22, 2023, 8:47pm UTC](https://forums.openmv.io/t/trouble-with-from-machine-import-pwm/8120/3 "2023-03-22T20:47:07Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [March 22, 2023, 9:30pm UTC](https://forums.openmv.io/t/trouble-with-from-machine-import-pwm/8120/4 "2023-03-22T21:30:32Z")

</div>

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