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

More
13 Aug 2017 02:04 #97401 by Askjerry
Askjerry created the topic: Force a write of "linuxcnc.var" file from code.
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
More
13 Aug 2017 17:36 #97414 by jstoquica
jstoquica replied the topic: Force a write of "linuxcnc.var" file from code.
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.
More
13 Aug 2017 21:32 - 13 Aug 2017 21:34 #97422 by Askjerry
Askjerry replied the topic: Force a write of "linuxcnc.var" file from code.
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
More
13 Aug 2017 22:10 #97424 by jstoquica
jstoquica replied the topic: Force a write of "linuxcnc.var" file from code.
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.
More
13 Aug 2017 23:11 #97427 by Askjerry
Askjerry replied the topic: Force a write of "linuxcnc.var" file from code.
Overwrite the file "linuxcnc.var"

Jerry
More
14 Aug 2017 00:52 #97432 by Askjerry
Askjerry replied the topic: Force a write of "linuxcnc.var" file from code.
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

Time to create page: 0.084 seconds
Powered by Kunena Forum