Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: rhtuttle on May 07, 2018, 11:32:46 AM
-
Trying to determine if my coding is incorrct or if Mach4 or PMDX411 is incorrect.
using the following code to produce tick marks on a dial. the first example uses an incremental approach to advance the C axis for each tick. The 2nd uses absolute positioning.
They produce different results
move h, deg
local n=scr.GetProperty('droNmarks','Value')
local dpth=scr.GetProperty('droMarkXdepth','Value')
local lngth=scr.GetProperty('droMarkXlength','Value')
local deg=360/n
local i,s
s=''
for i=1,n do
s=s..'g0 z-'..lngth..'\ng0 x-'..dpth..'\ng0z0\ng0x0\ng0 h'..tostring(deg)..'\n'
end
s=s..'g0 c0'
mc.mcCntlMdiExecute(mc.mcGetInstance(),s)
Absolute, move c, deg*i
local n=scr.GetProperty('droNmarks','Value')
local dpth=scr.GetProperty('droMarkXdepth','Value')
local lngth=scr.GetProperty('droMarkXlength','Value')
local deg=360/n
local i,s
s=''
for i=1,n do
s=s..'g0 z-'..lngth..'\ng0 x-'..dpth..'\ng0z0\ng0x0\ng0 c'..tostring(deg*i)..'\n'
end
s=s..'g0 c0'
mc.mcCntlMdiExecute(mc.mcGetInstance(),s)
The latter gives correct results but both should be the same.
TIA
RT
-
Hi,
is it a typo but in the first piece of code:
\ng0 h'..tostring
Whereas in the second:
\ng0 c'..tostring
What's the 'h' axis?
Craig
-
Mach4 follows fanuc implementation so for lathe there is no g91. X,Y,Z,A axis are referred to as U,V,W,H for incremental mode.
-
Hi,
OK but why then are you using 'h' in one but 'c' in the other. Is 'h' equivalent to incremental 'a' or.....?
Craig
-
sorry, not A but C. No incremental support for A or B, just C
-
Hi,
kool, learn something new every day!
That still leaves the original question unanswered. The code looks good.
When you say the incremental version doesn't work....what does it do?
Craig
-
Hi,
thinking a little more about this may I suggest some experiments to find out whats going on.
First just set up a script to rotate the C axis in discrete steps... something like
local s
Local for i=1 to 100
s=s..'g0 h5\n'
end
mc.mcCntlMdiExecute(mc.mcGetInstance(),s)
The next question I have is 'is it possible that the lines of Gcode presented to the interpreter are returning
before being executed and being lost?'
Maybe something like this
local i,s
for i=0,100
s='g0 h5'
mc.mcCntlMdiExecuteWait(mc.mcGetInstance(),s)
end
Craig
-
Hi Craig,
Since both strings passed to the interpreter contain the same number of lines and characters they would both fail but the absolute one does execute as expected.
I have attached two pictures. Two ops were run on each. A 25 tic, .100" length and a 5 tic .200" length. You can see in the incremental photo that the spacing from the 25 is short and the 5 tic does not line up with the 25 tic.
If there is someone out there that has Mach4 on a lathe with a rotary that could test the 2 code samples it could narrow it down as to whether it is Mach4 or pmdx411 that is failing.
TIA
RT
-
Hi,
sorry I have a Mach4 mill only.
I follow your argument that both strings are the same length, ergo length is not the determinate.
It rather suggests that 'h' axis movement is not properly supported by Mach.
Craig
-
Do you do an absolute return to start before the second cut ?
-
Yes, I home the C axis.
-
Hi RT,
how about having your program cut marks at 10 degrees say, but over two revolutions. I ideally the cuts made during the second revolution would land
on top of the cuts made during the first revolution.
It may give some insight into whats happening.
Craig