Hi,
So if I use regfile and update the register manually, the spindle turns on, changes speed etc.
Exactly, that proves if the register is updated then everything works.
When I say I'm not using M3, what I mean is I'm not using a separate M3 macro.
You ARE using m3, and note it is m3 NOT M3. m3 is a Mach4 built-in macro, it's there whether you like it or not. You may also write your own m3.
When Mach encounters an m3 call it will in the first instance looks in the macros directory of your profile, if it finds an m3 there it uses it, if not it searches further
up the directory tree until it finds an m3 to use, usually the built-in m3. This is a time when you MUST use proper notation, ie m3 not M3. Get used
to using lowercase, without leading zeros and without whitespace, this is how the Gcode interpreter parses the Gcode. When the interpreter is looking for
m3 for example its likely to miss M3, it's looking look a lowercase m.
So you have two choices:
1) Write your own m3. It will live in the macros folder of your profile. It will need to include everything that the built-in m3 includes PLUS whatever
else you want, which in your case would include updating the three registers that control the VFD.
2) Use the provided script, but which for whatever reason fails to update the speed register by adding a little code in the PLC script.
The script will be something like this:
local registerHandle=mc.mcRegGetHandle(inst,.....Path) -- Substitute Path with the full path to register wrtvfdspeed0
local speed=mc.mcGetPoundVar(inst, 2132)
speed = speed*........... -- You may need to do some arithmetic on the pound variable to bring into into line with the number the VFD expects.
mc.mcRegSetValue(registerHandle,speed)
Craig