Good morning @dc42,
Thank you for your response. Regarding blocking daemon.g, it is clear to me that it is not necessary. It was likely a feeling I had due to the behavior I observed, and I decided to block it to be sure, but I have now removed it from my code.
Regarding "stack," it is probably a mistranslation; I mean the movement queue (M596 P0 or P1).
As for your last comment, I just tried it and still have to use M569 P1 because if I don't use it, it does not execute in the desired times. Even using M669 T0.1 S1, the execution response of daemon.g is slow. Here are the details of how I conducted the tests.
Gcode being printed:
; G-Code generated by INDART3D
G21 ; Metric values
T0 P0 ; Select Tool
G28 ; Home all
G0 Z900
M400 ; Wait for current moves to finish
; Macro
G1 X0 Y0 F3000
G1 X1000 Y1000
G1 X0 Y1000
G1 X1000 Y0
G1 X0 Y0 F3000
G1 X1000 Y1000
G1 X0 Y1000
G1 X1000 Y0
G1 X0 Y0 F3000
G1 X1000 Y1000
G1 X0 Y1000
G1 X1000 Y0
G1 X1000 Y0
G1 X0 Y0 F3000
; The gcode keeps repeating these commands hundreds more times
daemon.g modified with your instructions:
; M596 P1
if (state.status == "processing") && (sensors.gpIn[1].value == 1) && (global.DaemonActive < state.upTime)
M106 P3 S1
set global.TimerPelletsT0 = state.upTime + 6
echo >>"0:/sys/Alimentador Registro" {global.ContPelletsT0} ; Log of number of unsuccessful attempts
while state.upTime < global.TimerPelletsT0 ; count off the fill time
if sensors.gpIn[1].value == 0 ; Check for pellets
M106 P3 S0
G4 P500 ; M400 ; Perform a short wait before checking
if sensors.gpIn[1].value == 0 ; Check that it was not a false detection
set global.TimerPelletsT0 = state.upTime - 6
M300 S5000 P500
else ; A false detection was detected, continue.
M106 P3 S1
G4 S1 ; M400
M106 P3 S0
set global.DaemonActive = state.upTime + 20 ; set the new time to allow compressor refill
if sensors.gpIn[1].value == 1 ; is hopper still empty?
set global.ContPelletsT0 = global.ContPelletsT0 + 1
else
set global.ContPelletsT0 = 1
if global.ContPelletsT0 > 10
set global.ContPelletsT0 = 1
; M596 P0
M25
M291 R"Material Sensor" P"No Pellets detected" S2 T0
The result I get is the same. Right now, I am testing with an empty system, so sensors.gpIn[1].value is always equal to 1. The issue is that without using the secondary motion queue, it does not respect the 6 seconds, it always takes longer than desired, and it always turns off or on at the end of the complete Gcode lines, despite being fragmented with M669 T0.1 S1.
Best regards,