Hello Guest it is November 20, 2019, 05:50:51 PM

Author Topic: Displaying specific data from Machine.ini onto Mach4 Screen  (Read 2088 times)

0 Members and 1 Guest are viewing this topic.

Offline Mauri

*
  •  306 306
    • View Profile
Displaying specific data from Machine.ini onto Mach4 Screen
« 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.

Offline DazTheGas

*
  •  750 750
  • DazTheGas
    • View Profile
Re: Displaying specific data from Machine.ini onto Mach4 Screen
« Reply #1 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
Theres always time for a choccy biccy

Offline Mauri

*
  •  306 306
    • View Profile
Re: Displaying specific data from Machine.ini onto Mach4 Screen
« Reply #2 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.

Offline DazTheGas

*
  •  750 750
  • DazTheGas
    • View Profile
Re: Displaying specific data from Machine.ini onto Mach4 Screen
« Reply #3 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
Theres always time for a choccy biccy

Offline DazTheGas

*
  •  750 750
  • DazTheGas
    • View Profile
Re: Displaying specific data from Machine.ini onto Mach4 Screen
« Reply #4 on: February 11, 2017, 03:24:36 PM »
Actually in the screen editor its called static text.
Theres always time for a choccy biccy

Offline Mauri

*
  •  306 306
    • View Profile
Re: Displaying specific data from Machine.ini onto Mach4 Screen
« Reply #5 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.

Offline DazTheGas

*
  •  750 750
  • DazTheGas
    • View Profile
Re: Displaying specific data from Machine.ini onto Mach4 Screen
« Reply #6 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
Theres always time for a choccy biccy

Offline Mauri

*
  •  306 306
    • View Profile
Re: Displaying specific data from Machine.ini onto Mach4 Screen
« Reply #7 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.

Offline Mauri

*
  •  306 306
    • View Profile
Re: Displaying specific data from Machine.ini onto Mach4 Screen
« Reply #8 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.

Offline DazTheGas

*
  •  750 750
  • DazTheGas
    • View Profile
Re: Displaying specific data from Machine.ini onto Mach4 Screen
« Reply #9 on: February 11, 2017, 05:57:33 PM »
Perhaps this will shed some light, an uncut forum answer video. ;-)

https://youtu.be/c3wUS4LjuCA

DazTheGas
Theres always time for a choccy biccy