Hello Guest it is May 14, 2021, 10:23:08 AM

Author Topic: Comments about Mach4 in Demo  (Read 73705 times)

0 Members and 1 Guest are viewing this topic.

Re: Comments about Mach4 in Demo
« Reply #130 on: May 02, 2014, 08:38:55 AM »
MACH Config - Input signals tab - first column is not resizable - text truncated

Don't see it here...

The issue is also present on Axis Mapping, Homing, Input, Output and Spindle tabs.

By 'first column, I refer to the gray colored column that has, for lack of a better term, the 'titles' for each line. This column cannot be resized on my system. Some of the 'titles' exceed the available space and are therefor truncated. In most cases, this is not much of a problem, but some of the titles need to be guessed at, which is not a good thing.

They ALL drag and display properly here, top row as well as columns.
Dell laptop
XP SP3

Russ
Re: Comments about Mach4 in Demo
« Reply #131 on: May 02, 2014, 08:43:59 AM »

3. Can the file loader be made to remember the last location and not default to the root directory of Mach4?
4.

Dan
I'm with Dan on # 3.

Also, G4 .... anywhere to select ms instead of seconds ?
Is decimal seconds a valid entry ?  ie: 0.25

Thanks,
Russ
Re: Comments about Mach4 in Demo
« Reply #132 on: May 02, 2014, 09:17:16 AM »

So, with Lua replacing VBscript, how is the above described process handled by MACH4? Specifically, does MACH4 suspend the G-code execution until macros return or will the programmer still have to test and insert delays to assure this happens?

Secondly, will macros be able to have any legal windows file name and be called by a 'RunScript' (or equiv) call?


simpson36,

First I want to explain the main difference between how mach3 handled Mcodes and how mach4 handles Mcodes.  In mach3 every time a Mcode was called from gcode or a RunScript command mach would go find the mcode load that single VB script, compile it and then run it.  So in mach3 every mcode was run on its own thread and the only way to have one mcode pass variables to another mcode was through a DRO, LED ect.

Now lets talk about mach4!! When mach4 starts up it will look at all the Mcodes in the Macros directory and compile them and load them into a single file called mcLua.mcc this is the file mach will run from when a Mcode is called. Now this is where it gets cool! In mach4 when you define a variable you can define it as "local testvar = 123" or a global "testvar = 123" if it is a global variable then any Mcode or script that is in the macros directory can read that variable.

Another big difference is how you must create your mcodes, here is a example.

function m3()
   local inst = mc.mcGetInstance() -- Get the current instance
    local Range, Dwell

   Range = mc.mcSpindleGetCurrentRange(inst);
   Dwell = mc.mcSpindleGetAccelTime(inst, Range);
   
   -- Turn on Spindle FWD Output
   local hReg = mc.mcSignalGetHandle(inst,mc.OSIG_SPINDLEFWD)
    if hReg == 0 then
        mc.mcCntlSetLastError(inst, "Get Handle Error")
      return
    end
   mc.mcSignalSetState(hReg,true)
   
   -- Turn on Spindle On Output
   local hReg = mc.mcSignalGetHandle(inst,mc.OSIG_SPINDLEON)
    if hReg == 0 then
        mc.mcCntlSetLastError(inst, "Get Handle Error")
      return
    end
   mc.mcSignalSetState(hReg,true)
   
   --Dwell while spindle gets up to speed
   wx.wxSleep(Dwell);
end

if (mc.mcInEditor() == 1) then
    m3()
end

Because mach4 compiles all the Mcodes into one script and runs them the only thing that separates Mcodes in the mcLua file are the "function" calls that each Mocde needs to have.

If I was making a custom mcode and needed to run m3 I would simply write "m3()" and because the custom mcode we made is compiled into mcLua along with m3 we can call m3 just like we would call a local function.

This opens up a whole new world of powerful options!!

I hope that helps!!

Andrew Eldredge
MachMotion
Andrew
MachMotion

Offline poppabear

*
  • *
  •  2,233 2,233
  • Briceville, TN, USA
    • View Profile
    • S S Systems, LLC
Re: Comments about Mach4 in Demo
« Reply #133 on: May 02, 2014, 09:53:36 AM »
Andrew, in your code above, perhaps you could show what you where using: "Range = mc.mcSpindleGetCurrentRange(inst);"  Didn't see where you used it in your m3() code above.

I definitely agree, wxLua and M4 rocks!

Scott
Commercial Mach3 & Mach 4, Design/Build/Retrofit CNC and Industrial machines.
http://www.ss-systems-llc.com/
Re: Comments about Mach4 in Demo
« Reply #134 on: May 02, 2014, 10:07:20 AM »
Range = mc.mcSpindleGetCurrentRange(inst);
Dwell = mc.mcSpindleGetAccelTime(inst, Range);

He is passing the variable Range into the Dwell functions second field

There is a whole lot to learn for all of us. Blowing my mind the possibilities. No wonder it took them so damn long. lol
using a Messagebox helps with debugging and seeing what is in the variables, helps me anyways.

wx.wxMessageBox("Range == " .. tostring(Range) )
« Last Edit: May 02, 2014, 10:11:01 AM by Ya-Nvr-No »

Offline BR549

*
  •  6,952 6,952
    • View Profile
Re: Comments about Mach4 in Demo
« Reply #135 on: May 02, 2014, 10:56:54 AM »
HIYA Brian a while back we talked about in Mach4 that it "could" display the #vars as real numbers in the Gcode window as the program ran. Did this make it into Mach4 ??

(;-) TP

Offline poppabear

*
  • *
  •  2,233 2,233
  • Briceville, TN, USA
    • View Profile
    • S S Systems, LLC
Re: Comments about Mach4 in Demo
« Reply #136 on: May 02, 2014, 11:07:57 AM »
Benny,

Perhaps I need to rephrase the question, I was wondering more what the Range was i.e.  Pulley range, rpm range, acceleration range etc... is that var, represent the total value of the full range, i.e.  Max - Min of what ever range it is measuring, etc.
Should have tried to clarify better.
Commercial Mach3 & Mach 4, Design/Build/Retrofit CNC and Industrial machines.
http://www.ss-systems-llc.com/
Re: Comments about Mach4 in Demo
« Reply #137 on: May 02, 2014, 11:20:29 AM »
That seemed like a odd question from your wisdom on programming, but did want to pass on some information to others as to how to get used to this new scripting. And don't be afraid of trying and learning something much more powerful then VB.
We ain't dead yet.

Most of my post are for general knowledge and enlightenment. The ole instructor in me.

Offline simpson36

*
  •  1,369 1,369
    • View Profile
Re: Comments about Mach4 in Demo
« Reply #138 on: May 02, 2014, 11:21:18 AM »
MACH Config - Input signals tab - first column is not resizable - text truncated

Don't see it here...

The issue is also present on Axis Mapping, Homing, Input, Output and Spindle tabs.

By 'first column, I refer to the gray colored column that has, for lack of a better term, the 'titles' for each line. This column cannot be resized on my system. Some of the 'titles' exceed the available space and are therefor truncated. In most cases, this is not much of a problem, but some of the titles need to be guessed at, which is not a good thing.

They ALL drag and display properly here, top row as well as columns.
Dell laptop
XP SP3

Russ

I do not understand what I could be doing wrong, then. No matter ho slowly or carefully I float
 the cursor over the vertical line between COLUMN 1 and 2, I do not get the expand cursor as I get with every other vertical line between COLUMNS.

To make sure we are on the same page, I am attaching a screen capture with the first column circled. How do I make this column wider?

Offline simpson36

*
  •  1,369 1,369
    • View Profile
Re: Comments about Mach4 in Demo
« Reply #139 on: May 02, 2014, 11:46:49 AM »

So, with Lua replacing VBscript, how is the above described process handled by MACH4? Specifically, does MACH4 suspend the G-code execution until macros return or will the programmer still have to test and insert delays to assure this happens?

Secondly, will macros be able to have any legal windows file name and be called by a 'RunScript' (or equiv) call?


simpson36,

First I want to explain the main difference between how mach3 handled Mcodes and how mach4 handles Mcodes.  In mach3 every time a Mcode was called from gcode or a RunScript command mach would go find the mcode load that single VB script, compile it and then run it.  So in mach3 every mcode was run on its own thread and the only way to have one mcode pass variables to another mcode was through a DRO, LED ect.

Now lets talk about mach4!!


Andrew, thanks for the info. It does help. However, my original question remain:

1) Does MACH4 wait for a return from a 'function' before it parses the next G-code block.
 - and-
2) Can 'named' (sorry, I don't know what else to call them) scripts residing in legally named Windows files be called from a 'function'.

Here is an example:

'© 2012 www.theCUBEstudio.com
'NAME:       M4011
'ACTION:    Runs script to set Lathe mode ON
'USE:          embedded macro

 
If RunScript("\macros\Simpson\4thAxisModeOFF") < 0 Then
MsgBox "RunScript 4thAxisModeOFF returned an error"
End If


The above 'numbered' macro calls the following 'named' macro:

'© 2012 www.theCUBEstudio.com
'NAME:      4thAxisModeOFF
'ACTION:    Macro to set Axis mode
'USE:       Called From M4011 - embed in Gcode
'NOTE       'unconditionally enables 4th axis   - built from 4thAxisModeSWITCH macro


Style1 = 4 + 32   '4=display Yes and NO buttons only 32 = Question Icon
Style2 = 0 + 48  '0= display OK button only 48=Exclamation Icon

GoFlag = true

DriveDisabled = GetUserLED(1003)
IndexON = GetUserLED(1004)
SpindleON = GetUserLED(1005) + GetUserLED(1006)  'Either Spindle ON CW or CCW will = true
CurrentRPM = GetUserDRO(1003)


' activate Turn MODE


 If (DriveDisabled = 1) Then           ' drive is disabled, enable drive
  If RunScript("\macros\Simpson\4thEnableON") < 0 Then
   MsgBox "RunScript 4thEnableON returned an error"
  End If      
 End If
   SetUserLED(1004,0)            ' Index Mode LED OFF
   SetModOutput(4,1)            ' set INDEX mode OFF thru Modbus
   Sleep(300)
sleep(20)


The larger 'named' macro is in the windows file 'c:\MACH3\macros\Simpson\4thIndexModeOFF.m1s'. The delays are primarily to allow enough time for the Modbus to finish processing. Because of the time involved to execute, this macro is problematic to run directly as an 'M*********' macro because MACH3 would be off and crunching thru the next several G-code blocks before the macro completes.

So, if any of the above makes sense, can anyone either answer the two questions above or perhaps just describe how to duplicate this functionality in MACH4?

Much appreciated!

« Last Edit: May 02, 2014, 11:50:42 AM by simpson36 »