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

    Frequency of digital output

    Scheduled Pinned Locked Moved Unsolved
    General Discussion
    4
    8
    354
    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.
    • JBiscundefined
      JBisc
      last edited by JBisc

      To switch one of my H-bridge, I use two digital output

      ; definition
      M950 P4 C"^io4.out" Q200                        
      M950 P6 C" ^io6.out" Q200
      

      Then if switch between two settings (1,2) with the "highest" possible frequency

      ; setting 1
      M42 P6 S0.0
      M42 P4 S1.0
      
      ;setting 2
      M42 P6 S1.0
      M42 P4 S0.0
      
      ; again setting 1
      M42 P6 S0.0
      M42 P4 S1.0
      
      ; again setting 2
      M42 P6 S1.0
      M42 P4 S0.0
      
      ..... repeat
      

      The problem is that i only get a frequency about 3Hz between the changes from setting 1 to setting 2. I would expect a much higher one... Also a small break with G4 P1 does not work

      I am running out of Ideas.... Some Hints for me?

      [CORRECTION:] I was not using exactly this code, the code was refactored in macros and that was also the problem

      My Setup: Duet 3 MB6HC Main Board with attached RPI

      dc42undefined 1 Reply Last reply Reply Quote 0
      • OwenDundefined
        OwenD
        last edited by

        I think you need to look at the "F" parameter of M42
        https://duet3d.dozuki.com/Wiki/Gcode#Section_M42_Switch_I_O_pin

        JBiscundefined 1 Reply Last reply Reply Quote 0
        • JBiscundefined
          JBisc @OwenD
          last edited by

          @OwenD I think in RRF_3 the frequency is specified in M950 by Q and not anymore in M42, but I will try anway

          My Setup: Duet 3 MB6HC Main Board with attached RPI

          OwenDundefined 1 Reply Last reply Reply Quote 0
          • OwenDundefined
            OwenD @JBisc
            last edited by

            @JBisc said in Frequency of digital output:

            @OwenD I think in RRF_3 the frequency is specified in M950 by Q and not anymore in M42, but I will try anway

            You are correct, it has changed.
            You haven't stated the intent of your code.
            I presume to control the speed of a motor, which is why I was pointing you to the PWM frequency.
            The frequency of code execution is a factor of processor speed and load, but I would have thought it significantly faster than 3Hz between execution of those lines.

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

              Are you running that code from the SD card? On which Duet?

              Command G4 P1 will delay by just 1 millisecond, so you are unlikely to notice it.

              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

              JBiscundefined 1 Reply Last reply Reply Quote 0
              • JBiscundefined
                JBisc @dc42
                last edited by JBisc

                @dc42 on SD-Card/RPI (Duet 3)

                I found my error, and I think its Bug from the firmware. But, the firmware experts can probably tell me if this is intended....

                If i call

                ; first step
                M42 P4 S0.0
                G4 P1
                M42 P4 S1.0
                G4 P1
                ; second step
                M42 P4 S0.0
                G4 P1
                M42 P4 S1.0
                G4 P1
                ....
                

                everything is fine and required only a few miliseconds. But if call macros with exactly the same content (eg. M42 P4 S1.0), the programm needs several 100ms to perform a step.

                
                M98 P"/macros/LOW.g"
                G4 P1
                M98 P"/macros/HIGH.g"
                G4 P1
                M98 P"/macros/LOW.g"
                G4 P1
                M98 P"/macros/HIGH.g"
                G4 P1
                

                My Setup: Duet 3 MB6HC Main Board with attached RPI

                T3P3Tonyundefined 1 Reply Last reply Reply Quote 0
                • T3P3Tonyundefined
                  T3P3Tony administrators @JBisc
                  last edited by

                  @JBisc you are probably running into the SD card read times there.

                  www.duet3d.com

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

                    Processing a M98 call requires the file system to read the root directory to find where /sys is, read the /sys directory, then read the sector that contains the start of the macro file. If the /sys directory or the macro file exceeds 512 bytes then additional reads will be needed. If the cluster size is small than FAT reads may be needed too. There isn't sufficient RAM to cache more than 1 sector. So there will be at least 3 SD card reads per execution of the macro. That will be what's taking the time.

                    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

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