Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started 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.
-
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
-
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.
-
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
-
Actually in the screen editor its called static text.
-
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.
-
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.
if testcount == 2 then
local cvMode = mc.mcProfileGetString(inst, 'CVFeedrate', 'CVMode', 'G64')
scr.SetProperty('lblCVMode', 'Label', cvMode)
end
DazTheGas
-
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.
-
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.
-
Perhaps this will shed some light, an uncut forum answer video. ;-)
https://youtu.be/c3wUS4LjuCA
DazTheGas
-
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.
-
Not sure I understand what you mean, its sunday for me now ;-)
DazTheGas