Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Precise pulse duration

    Scheduled Pinned Locked Moved Discussion
    lopy4pythonpulse
    4 Posts 3 Posters 687 Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B Offline
      berni
      last edited by

      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!

      robert-hhR J 2 Replies Last reply Reply Quote 0
      • robert-hhR Offline
        robert-hh @berni
        last edited by

        @berni The RMT class could be used for that.

        1 Reply Last reply Reply Quote 0
        • J Offline
          jmarcelino @berni
          last edited by jmarcelino

          @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

          1 Reply Last reply Reply Quote 1
          • B Offline
            berni
            last edited by

            Thank you @robert-hh and @jmarcelino! I will give it a go and report back. :-)

            1 Reply Last reply Reply Quote 0

            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
            • 1 / 1
            • First post
              Last post

            Pycom on Twitter

            Pycom