Hello Guest it is January 28, 2020, 03:19:51 PM

Author Topic: Mechanical speed ranges in Mach4  (Read 263 times)

0 Members and 1 Guest are viewing this topic.

Re: Mechanical speed ranges in Mach4
« Reply #10 on: January 14, 2020, 02:22:02 AM »
yes, I forgot to write that I tried both ways.
I put the m40.mcs macros in the folder:
C: \ Mach4Hobby \ Profiles \ Mach4Lathe \ Macros

then I wrote this little gcode test.

%
M5
M40
T101
M30
;

M40 is ignored, does not change the scale.
Re: Mechanical speed ranges in Mach4
« Reply #11 on: January 14, 2020, 03:51:54 PM »
I forgot something?
or did I make a mistake?
Re: Mechanical speed ranges in Mach4
« Reply #12 on: January 15, 2020, 03:29:53 AM »
not to misunderstand, I would like to change this.
look at the picture.
Re: Mechanical speed ranges in Mach4
« Reply #13 on: January 15, 2020, 11:05:20 AM »
daniba73,  you're not going to get much help if you don't follow the advice as given.  You say that you tried both suggestions and they didn't work but did not provide what you 'actually' did.  Attach the macro file that you tried and the gcode that you tried as well.

RT
Re: Mechanical speed ranges in Mach4
« Reply #14 on: January 15, 2020, 06:18:49 PM »
ok, this is the gcode:
%
M5
M40
G97 S1000 M3
T101
G0 X100 Z10
G1 Z-20 G98 F100
G0 X150 Z10
M5
M42
G97 S1000 M3
T202
G0 X98 Z10
G1 Z-20 G98 F100
G0 X150 Z10
M5
M30
;
Re: Mechanical speed ranges in Mach4
« Reply #15 on: January 15, 2020, 06:51:53 PM »
Hi,
you've seen Smurph's recommendation about using lowercase in Gcode......is there any reason you ignore his advice?

Craig
My wife left with my best friend...
     and I miss him!
Re: Mechanical speed ranges in Mach4
« Reply #16 on: January 15, 2020, 07:15:49 PM »
function m42()
   local inst = mc.mcGetInstance("Spindle range 2")
   local rc
   local currentRange
   currentRange, rc = mc.mcSpindleGetCurrentRange(inst)
   if (currentRange == 2) then
      return -- nothing to do!
   end
   -- Do the machine dependent range change control.
   --
   -- End machine dependent range change control

   -- Next, tell Mach what rage we are now in IF the above is successful.
   mc.mcSpindleSetRage(inst, 2) <----Should be: mc.mcSpindleSetRange(inst, 2)
end

if (mc.mcInEditor() == 2) then (to debug it should be: if (mc.mcInEditor() == 1) then
    m42()
end

Offline smurph

*
  • *
  •  1,187 1,187
  • "That there... that's an RV."
    • View Profile
Re: Mechanical speed ranges in Mach4
« Reply #17 on: January 15, 2020, 07:31:21 PM »
Hi,
you've seen Smurph's recommendation about using lowercase in Gcode......is there any reason you ignore his advice?

Craig

I think there is a misunderstanding.  You don't have to call the m40.mcs macro script with lower case in G code.  But you do have to make the macro script filename lower case.  And the function name in the script should be lower case as well.

The first thing the interpreter does is lower case everything.  So if you had a line wit "M40" on it, when the interpreter processed that line it would do:

1. M40 -> m40  (lower case the M40 to m40)
2. Look for m40.mcs (notice the lower case filename).
3. Look for function m40() in the m40.mcs file (notice the lower case function name).

Steve
Re: Mechanical speed ranges in Mach4
« Reply #18 on: January 16, 2020, 04:38:31 AM »
I found and solved the problem, it was a writing error in the m40 macro that you had loaded.
this is correct:

function m40()
   local inst = mc.mcGetInstance("Spindle range 0")
   local rc
   local currentRange
   currentRange, rc = mc.mcSpindleGetCurrentRange(inst)
   if (currentRange == 0) then
      return -- nothing to do!
   end
   -- Do the machine dependent range change control.
   --
   -- End machine dependent range change control

   -- Next, tell Mach what rage we are now in IF the above is successful.
   mc.mcSpindleSetRange(inst, 0)
end

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




P.S in gdode and MDI it is recognized and applied whether you use uppercase or lowercase letters.
thank you so much!! you are great!!
« Last Edit: January 16, 2020, 04:41:55 AM by daniba73 »
Re: Mechanical speed ranges in Mach4
« Reply #19 on: January 16, 2020, 11:51:02 AM »
Is it possible to associate an output to the macro to activate a light bulb?