ESP32 machine.PWM

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
marestudio2004
Posts: 16
Joined: Thu Sep 30, 2021 9:45 am

Re: ESP32 machine.PWM

Post by marestudio2004 » Sun Dec 19, 2021 10:30 pm

I have esp32, what is solution?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: ESP32 machine.PWM

Post by Roberthh » Mon Dec 20, 2021 6:44 am

Try to use the daily build: https://micropython.org/resources/firmw ... 2ebe09.bin.
See the web page for upload instructions: https://micropython.org/download/esp32/

marestudio2004
Posts: 16
Joined: Thu Sep 30, 2021 9:45 am

Re: ESP32 machine.PWM

Post by marestudio2004 » Mon Dec 20, 2021 7:49 am

Thanks a lot!

I'll try and report my impressions!

marestudio2004
Posts: 16
Joined: Thu Sep 30, 2021 9:45 am

Re: ESP32 machine.PWM

Post by marestudio2004 » Mon Dec 20, 2021 12:15 pm

Sorry, it doesn't seem to be a mistake in the firmware and timing!

Is pwm.deinit () automatically sent commands to return the servo to the starting position and is it possible to change it?

This is my code for servo motor control:

'''klapna'''
class klapna:
def __init__(self, pozicija):
self.pozicija = pozicija
p2 = machine.Pin(32)
servo = machine.PWM(p2,freq = 50)
servo.duty(pozicija)
servo.deinit() # After servo.deinit() esp32 send min value of 95 every time

klapna(pozicija=130) # 95 - 130 min-max

marestudio2004
Posts: 16
Joined: Thu Sep 30, 2021 9:45 am

Re: ESP32 machine.PWM

Post by marestudio2004 » Mon Dec 20, 2021 1:18 pm

I just tried this code on the MicroPython v1.16 on 2021-06-23; ESP32 module with ESP32, and everithing work!

That it is not a mistake in the version v1.17...?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: ESP32 machine.PWM

Post by Roberthh » Mon Dec 20, 2021 2:12 pm

It may be that the deinit() method changed. Why do you call deinit()?

marestudio2004
Posts: 16
Joined: Thu Sep 30, 2021 9:45 am

Re: ESP32 machine.PWM

Post by marestudio2004 » Mon Dec 20, 2021 5:03 pm

In case I don't use deinit (), it's as if there is some interference (signal) that moves the servo in small movements!

I am not an expert in the field of microcontrollers ... My field of expertise is acoustics and audio signal processing ...

Is there an error in the code given in the previous post?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: ESP32 machine.PWM

Post by Roberthh » Mon Dec 20, 2021 5:06 pm

Is that constantly moving in one direction or moving forth and back?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: ESP32 machine.PWM

Post by Roberthh » Mon Dec 20, 2021 5:15 pm

Which parameters do you use when this happens: freq, duty

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: ESP32 machine.PWM

Post by Roberthh » Mon Dec 20, 2021 5:28 pm

With respect to deinit(), I see no difference between v1.16 and v1.17. Both switch off the PWM signal.

Post Reply