Machsupport Forum
Mach Discussion => VB and the development of wizards => Topic started by: Deon Gerber on November 01, 2020, 02:02:58 PM
-
Hi all
Please Help.
I get the above error while posting code generated by a Wizard Script that I am working on.
I do not get errors in the Script editor but only while posting to Mach3.
Full error Message:
Unknown Word starting with a , Block G1X [Tan[Ang / 2]]*[R*[1 - Cos[#203]]] A#203 on line 11
Been trying all afternoon to find the problem but no luck.
A nudge in the right direction will be appreciated.
Thanks
Deon
Full code to follow.
%
G0 G40 G54 G90 G49 G17 G50 G64 G91.1 G94
G0 Z95
G0 A0.000 X0.000 F6
M98 P01 L72
G0
G92 X
M98 P02 L180
M30
o01
M8
G1X [Tan[Ang / 2]]*[R*[1 - Cos[#203]]] A#203
#203=#207+#203
M99
%
-
Where is it getting 'R' from?
Split it down and try to see where the fault is.
G1X [Tan[Ang / 2]]*[R*[1 - Cos[#203]]] A#203
-
Thx for the reply. Now that you mentioned R...........Mabe I must also declare R and Ang as variables(setVar). I had .a problem with my normal naming syntax of variables whate I used an A as Angle........it did not like that. Interfered with A Axis. Will try it when I get home. Thanks
-
You need to put every variable into a #number and then use them for the maths.
e.g.
G21 G40 G00 G90
G00 X0 Y0
#100 = 45 (Angle)
#101 = 2.5 (length)
#102 = [SIN[[#100 / 2]]]
#103 = [#102 * #101]
#104 = [COS[[#100 / 2]]]
#105 = [#104 * #101]
G00 X#103 Y#105
M30
Etc.
-
Hi Graham
Thanks for the tip. I have done the following.
' G1X [Tan[Ang / 2]]*[R*[1 - Cos[#203]]] A#203
'*******************************
Setvar(101, tan(Ang/2))
Setvar(102, R)
Setvar(103, D)
Setvar(104, Num)
Setvar(105, ADiv)
Code "G1 X [#101*[#102 *[1-cos[#104]]]] A#104"
Code "#104=[#105+#104]"
It seems to not be happy with the 1-cos[#104] part of the macro.
Not sure how to reduce this into a single Var because with the line just after that #104 gets update by an increment each time for the rest of the cycles the sub is running.
Thanks for your help in advance.
Regards
Deon.
-
I am confused now, are you wanting to do this in VB or in Gcode you have given examples of both.
-
Hi
Sorry for the confusion. You are correct. The last post I showed the VBscript that runs to output the GCode in the first post.
The VBscript runs with out any errors showing up in Mach3's VB editor. But the toolpath do not display in the toolpath window. When you exit the Wizard then Mach3 is complaining about a bad carracter in the gcode. (The line I mentioned in the first post)
If I remove the [1-Cos[#104]] then Mach3 do not complain about the code anymore. Telling me that the format in that part of the equation is the problem.
Obviously the output gcode is then not what I need, thats why I asked if there was a way to simplify that part of the equation in the VBscript.
Hope all will make better sense now.
Thanks for trying to help.
Deon
-
Replace the 1 with a # var
g00 g90 x0 y0
#106 =1
#104 = 30
#107 = [#106 - [Cos[#104]]]
g00 x#107
m30
-
can you explain what you want to do.
might be easier to get a solution.
-
Hi Graham
Thx. That looks like its been solved. Am I safe to assume that it does not like the numerical value of 1.
Thanks for the help.
Deon
-
The Mach3 parser is a bit limited and soon gets confused.
It is not keen on any real numbers in a calculation.
#100=-1 is also a problem. #100 = [1 * -1] works.
The safest way is to keep the lines simple and always put values into #vars with lots of enclosing square brackets.
-
Thanks Graham. Will keep that in mind.