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

    Vary Frequency in PWM output instead of duty cycle.

    Scheduled Pinned Locked Moved
    Firmware wishlist
    3
    8
    767
    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.
    • lee7670undefined
      lee7670
      last edited by

      Hi, I have an external peripheral where it would be useful to vary the pwm frequency instead of the duty cycle from 0-65535Hz. Is this possible with M42? Better yet, would it be possible to implement something similar to M106 so I could have a nice slider in DWC?

      1 Reply Last reply Reply Quote 0
      • A Former User?
        A Former User
        last edited by A Former User

        M42 is stricktly for on/off, and it seems M42 two consequiteve M42 take about 1ms on a Duet2Wifi, so that'll limit you to about 500hz.

        Haven't looked at how M160 M106 or M280 deals with changing the base frequency while outputting a signal, but I wouldn't be surprised if there were some artifacts.

        What kind of response times and resolutions are you looking for; and are there no other control options?

        1 Reply Last reply Reply Quote 0
        • baird1faundefined
          baird1fa
          last edited by

          what you are looking for is not PWM (pulse width modulation) you want FM (Frequency Modulation). I would suspect that the duet is not setup to use FM as it is not mentioned anywhere in the documentation. As Bearer said you can change the base frequency of the PWM and if you set the PWM to 50% and then changed the base frequency it might work to act like frequency modulation, but i doubt it. Give it a try, it can't hurt.

          I do believe you can buy conversion hardware that will take a PWM signal and convert it to an FM signal.

          1 Reply Last reply Reply Quote 1
          • lee7670undefined
            lee7670
            last edited by

            This is actually for driving a Clearpath Servomotor in Torque command mode, where the most accurate way to control it is with frequency of a square wave. It will probably work if I just reconfigure the pin every time, but I was hoping there was a more convenient way to do it.

            See https://www.youtube.com/watch?v=PsCY2qx6dK8 for an exxample.

            1 Reply Last reply Reply Quote 0
            • A Former User?
              A Former User
              last edited by

              video shows you can use both pwm duty cycle and frequency control?

              but if you don't need frequent updates and the control doesn't react to any undesired frequency components as a result of changing the frequency then it might work with M106.

              1 Reply Last reply Reply Quote 0
              • lee7670undefined
                lee7670
                last edited by

                Yes, but the Duty Cycle control mode is much less accurate (from using some function generator testing.
                It'll probably be adequate for what I need to do.

                1 Reply Last reply Reply Quote 0
                • A Former User?
                  A Former User
                  last edited by

                  interesting, i suppose the duty cycle can only be adjusted in 255 steps (unless using a 0..1 notation with decimals gives finer resolution?).

                  you might find the limited duty cycle adjustment of M280 to be not suited for frequency control, but M106 will let you change both the frequency and the duty cycle. testing might be the best manor of determining the min/max frequency the duet can produce as well as the resolution and linearity.

                  1 Reply Last reply Reply Quote 0
                  • lee7670undefined
                    lee7670
                    last edited by

                    Unfortunately, M106 doesn't support frequency change in RRF3 :(. Gotta use M950.

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