Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: Mauri on February 10, 2017, 04:36:33 PM

Title: Displaying specific data from Machine.ini onto Mach4 Screen
Post by: Mauri on February 10, 2017, 04:36:33 PM
Hi,
Does any one know how to read and display specific data from Machine.ini file onto the Mach4 Screen?
For example read the 100 and G64 from the Machine.ini file.
CV ON
CV 100
[CVFeedrate]
Angle_0=100.000000
CVMode=G64
Regards,
Mauri.
Title: Re: Displaying specific data from Machine.ini onto Mach4 Screen
Post by: DazTheGas on February 11, 2017, 05:02:01 AM
If you look in the docs directory at the api docs there is a section called profile which does what you need.

IE for CVMode would be  cvMode = mc.mcProfileGetString(inst, 'CVFeedrate', 'CVMode', 'G64') last param being default if not already in machine.ini

To write this too, lets say a label called lblCVMode then you can use scr.SetProperty('lblCVMode', 'Label', cvMode)

Hope this helps

DazTheGas
Title: Re: Displaying specific data from Machine.ini onto Mach4 Screen
Post by: Mauri on February 11, 2017, 02:45:56 PM
Daz,
Need more help please.
Where do you put "cvMode = mc.mcProfileGetString(inst, 'CVFeedrate', 'CVMode', 'G64')"  ?
If I have a Label called lblCVMode where does "scr.SetProperty('lblCVMode', 'Label', cvMode)" go?
Is the Label part of a button?
Regards,
Mauri.
Title: Re: Displaying specific data from Machine.ini onto Mach4 Screen
Post by: DazTheGas on February 11, 2017, 03:22:32 PM
You will find the label object in the screen editor.

Depending if you want the output updated or not to where you put the code, if you just want to display what has been loaded from the machine.ini then this would go in the screen load script, if you want the label to update during the session then this would go into the plc script.

DazTheGas
Title: Re: Displaying specific data from Machine.ini onto Mach4 Screen
Post by: DazTheGas on February 11, 2017, 03:24:36 PM
Actually in the screen editor its called static text.
Title: Re: Displaying specific data from Machine.ini onto Mach4 Screen
Post by: Mauri on February 11, 2017, 03:52:40 PM
Daz,
It must be Sunday that is why I do not get it.

I added a Static Label called "lblCVMode" and loaded the other two line into Screen Load Script, restarted Mach4, but nothing displays?

Do I require to have anything in Label Code or Registry of the Static Label?

Regards,
Mauri.
Title: Re: Displaying specific data from Machine.ini onto Mach4 Screen
Post by: DazTheGas on February 11, 2017, 04:19:01 PM
Just had a quick look and your right, it appears that the screen load script has loaded and finished before the label is created, will have to go in plc, change the 2 to suit or just remove for the lbl to const update.

Code: [Select]
if testcount == 2 then
local cvMode = mc.mcProfileGetString(inst, 'CVFeedrate', 'CVMode', 'G64')
scr.SetProperty('lblCVMode', 'Label', cvMode)
end

DazTheGas
Title: Re: Displaying specific data from Machine.ini onto Mach4 Screen
Post by: Mauri on February 11, 2017, 04:34:14 PM
Daz,
If testcount ==2 then
Where does the PLC know that testcount =2?

If I only have
local cvMode = mc.mcProfileGetString(inst, 'CVFeedrate', 'CVMode', 'G64')
scr.SetProperty('lblCVMode', 'Label', cvMode)
Nothing displays.

"or just remove for the lbl to const update"  where is this done?
Regards,
Mauri.
Title: Re: Displaying specific data from Machine.ini onto Mach4 Screen
Post by: Mauri on February 11, 2017, 04:41:32 PM
Daz,
I see the "testcount = testcount + 1" at the top of the PLC.
However nothing displays when I start Mach4 with that Label?
Have you tested it?
Regards,
Mauri.
Title: Re: Displaying specific data from Machine.ini onto Mach4 Screen
Post by: DazTheGas on February 11, 2017, 05:57:33 PM
Perhaps this will shed some light, an uncut forum answer video. ;-)

https://youtu.be/c3wUS4LjuCA

DazTheGas
Title: Re: Displaying specific data from Machine.ini onto Mach4 Screen
Post by: Mauri on February 12, 2017, 03:22:56 AM
Daz,
Thanks for your great video.
The reason mine did not work is that I had mine setup in another TAB not on the initial screen as loaded.
By putting in on the load screen it works OK, however if you TAB to another screen then it disappears.
If there a way to keep it there so this does not happen?
Regards,
Mauri.
Title: Re: Displaying specific data from Machine.ini onto Mach4 Screen
Post by: DazTheGas on February 12, 2017, 03:32:10 AM
Not sure I understand what you mean, its sunday for me now ;-)

DazTheGas