Frequency of digital output
-
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
-
I think you need to look at the "F" parameter of M42
https://duet3d.dozuki.com/Wiki/Gcode#Section_M42_Switch_I_O_pin -
@OwenD I think in RRF_3 the frequency is specified in M950 by Q and not anymore in M42, but I will try anway
-
@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. -
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.
-
@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
-
@JBisc you are probably running into the SD card read times there.
-
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.