Hello Guest it is March 29, 2024, 09:58:35 AM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - MachMotion Development Team

Pages: « 1 2 3 4 5 6 »
31
Mach4 General Discussion / Re: Mcodes ??
« on: December 01, 2014, 10:59:07 AM »
Attached is the M700 mcode. Example: M700 A2 B3

32
Mach4 General Discussion / Re: Mcodes ??
« on: December 01, 2014, 10:57:05 AM »
M700 A1.5 B2.5

That should work fine... I will post the mcodes so you can download and test.

33
Mach4 General Discussion / Re: Mcodes ??
« on: December 01, 2014, 10:17:28 AM »
This is a example of how to read parameters in a Mcode for Mach4.  You can use any of the parameters in this list.

-----------------------------------------------------------------------------
-- Machine Type: Standard Mill Control
-- Author: MachMotion Development Team
-- Created: 09/24/2013
-- Modified by: MachMotion Development Team
-- Modified on: 01/10/2014
-- Description: Example: Reading Variables into MCodes
-- Copyright: © 2013-2014 Edge Solutions LLC All Rights Reserved
-----------------------------------------------------------------------------

function m700(hVars)
   local macroname = "m700"
   local a,b,c,rc
   local inst = mc.mcGetInstance() -- Get the current instance

   local nilPoundVar = mc.mcCntlGetPoundVar(inst,0)
   
   local message = ""
   if hVars ~= nil then
      
        local ParameterLetterArray = {"A", "B", "C", "D", "E", "F", "H", "I", "J", "K", "L", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}
        local ParameterNumberArray = {mc.VAR_A, mc.VAR_B, mc.VAR_C, mc.VAR_D, mc.VAR_E, mc.VAR_F, mc.VAR_H, mc.VAR_I, mc.VAR_J, mc.VAR_K, mc.VAR_L, mc.VAR_P, mc.VAR_Q, mc.VAR_R, mc.VAR_S, mc.VAR_T, mc.VAR_U, mc.VAR_V, mc.VAR_W, mc.VAR_X, mc.VAR_Y, mc.VAR_Z}
        for i = mc.VAR_A, #ParameterNumberArray do
         rc = mc.mcCntlGetLocalVar(inst, hVars, ParameterNumberArray)
         message = message .. "#" .. ParameterLetterArray .. ":" .. tostring(rc) .. ", "
      end
      wx.wxMessageBox(message)
   end
   return nil, true, macroname .. " Ran Successfully"
end

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

34
Mach4 General Discussion / Re: Comments about Mach4 in Demo
« on: May 02, 2014, 12:53:02 PM »

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!



simpson36,

To try to answer your question.
1. Yes mach will wait for a return before executing the next block
2. You can use named like 4thAxisModeOFF.mcs and then in your M4011 you could call the script with 4thAxisModeOFF().

When you make your scripts make sure you name the script the same name as the function in the script.

Scott - The range is the pulley range, and in mach4 each range has it own accel and decel parameters.

Andrew
MachMotion

35
Mach4 General Discussion / Re: Comments about Mach4 in Demo
« 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

36
dspMC/IP Motion Controller / Re: Saving Softlimits
« on: December 05, 2011, 10:44:23 AM »
Hi, soft limits are working in the DSPMC... How are you setting them?  You have to go to Config>Homing/Limits to configure them.  If you update the soft limits from the dros the changes will not be saved in the xml.

If you are already configuring them through the Homing/Limits dialog and its not working give me a call at: 573.368.7399 and ask for Andrew.

Andrew
MachMotion

37
Hi,

There is a new feature called "low pass filter" on the latest plugin.  I have found it to be very helpful in getting rid all the noise from the servo motors.  It will still leave you with a very "hard" tune.  Please let me know if you have already tried this, for larger motors we we set it to 10-15 and for medium motors set it to 5-10.

Andrew
MachMotion

38
General Mach Discussion / Re: Barcode Plugin *** Andrew question
« on: September 04, 2011, 08:03:17 PM »
Hi,

I don't know if there is a notify plugin call, but you could turn on a UserLED and the plugin could watch the LED and then run the code.

Andrew

39
dspMC/IP Motion Controller / Re: How to change the DRO for RPM?
« on: August 08, 2011, 08:50:32 AM »
Hi,

The best fix would be mount your encoder to the spindle output 1:1, normally the counts value is the number of encoder counts for 1 turn of the encoder.

Andrew

40
General Mach Discussion / Re: Interfacing to Ah-ha control
« on: January 24, 2011, 03:12:00 PM »
Hi,

I have helped a few customers interface our controls to the old Ah-ha drive boxes.  All you need to do is make a crossover cable from their (I think DB37) to a DB25.  I just did it with 2 connectors and soldered wires in between.  Attached is a simple doc that I made a few years ago when I set one up.  There are 2 pins that need to be jumper-ed for enable, and they are not on this doc so you will need to look them up.  Or you could just make a cable and connect the DB37 to a BOB.

Andrew

PS. I just realized the PDF only shows the connections I made to the PPort.  So it really doesn't help you.  But I do know it can be done, I just don't have a document on it any more.  From what I remember all the IO is 5V and it uses standard Step and Dir.

Pages: « 1 2 3 4 5 6 »