Page 2 of 3

Re: ESP32 machine.PWM

Posted: Sun Dec 19, 2021 10:30 pm
by marestudio2004
I have esp32, what is solution?

Re: ESP32 machine.PWM

Posted: Mon Dec 20, 2021 6:44 am
by Roberthh
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/

Re: ESP32 machine.PWM

Posted: Mon Dec 20, 2021 7:49 am
by marestudio2004
Thanks a lot!

I'll try and report my impressions!

Re: ESP32 machine.PWM

Posted: Mon Dec 20, 2021 12:15 pm
by marestudio2004
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

Re: ESP32 machine.PWM

Posted: Mon Dec 20, 2021 1:18 pm
by marestudio2004
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...?

Re: ESP32 machine.PWM

Posted: Mon Dec 20, 2021 2:12 pm
by Roberthh
It may be that the deinit() method changed. Why do you call deinit()?

Re: ESP32 machine.PWM

Posted: Mon Dec 20, 2021 5:03 pm
by marestudio2004
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?

Re: ESP32 machine.PWM

Posted: Mon Dec 20, 2021 5:06 pm
by Roberthh
Is that constantly moving in one direction or moving forth and back?

Re: ESP32 machine.PWM

Posted: Mon Dec 20, 2021 5:15 pm
by Roberthh
Which parameters do you use when this happens: freq, duty

Re: ESP32 machine.PWM

Posted: Mon Dec 20, 2021 5:28 pm
by Roberthh
With respect to deinit(), I see no difference between v1.16 and v1.17. Both switch off the PWM signal.