Read io input
-
@pouic1313 I read an input in daemon.g with the following command: sensors.gpIn[0].value.
In your case it will be: sensors.gpIn[6].value -
Does i need to create a "deamon.g" file into my sd card ?
-
@pouic1313 It is not explicit needed to read an input state.
If you create a daemon.g file in the "sys" folder, you have a frequently called routine (every 10 seconds by default). There you can put in your meta commands for doing what ever you want... -
@pouic1313 what do you want to do when you have read the input? If you want to execute something or not depending on the state, you can use this:
if sensors.gpin[6].value != 0 ... put your code here ...
-
Hi @dc42,
I work on a pick and place machine.
Actually, I am experiencing problems with error monitoring when taping components.
My feeder contain just one IR sensor to stop advance tape.After several run, we need to add one IR sensor to detect the presence of the component in tape (the state what i want to read, related to this topic) and if the stepper motor stall when tape is advanced (i think is an other subject).
Actually i just use the Gcode:
G1 H1 A10
Tape is advanced as long as the IR sensor is triggered
so i want to read my IR sensor (component is present) just after the tape is advanced.In accord with @cosmowave i just need to add "deamon.g" file in my "sys" folder conf, and with my gcode ? send : sensors.gpin[6].value
to continue or raise an error ? -
@pouic1313 Yes. You can create the "daemon.g" in your sys folder on the sd card. In this daemon.g file you can put your code which will be executed every 10 seconds.
In my daemon.g i read the input state with following code:
if sensors.gpIn[0].value = 0 ; check that the input is still low .....
-
@cosmowave
Can we set the time between each maesure ? 10 seconds are very longi can't find any documentation for deamon.g file where do you find this feature?
-
@pouic1313 You can put your commands in a while loop with delay in daemon.g.
while true ;do your stuff G4 S1 ; Delay 1s = daemon.g is called every second
Note: You need to define a delay, otherwise the cpu can not do other things! But the duration of the delay is up to you. It should not be to low, the cpu needs time to do other things!
-
@pouic1313 Some infos are here:
https://docs.duet3d.com/en/User_manual/Reference/Gcode_meta_commands -
@pouic1313 you only need a daemon.g file if you want to monitor the input continuously. Otherwise, just test it at those places in your GCode where you want to check it.
-
@cosmowave
oh yes i found it thank! I already check this page but I didn't find the last time@dc42
I can't test it now, i need to wait monday -
Finally I use the endstop reassignment with M574 and i can read the status with M119 command
Thank for your help!