Duet3D Logo Duet3D
    • Tags
    • Documentation
    • Order
    • Register
    • Login

    Collect ADC sensor values at high frequency

    Scheduled Pinned Locked Moved
    Firmware developers
    2
    3
    114
    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.
    • leoneundefined
      leone
      last edited by

      Hi all,

      I'd like to ask your opinion about having the possibility to stream data at high frequency from a generic ADC sensor (connected to an expansion board) to a CSV file (similar to what the M956 is doing with the accelerometer). I have this need because the CAN frequency at which the sensors are updating is too low for some of the custom calibrations I'm doing. I have something working based on the AccelerometerHandle, but I'd like to see if it is of interest to do a proper refactor and open a pull request from that.

      My idea would be to have something like: M956.1 Pbb.nn Snnn F"" (board.pin name, number of samples, filename). The implementation would be similar to how the accelerometer works, so:

      • add two CAN messages, one for the start request and one for the data structure (or somehow use the accelerometer messages?)
      • an AdcStreamHandler: to be initialized from the pin name and have a task to collect the raw data and build/send the CAN messages
      • modify AveragingFilter.h to return all the collected samples (without interfering with the average)
        Side question: I'm not quite sure at which frequency the ADC is updating the filter queue: from a comment "Readings will be taken and about every 'ticksPerCall' milliseconds the callback function will be called with the specified parameter and ADC reading.". It seems like the analog ports are configured with 1, does this mean the adcFilter queue is filling up at 1ms rate?

      BTW, what do you think about this feature? The main goal is to get values at high frequency (buffered, not necessarily in real-time, but with a known time interval between the samples). Do you see other approaches that could be followed to have the same functionality?

      Thank you in advance.

      dc42undefined 1 Reply Last reply Reply Quote 1
      • dc42undefined
        dc42 administrators @leone
        last edited by

        @leone what sampling rate do you need?

        Duet WiFi hardware designer and firmware engineer
        Please do not ask me for Duet support via PM or email, use the forum
        http://www.escher3d.com, https://miscsolutions.wordpress.com

        leoneundefined 1 Reply Last reply Reply Quote 0
        • leoneundefined
          leone @dc42
          last edited by

          @dc42 about 200-250Hz is good for what I'm doing now. If higher is possible, it is even better for future uses.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Unless otherwise noted, all forum content is licensed under CC-BY-SA