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

    Input Capture Units

    Scheduled Pinned Locked Moved Comments & Feedback
    6 Posts 4 Posters 137 Views 4 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.
    • M Offline
      Markus Roggli
      last edited by

      I am looking for an accurate implementation to capture the time after a rising edge occurred on an external pin by a WiPy 3.0 module. My needs for a time measurement between rising edges, is between 0.5s and 0.5ms with an accuracy of about 10us. Tests showed, that calling the time value inside the interrupt driven callback function is very inaccurate.

      Now my question:

      It seem that the ESP32 has a Capture Submodule implemented in the PWM module.
      Is it possible to configure the PWM unit in a way, that it stores a time stamp value in a HW register after a rising edge on a HW pin occurred? A interrupt driven callback function could then simply read the specific register value and the value would not be interrupt latency dependent.

      Any help is very appreciated

      P robert-hhR 2 Replies Last reply Reply Quote 0
      • P Offline
        pwest @Markus Roggli
        last edited by

        @Markus-Roggli
        Have you made any progress on this? I'm considering applying a WiPy to a problem where I'll need to be measuring short events, maybe 30-100ms, with approximately 100 microsecond accuracy.

        What sort of accuracy did you see in your tests? You say you were calling time() inside an interrupt. Did you try using the micropython timerchannel.capture([value]) ?

        -Phil

        M 1 Reply Last reply Reply Quote 0
        • robert-hhR Offline
          robert-hh @Markus Roggli
          last edited by

          @Markus-Roggli Did you have a look at the RMT module? It is very precise.

          D 1 Reply Last reply Reply Quote 0
          • D Offline
            d.alvrzx @robert-hh
            last edited by

            @robert-hh I've personally attempted to use the RMT module to measure RPM signals (which are square waves at ~1 kHz in the case of my sensor), but unfortunately the module only works for signals that "stop" at some point (until it gets some timeout), while my RPM signal keeps on going as long as the engine is running... But yeah, when I tested it, it was super precise...

            Any idea of how to make it work with "continuous" signals? I actually followed your code here: https://forum.pycom.io/topic/3430/how-to-measure-ac-line-frequency-using-lopy/4

            robert-hhR 1 Reply Last reply Reply Quote 0
            • robert-hhR Offline
              robert-hh @d.alvrzx
              last edited by

              @d-alvrzx Oh yes. That is something I stumbled upon. So the only method I found until now is stopping the input, either be re-defining the pin, or by gating the signal with an external gate.
              The behavior is caused by the esp-idf methods used. I did not look into that again about whether it could be changed.

              1 Reply Last reply Reply Quote 1
              • M Offline
                Markus Roggli @pwest
                last edited by

                @pwest
                The worst-case interrupt latency that I measured on pycom's Wipy board was approximately 1 ms (measured with an oscilloscope).
                I did not find the timerchannel.capture ([value]) method on the micropython implementation of pycom.

                In the meantime I switched to the Pybord D series with an STM32F7.
                The measured interrupt latency is approx. 30us and the timer.capture method is implemented and can be called within the callback routine.

                Measurements in the us scale are no problem, so this solution works for me.

                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