Hello Guest it is March 29, 2024, 06:36:38 AM

Author Topic: G code to change rapid speeds  (Read 974 times)

0 Members and 1 Guest are viewing this topic.

G code to change rapid speeds
« on: December 15, 2021, 04:19:03 AM »
I have a third-party controller on which it is possible to change rapid speeds, I find it very convenient, if possible I would like to use a similar function with Mach4 too, is it possible?
I give example:
G103 V3000
the value of 3000 will be expressed in mm / min (I am European) and will be the maximum threshold.
being a G code it is modal.
to bring the axis speed back to the maximum it will be sufficient to write
G103 V0
thanks for any information.
Re: G code to change rapid speeds
« Reply #1 on: December 15, 2021, 05:43:30 AM »
You can use the following inside a custom macro to set the rapid speed as a percentage. You can pass a value to the macro from the gcode and set it. e.g. M103 V2000. To set it as mm/min you would just have to calculate the percentage of the max rapid speed.

I've just thrown this together... Not tested..

Code: [Select]
function m103(hParam)
local inst = mc.mcGetInstance();
local maxVel = 3000
if (hParam ~= nil) then

local vVal = mc.mcCntlGetLocalVar(inst, hParam, mc.SV_V)
local vFlag = mc.mcCntlGetLocalVarFlag(inst, hParam, mc.SV_V)

local RROpercent = (vVal/maxVel)*100

if(vFlag == 1) then
mc.mcCntlSetRRO(inst, RROpercent)
end
end
end
« Last Edit: December 15, 2021, 05:51:21 AM by SwiftyJ »
Re: G code to change rapid speeds
« Reply #2 on: December 15, 2021, 06:33:10 AM »
OK thanks!
I'll try tomorrow!
Re: G code to change rapid speeds
« Reply #3 on: December 16, 2021, 02:15:05 AM »
the macro works
but that's not what I wanted to do.
your code moves the slide.
I own CsLab CSMIO-IP / S.
I associated Feed + Rapid with the same potentiometer via plugin.
consequently the plugin takes priority over control.
to make it work it is necessary to impose the limit threshold on Mach4, and not on the functions.
Re: G code to change rapid speeds
« Reply #4 on: December 16, 2021, 03:50:53 AM »
So you are saying you need to increase the max velocity in the Mach4 motor config. If this is the case then you would use

rc = mc.mcMotorSetMaxVel(number mInst,    number motorId, number maxVel)

But I do not know if this is possible during execution of g-code.
Re: G code to change rapid speeds
« Reply #5 on: December 16, 2021, 03:57:57 AM »
no, I want to decrease the maximum speed of the rapid.
tested the first gcode, the quick value will be reported to 100%