Precise pulse duration
-
I am trying to to do a pulse of a given duration (e.g. 2.000 ms) on a digital output. Ideally, I don't want to stop the code with a
while True
:At the moment, I am trying with Timer.Alarm but I have the feeling that I am not getting an accurate timing.
p_out = Pin('P19', mode=Pin.OUT) def pulse_off(timer): p_out(0) # Perform a pulse of 2000ms p_out(1) pulse_timer = Timer.Alarm(self.pulse_off, ms=2000, periodic=False)
Could anyone give some advice on the most accurate way to perform a pulse? Thank you in advance!
-
Thank you @robert-hh and @jmarcelino! I will give it a go and report back. :-)
-
@berni
Indeed RMT would be the best way to generate pulses, https://docs.pycom.io/chapter/tutorials/all/rmt.html.The maximum single pulse width is ~ 100ms but you should be able to chain multiple together
-
@berni The RMT class could be used for that.