Force a write of "linuxcnc.var" file from code.

More
13 Aug 2017 02:04 #97401 by Askjerry
Under normal use, I home the machine (G53) then I specify my work origin (P1 / G54) location.

If I shut down the machine... then bring it back online next week, tomorrow, whenever... I can home the machine (G53) then tell it to go home... and it happily returns to the P1 / G54 home that was set. no problem. (I can use G28.1 or G10L20 X0Y0Z0) They work fine.

Unless.... if I set all that stuff... and I have a power fail... all bets are off.

The file "linuxcnc.var" normally contains a string of numbers... all the offsets, etc. But apparently... when you make changes... they are written in MEMORY... not the file... UNTIL you tell it to quit. If power gets interrupted... and you open "linuxcnc.var" it is a blank file.

I proved this by saving a copy of the file elsewhere... doing a power down (switch on power strip) and restarting... dumb as a door-nail. If I did the same thing... but replaced that file with the saved version... it worked flawlessly.

I have a pyvcp button that calls a routine to set home (G54 / P1) via the G10L20 X0Y0Z0 code that works well. Now I want to add a line that will also basically say, "while you are at it... update "linuxcnc.var". Then... even with a power outage... next reboot will have valid data.

Can it be done?
How?
Sample code that I can paste in???

Thanks,
Jerry

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

More
13 Aug 2017 17:36 #97414 by jstoquica
Hi Jerry,

It is good to know about you.

Why do you try to use G92 and after that save in you g-code your working points.

Regards.

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

More
13 Aug 2017 21:32 - 13 Aug 2017 21:34 #97422 by Askjerry
The problem is that this does not automatically save the file.

I'm looking for a solution that can be implemented and forgotten. On my pyvcp panel I have a button that initiates a G10L20 X0 Y0 Z0 P1 when I click it. This sets all the P1 variables (G54) to exactly what I need. The problem is... unless I write the offsets down manually, extract the variables, or modify my G-Code... the data is lost on a power failure.

Currently I'm performing these functions when I click my button...
(===========================| SET P1/G54 HOME including the ANGLE SETTING |=====================)
(=== 		Copyright 2015 ~ Jerry Rutherford ~ Email: jerryarutherford@gmail.com        ===)
(===============================================================================================)
O <home-angle-zero> sub
	M5     			(Stop Spindle)
	M9     			(Stop Coolant)
	G17    			(Machine to XY Plane)
	G21   			(METRIC Mode)
	G40    			(Cutter Compensation OFF)
	G90    			(Absolute Movement Mode)
	G54    			(Use Coordinate system P1 G54 Default)
	G49    			(Cancel any tool length compensation)
	G91.1  			(Arcs set to default units and method)
	G10 L20 P1 X0 Y0 Z0  	(Set current location to ZERO)
	G10 L2  P1 R0		(Set the angle to ZERO degrees offset.)
O <home-angle-zero> endsub
(===============================================================================================)

What i want to do... is right after the G10 L2 P1 R0 command... is have something like...
write linuxcnc.var
Then the data would be saved at that point... instead of waiting until machine shut down... which we never get to in a power failure.

Thanks,
Jerry
Last edit: 13 Aug 2017 21:34 by Askjerry. Reason: Color / Highlight added

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

More
13 Aug 2017 22:10 #97424 by jstoquica
Jerry,

Then the data would be saved at that point... instead of waiting until machine shut down... which we never get to in a power failure.


What kind of data do you want to save?

Regards.

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

More
13 Aug 2017 23:11 #97427 by Askjerry
Overwrite the file "linuxcnc.var"

Jerry

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

More
14 Aug 2017 00:52 #97432 by Askjerry
I just got a chance to give this a try tonight and here is what I noticed.

I moved the machine to a home point and used the G92 to set the current location to home.
G92 X0 Y0 Z0

Once I did that... I moved the tool to the G30 location I has saved previously, then to the home via my routine. It worked.
I next opened the linuxcnc.var file and found that it now contained data. This was surprising.

I powered off the machine with the power-strip... uncontrolled shutdown... and restarted everything.

When I homed the machine (G53) I then clicked my SAFE GO HOME routine... the equivalent to typing in G0 X0 Y0 Z0 with a couple of extra moves to prevent dragging the tool across the table/part. I expected the machine to remain stationary... not having been shut down properly... but it worked flawlessly.

I'll set up later tonight for more detailed testing... if that works (doing what I did in my earlier video... see below) then I'll make a Part-B follow-up showing that it works.

If so... HUGE THANKS!
Jerry

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

More
05 Sep 2017 11:46 #98526 by eneias_eringer
I have the same problem , in my case , i lost the touch probe calibration !!!

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

More
06 Sep 2017 12:57 #98578 by cmorley
IIRC Linuxcnc writes out the var file when the mode is switched.
The glade widget offset_widget.py there is code like this:
                if self.status.task_mode != self.linuxcnc.MODE_MDI:
                    self.cmd.mode(self.linuxcnc.MODE_MDI)
                    self.cmd.wait_complete()
                self.cmd.mode(self.linuxcnc.MODE_MANUAL)
                self.cmd.wait_complete()
                self.cmd.mode(self.linuxcnc.MODE_MDI)
                self.cmd.wait_complete()

This causes a mode switch (from MDI to manual and back to MDI) which writes out the var file.
Maybe you could make an Mcode that calls a similar python routine to do this.
Just another idea

Chris M

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

More
06 Sep 2017 13:14 #98580 by eFalegname
Instead, I found a temporary solution to this problem, it's a shame that the definitive solution never came.
www.google.it/search?q=pc+backup+power+s...ygC&biw=1361&bih=645

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

More
07 Sep 2017 09:02 - 07 Sep 2017 09:03 #98615 by Askjerry
cmorley: I'll be getting home on Saturday... and I'll verify this again... but it doesn't appear to work.

If you watch my video about 10 minutes in (QUICK LINK) you can see that after setting the home and zero points... I switched between MDI and MANUAL... but after the power fail simulation at 11:30 in the video... when it comes back... the file contains all blanks.

Again... I'll verify this... but looking at the video... you can clearly see where I switched modes a couple of times.

M-Codes: Funny you should mention that... it's the next video I'll write... how to make custom M-Codes. Perhaps if the change is software driven vs. human clicking the screen... it might make a difference. Still looking for that self.variable.write("somefile") kind of command tho.

eFalegname: Yes... it looks like we need a UPS for protection... should actually have that anyway. But the issue has me interested in finding a software fix. I've been lucky... I never had a power failure while running... it wasn't until seeing Peter's video (QUICK LINK) that I even thought about it.

Thanks,
Jerry
Last edit: 07 Sep 2017 09:03 by Askjerry.

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

Time to create page: 0.113 seconds
Powered by Kunena Forum