Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: daniba73 on November 18, 2022, 05:52:01 AM

Title: How to remember DRO and Fixtures in Mach4?
Post by: daniba73 on November 18, 2022, 05:52:01 AM
I'm using google translate, sorry for any mistakes.
How can I make Mach4 remember the last seen position in the DROs, the next time the program is reopened?
How can I save the fixture G54, G55 etc etc?
I asked this question, because sometimes the electricity goes out.
When this happens I lose fixture offset.
thanks!
Title: Re: How to remember DRO and Fixtures in Mach4?
Post by: joeaverage on November 18, 2022, 03:23:37 PM
Hi,
in most cases g54,g55...etc are saved when Mach closes down.

When Mach is closed down it executes the ScreenUnload script. That script will save all the usual stuff like g54,g55 etc. If you want to save other items that's where you put the code.
Any data you save will be stored in the .ini file.

When Mach is restarted at the first run of the PLC script (which occurs after Mach loads and runs) you can retrieve the data from the .ini file and restore whatever DROs or variables within Mach.

Quote
I asked this question, because sometimes the electricity goes out.

This is your problem, if the power goes out then Mach just crashes, the ScreenUnload script will never get to run....and so none of the current data will be saved. Thats just bad luck
and nothing you can do about it. You need an uninterruptable power supply for your PC. If the power goes out then the power supply will know about it and shut down Mach gracefully,
ie run the ScreenUnload script.

Craig
Title: Re: How to remember DRO and Fixtures in Mach4?
Post by: SwiftyJ on November 19, 2022, 05:35:23 AM
You can use mc.mcFixtureSaveFile(inst) to save the fixture offsets file. So you can add this to the end of any button script that you use to set the offsets
Title: Re: How to remember DRO and Fixtures in Mach4?
Post by: daniba73 on November 19, 2022, 06:11:42 AM
well! I thank you!
I'll try, then let you know
Title: Re: How to remember DRO and Fixtures in Mach4?
Post by: daniba73 on November 20, 2022, 03:24:57 AM
Hello.
I tried putting the code you wrote inside the Custom Button.
no result.
Origin of the piece made and button pressed.
if i turn off the power to the pc i lose origin.
Title: Re: How to remember DRO and Fixtures in Mach4?
Post by: CajonRat on November 20, 2022, 01:42:29 PM
If your machine has home switches or if you home in the same spot every time, you can put your fixture offsets
in your program with G10 L2 X* Y* Z* A*
Title: Re: How to remember DRO and Fixtures in Mach4?
Post by: joeaverage on November 20, 2022, 02:20:29 PM
Hi,

Quote
if i turn off the power to the pc i lose origin.

Did you restore the origin? You may have saved the origin but you need to read from the .ini file and restore the g54 coordinates.

Craig

Title: Re: How to remember DRO and Fixtures in Mach4?
Post by: daniba73 on November 20, 2022, 04:47:45 PM
how can i load the.ini file?
Title: Re: How to remember DRO and Fixtures in Mach4?
Post by: joeaverage on November 20, 2022, 04:54:54 PM
Hi,
you have to use the complementary API to that which you saved the fixture table:

LUA Syntax:
rc = mc.mcFixtureLoadFile(
      number mInst,
      string FileToLoad);

Description:
Used to load a fixture table into the core.

Craig
Title: Re: How to remember DRO and Fixtures in Mach4?
Post by: daniba73 on November 21, 2022, 06:54:19 AM
I don't understand what to do!
I'm not a programmer!
is it not possible to create a Fixture Save button like in Mach3?
Title: Re: How to remember DRO and Fixtures in Mach4?
Post by: joeaverage on November 21, 2022, 02:12:50 PM
Hi,

Quote
is it not possible to create a Fixture Save button like in Mach3?

Yes it is possible but it will require some programming whether you like it or not.

There is a pair of API's especially for this purpose,  and a number of other API's which could be used to do the same thing, but all of the APIs require some code
to glue it all together.

Craig
Title: Re: How to remember DRO and Fixtures in Mach4?
Post by: Bill_O on November 21, 2022, 06:01:05 PM
Daniba,

I am not a programmer either but I made this to help others out.

https://www.machsupport.com/forum/index.php?action=dlattach;topic=43260.0;attach=54239
Title: Re: How to remember DRO and Fixtures in Mach4?
Post by: daniba73 on November 23, 2022, 01:15:05 AM
it would be an impossible mission for me ... I would only do damage ..