while-loop to track temperature
-
@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....
-
@T3P3Tony Is there any possibility to also write the target temperature the nozzle or bed should reach? As example sth like activated temperature?
My goal is to compare the target temperature with the current afterwards.
-
@Jojo-0 check the OM I think there is the set temperature for each tool.
-
@T3P3Tony
okay, thank you.
I'll search there.