Hello Guest it is February 24, 2026, 01:25:49 AM

Author Topic: Registers  (Read 89 times)

0 Members and 1 Guest are viewing this topic.

Registers
« on: February 17, 2026, 09:23:08 AM »
I've been attempting to use Registers for an automatic unload/reload of a dustboot. Here is my script so far.

In m6 I have
require "dustboot"
and have placed DropDustBoot() and PickupDustBoot() in appopriate places.


And here is my DustBoot.lua file. All of the mcRegGetHandle() always return 0 for the hreg and rc of 0. 
As well mcRegGetValue() calls have a return code of -27 and return 0 even when there's definitely values in the registers. Yes iRegs0/DustBoot/* all exist. -27 indicates it doesn't exist which should be correct as a register 0 doesn't exist but then the Gethandle should have told me that.
hreg,rc = mc.mcRegGetHandle(inst, "core/global/Version") fails with a hreg of 0 and a rc of 0. Either that exists or Mach is not running.

I believe this is ALL IPC related. Mach4 with it's wxprobe screen doesn't recognize probes have activated. This script fails there as well. I'm open to suggestions here.


local DustBoot = {}

-- Dustshoe Entry Settings
local inst = mc.mcGetInstance()

local hreg, rc, ignoreDustBoot
local DustBootX = 46.2057   
local DustBootY = 11
local DustbootZ = -3.7143
local DustbootRateY = 100
local DustBootRateZ = 200
local DustBootYSlide = 4   
local DustBootStatus

hreg, rc = mc.mcRegGetHandle(inst, "iRegs0/DustBoot/ignoreDustBoot")

if (rc == 0) then
    ignoreDustBoot, rc = mc.mcRegGetValue(hreg)
   hreg, rc = mc.mcRegGetHandle(inst, "iRegs0/DustBoot/DustBootX")
   DustBootX, rc = mc.mcRegGetValue(hreg)
   
   hreg, rc = mc.mcRegGetHandle(inst, "iRegs0/DustBoot/DustBootY")
    DustBootY , rc = mc.mcRegGetValue(hreg)
   
   hreg, rc = mc.mcRegGetHandle(inst, "iRegs0/DustBoot/DustBootZ")
   DustBootZ, rc = mc.mcRegGetValue(hreg)


   hreg, rc = mc.mcRegGetHandle(inst, "iRegs0/DustBoot/DustBootRateY")
   DustBootRateY, rc = mc.mcRegGetValue(hreg)

   hreg, rc = mc.mcRegGetHandle(inst, "iRegs0/DustBoot/DustBootRateZ")
   DustBootRateZ, rc = mc.mcRegGetValue(hreg)

    hreg, rc = mc.mcRegGetHandle(inst, "iRegs0/DustBoot/DustBootYSlide")
   DustBootYSlide, rc = mc.mcRegGetValue(hreg)

    hreg, rc = mc.mcRegGetHandle(inst, "iRegs0/DustBoot/DustBootStatus")
   DustBootStatus, rc = mc.mcRegGetValue(hreg)   
else
    ignoreDustBoot = 0
end

                                          ------ How far from dustshoe to start with Y Park Movement
   
-- =========================================================== drop dust boot =============================================================================
function DropDustBoot()

    if (ignoreDustBoot == 1 or DustBootStatus == 0) then
      do return end
    end

   GCode = "G00 G90 G53 Z-1\n"                                                             ------ Z Up   
   rc = mc.mcCntlGcodeExecuteWait(inst, GCode)

   if (rc ~= 0) then
      do return end
   end
   GCode =  string.format("G00 G90 G53 X%.4f Y%.4f \n", DustBootX, DustBootY-DustBootYSlide)       ------ TO DUSTSHOE ENTRY
   mc.mcCntlGcodeExecuteWait(inst, GCode)
            
   GCode =  string.format("G00 G90 G53 Z%.4f\n", DustBootZ)                                     ------ TO DUSTSHOE Z
   mc.mcCntlGcodeExecuteWait(inst, GCode)
            
   GCode = string.format("G01 G90 G53 Y%.4f F%.4f\n", DustBootY,DustBootRateY)                        ------ MOVE Y INTO DUSTSHOE HOLDER
   mc.mcCntlGcodeExecuteWait(inst, GCode)
            
   GCode = "G00 G90 G53 Z-1\n"                                                             ------ PICK UP Z --- DROP SHOE IN HOLDER --
   mc.mcCntlGcodeExecuteWait(inst, GCode)
            
   GCode =  string.format("G00 G90 G53 Y%.4f \n", DustBootY-DustBootYSlide)                      ------ MOVE TO SAFE Y
   mc.mcCntlGcodeExecuteWait(inst, GCode)
   hreg = mc.mcRegGetHandle(inst, "DustBoot/DustBootStatus")
   mc.mcRegSetValue(hreg, 0)
end


--  ============================================================ PICKUP DUST SHOE ==========================================================================   
   
function PickupDustBoot()   
   if (ignoreDustBoot == 1 or DustBootStatus == 1) then
      do return end
    end
   local toolnum, rc = mc.mcToolGetCurrent(inst)
    if (toolnum == 0) then
      do return end
   end
   
   mc.mcCntlGcodeExecuteWait(inst, "G00 G90 G53 Z-1.0\n")                                       ------ Z UP
   
   GCode =  string.format("G00 G90 G53 X%.4f\n", DustBootX)                                  ------ To DustShoe Entry X
   mc.mcCntlGcodeExecuteWait(inst, GCode)
            
   GCode =  string.format("G00 G90 G53 Y%.4f\n", DustBootY)                                  ------ To DustShoe Entry Y
   mc.mcCntlGcodeExecuteWait(inst, GCode)
   
   GCode = string.format("G00 G90 G53 Z%.4f\n", DustBootZ+0.75)                                 ------ G00 Quick down to 20mm above DustShoe Pick Up
   mc.mcCntlGcodeExecuteWait(inst, GCode)
   
   GCode = string.format("G01 G90 G53 Z%.4f F%.4f\n", DustBootZ,DustBootRateZ)                     ------ DustShoe Pick Up
   mc.mcCntlGcodeExecuteWait(inst, GCode)
            
   GCode = string.format("G01 G90 G53 Y%.4f F%.4f\n", DustBootY-DustBootYSlide,DustBootRateY)      ------ DustShoe SlideOutY
   mc.mcCntlGcodeExecuteWait(inst, GCode)
   hreg = mc.mcRegGetHandle(inst, "DustBoot/DustBootStatus")
   mc.mcRegSetValue(hreg, 1)
end   

if mc.mcEditor() == 1 then
   DropDustBoot()
   PickupDustBoot()
end

return DustBoot

Re: Registers
« Reply #1 on: February 20, 2026, 01:56:50 PM »
If some API calls are working in IPC and others are not, then it may be a port conflict with Windows.

You can reserve the Mach IPC port range one line commands.  One is for TCP and the other is for UDP. 
 
These are for the Mach API over IPC.
netsh int add excludedportrange protocol=tcp startport=48000 numberofports=200 store=persistent
netsh int add excludedportrange protocol=udp startport=48000 numberofports=200 store=persistent
These commands reserve the port range 48000 to 48199 for both TCP and UDP. 
 
These are for the Screen IPC.
netsh int add excludedportrange protocol=tcp startport=48500 numberofports=200 store=persistent
netsh int add excludedportrange protocol=udp startport=48500 numberofports=200 store=persistent
These commands reserve the port range 48500 to 48699 for both TCP and UDP. 
 
A reboot may be required to get Windows to let go of the ports. 
Thanks,

Paul