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!
-
@berni The RMT class could be used for that.
-
@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
-
Thank you @robert-hh and @jmarcelino! I will give it a go and report back. :-)
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login