Total Machine time

More
6 years 2 months ago - 6 years 2 months ago #177884 by anfänger
Hi,

I have some maintainance schedules for my machine (50 hours for some filters and 2000 hours for greasing ways and spindles)
So I would like to have a timer that’s counting as long as the machine is powered on but does not loose the information when powered of. Can I use time for this or will it loose its information with shutdown?
I am using 2.8 with qtpyvcp / Probe basic

Thanks Patrick
Last edit: 6 years 2 months ago by anfänger.

Please Log in or Create an account to join the conversation.

More
6 years 2 months ago #178032 by RotarySMP
Replied by RotarySMP on topic Total Machine time
I don't know how to do it, but LinuxCNC records the machine position to a file one shut down, and reads it in on start up, so you must be able to add what you want.
Mark

Please Log in or Create an account to join the conversation.

More
6 years 2 months ago #178033 by anfänger
Replied by anfänger on topic Total Machine time
This I already do. I know I had one in my debug tab in gmocappy but I can‘t find my old files to check how i it was done and i i can transfer this to probe basic.

Please Log in or Create an account to join the conversation.

More
6 years 2 months ago #178221 by Himarc3D
Replied by Himarc3D on topic Total Machine time
You get it running now ?
check this threads if not;

forum.linuxcnc.org/10-advanced-configura...e-studdies-ugh#44268

www.forum.linuxcnc.org/21-axis/12553-axis-log

I think every program language these days have library for CSV support.
If you dont need to be very specific maybe you can try Tuptime, its in Python and have CSV support...the code is open and maybe you can change it for your need or just start automatically LCNC and use Tuptime (system uptime) and consider it is the machine uptime...
The linuxCNC machine position at start up and shutdown will log even if you dont use the machine, if so its similar to Tuptime.
I need check the LCNC log file to see what happen if for example the machine loose power, the log will be there for power failure?
im still learning Linux, cron job, grep, ps etc so many things...very powerful CLI in Linux and system config file is all in .txt, very nice!

Please Log in or Create an account to join the conversation.

More
6 years 2 months ago - 6 years 2 months ago #178417 by anfänger
Replied by anfänger on topic Total Machine time
And yes linux is awesome. My only problem with linuxcnc is that I can't write python code. But I can use bash and perl. So the timelpg.py script (in the Time Studies thread ) should give me enough to make something out of it.
Last edit: 6 years 2 months ago by anfänger.

Please Log in or Create an account to join the conversation.

More
6 years 2 months ago - 6 years 2 months ago #178625 by anfänger
Replied by anfänger on topic Total Machine time
If someone is interested this code which seems to work.
Code:
#!/usr/bin/python import time import hal fname = "timelog.txt" sumlog = "time.txt" delta_t = 1 # seconds poll interval, hold inputs at least this long f = open(fname,mode="a+") # a: append or create if file doesnt exist h = hal.component("timelog") h.newpin("active",hal.HAL_BIT,hal.HAL_IN) h.newpin("seconds",hal.HAL_U32,hal.HAL_OUT) h.newpin("minutes",hal.HAL_U32,hal.HAL_OUT) h.newpin("hours",hal.HAL_U32,hal.HAL_OUT) h.ready() try: f2= open(sumlog,mode="r+") runtime=float(f2.readline()) f2.close() except: f2= open(sumlog,mode="w+") runtime=0.0 f2.write(str(runtime)) #f3.flush() f2.truncate() f2.close() m, s = divmod(runtime, 60) hr, m = divmod(m, 60) #print(hr,m,s) h["seconds"]=s h["minutes"]=m h["hours"]=hr old_start_pin_value = False t_start = time.time() t_begin = time.time() msg = ("Begin %s\n" % time.ctime()) f.write(msg) f.flush() started = False while True: time.sleep(delta_t) #print h["active"] start_pin_value = h["active"] if start_pin_value != old_start_pin_value: print("changed") if started: started = False print("timer off") t_now = time.time() msg = ("Stop: %s Elapsed: %f\n" % (time.ctime(),t_now - t_start)) f.write(msg) f.flush() runtime=seconds savetime=str(seconds) print savetime f2= open(sumlog,mode="w+") f2.write(savetime) #f3.flush() f2.truncate() f2.close() else: started = True print("timer on") msg = ("Start: %s\n" %time.ctime()) f.write(msg) f.flush() t_start = time.time() f2= open(sumlog,"r") runtime=float(f2.readline()) f2.close() print runtime if start_pin_value: seconds= runtime+(time.time() - t_start) m, s = divmod(seconds, 60) hr, m = divmod(m, 60) h["seconds"]=s h["minutes"]=m h["hours"]=hr old_start_pin_value = start_pin_value
Last edit: 6 years 2 months ago by anfänger. Reason: Edited code
The following user(s) said Thank You: RogEnk

Please Log in or Create an account to join the conversation.

Time to create page: 0.381 seconds
Powered by Kunena Forum