while-loop to track temperature
-
@koreandi another possibility is to use daemon.g to send the temperatures directly to a MQTT server. This is currently supported only in RRF 3.5beta versions, and only through WiFi interfaces.
-
Hi David,
I would have a question related to temperature data logging, as conducted with on-demand. I have RepRapFirmware for Duet 3 MB6HC 3.4.2 (2022-09-13).
My aim is to log data of two temperature sensors, e.g., after every 30 seconds, after I have enabled datalogging to occur continuously. The experiments would take approx. 3 hours, after which I would like to turn off this data logging property. After that, only data visualization on the web user interface is occurring.
I have tried to conduct this as described abone by @T3P3Tony . Setting-up a daemon file, except I have used M929 and M118 commands. Also, I have got some errors complaining about "logTemps already exists). Actually, I have also commented off the first two rows of above daemon.g and this stopped the error from appearing.
I have modified the config file as instructed above. I have also written macros for activating (set global.logTemps = true) or deactivating (set global.logTemps = false) the temperature data logging, with which I have intended to start and stop the datalogging feature.
However, I have end up in situation in which the datalogging occurs regardless of my macros. So it is runs continuously, and I need to rename daemon.g e.g., to daemon1.g to turn off this datalogging.
Please, could you give me hints about how to succeed with my aim to have on-demand data logging to occur after every 30 seconds?
BR, Heidi
-
@HeidiH said in while-loop to track temperature:
However, I have end up in situation in which the datalogging occurs regardless of my macros. So it is runs continuously, and I need to rename daemon.g e.g., to daemon1.g to turn off this datalogging.
You should only need to execute this to stop logging:
set global.logTemps=false
You could put that in your stop.g and cancel.g files.
-
@dc42
Hi,Thank you for your response. I will add this "set global.logTemps=false" to my stop.g and cancel.g files. This won't help with my current problem when I am aiming to test and data log the heating responses of my customized heater just by manually changing the temperatures using the the web interface and not printing anything.
Before, I added a macro containing the same command "set global.logTemps=false", and aimed to stop datalogging using it. However, it didn't have an effect. What could cause this?
I must admit, that I have the configuration file specified as instructed above, but if I would have had daemon.g file as written above then I have got warning"Error: in file macro line 2 column 18: meta command: variable 'logTemps' already exists. Consequently, I have left first row of daemon.g file: "if !exists(global.logTemps)" uncommented but commented off "global logTemps=false". This has been the only way to get rid of this warning, but the datalogging is then continuous, regardless of using my macro to stop datalogging. Should I modify my daemon.g file ?
With best wishes, Heidi
-
@HeidiH please post your daemon.g file
-
@T3P3Tony
Thank you Tony :). Please, find below my daemon file:if !exists(global.logTemps)
global logTemps = falsewhile global.logTemps == true
M929 P"0:/sys/templog14.csv" S1 ; Start logging and only log warnings by default
M118 S{"Pt100: " ^ sensors.analog[1].lastReading ^ " C"} L1 ; Send the temperature
M118 S{"Pt1002: " ^ sensors.analog[2].lastReading ^ " C"} L1 ; Send the temperatureG4 S20 ; In addition to default 10 seconds added this +20 s extra = 30 seconds intervals for temperature data logging;
-
If the files is formatted like you posted above then that's the issues, see the Meta Gcode documentation, you need to indent the sections of loops and conditional statements:
if !exists(global.logTemps) global logTemps = false while global.logTemps == true M929 P"0:/sys/templog14.csv" S1 ; Start logging and only log warnings by default M118 S{"Pt100: " ^ sensors.analog[1].lastReading ^ " C"} L1 ; Send the temperature M118 S{"Pt1002: " ^ sensors.analog[2].lastReading ^ " C"} L1 ; Send the temperature G4 S30 ; 30 seconds intervals for temperature data logging; M929 S0 ; stop logging
The while loop will loop until you set global.logTemps to false, so if you want 30s between log entries no need to wait the full 30s. Daemon.g will only attempt to run every 10s if it's not already running.
This is untested but should be a good start point
I find it easier to use echo when only interested in specific things (and not warnings/errors) to be output at regular intervals, rather than M929.b
-
Great, now my temperature logging is working as I want. Many thank you Tony :)!!
I had missed this importance of indentation, when screening through the Meta file, but I will read this web site again with special attention.
Echo is also interesting feature, did I understood correctly and it is just for visualizing or saving data of interest or does it have another properties also?
-
@HeidiH glad it's working
echo without the write to file aspect is useful for debugging (e.g. echo the output to console to see what it is.
echo with the > or >>,>>> is useful to write text files.
-
@T3P3Tony
Thank you very much Tony,after some problems with the command "echo" I found out that the fimrwareversion was still 3.3.
So I did the update to 3.4.6 and now it works perfect.A question I have is if it is possible to name the logtemp.csv after the current running job so the data is clearly defined and not only called logtemp.
Do you have any idea?
-
@Jojo-0 you can use information from the object model in your file name, like the current job name.
-
@T3P3Tony Does this work also automatically so I dont have to change the name of the file for each job manually?
What do I have to write instead of the folder "0:/sys/templog.csv" in daemon.g ?
-
@Jojo-0 for example you could use job.file.fileName however note that this is only valid if there is a job being executed.
for example (untested)
while global.logtemps ==true && job.file.fileName != null echo >>{"0:/sys/templog_"^job.file.fileName^".csv" {state.time}^.....etc G4 S1
not sure if that comparison with null will work. also make sure there are no spaces in your file names.
-
@T3P3Tony Thank you for your support!!!
I tried it that way, but the there is an error with the combination of the folder and the filename.
The file is just called "templog_"I tried different ways to skip that, but the only thing worked with job.file.fileName was to name the file exactly same as the job in a text file or to write it into the gcode.
-
I had a typo in the untested example:
Does this work better?
... echo >>{"0:/sys/templog_"^job.file.fileName^".csv"} {state.time}^.....etc ...
Not there is now a closing curly brace after fileName^".csv"}
-
@T3P3Tony
I saw that already, but the problem is that the daemon.g is not able to create or find the folder.Error: Failed to create folder 0:/sys/templog_0: in path 0:/sys/templog_0:/gcodes/2023-8-10-17-21_230808_7_KF-FDM010_D1_KF-FDM010_JB_155_110_MH-Professional-
Error: in file macro line 5 column 57: meta command: Failed to create or open fileFor better understanding:
-
the Job-Name: 2023-8-10-17-21_230808_7_KF-FDM010_D1_KF-FDM010_JB_155_110_MH-Professional-daemonG.gcode
-
the path of the jobs: 0:/gcodes/
-
-
@Jojo-0 ah yes, the job name is the full path so that wont work.
you could try using the state.upTime e.g.:
... echo >>{"0:/sys/templog_"^state.upTime^".csv"} {state.time}^.....etc ...
-
@T3P3Tony
I guess thats no good idea, cause it will create a seperate file for each second -
@Jojo-0 ah yes, store it in a variable at the start of the print and then use that variable throughout the print?
Parsing the filename to remove the directory section is not going to be something we can implement in 3.5 so we need a solution to work around that for now.
-
@T3P3Tony
Just fpound a way to write it into a c-file stored beneath the job with the same name.
So I can transfer it afterward into a excel file.echo >>{job.file.fileName}^".c" {state....