Hello Guest it is April 28, 2024, 09:50:07 AM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Bill_O

191
Mach4 General Discussion / Re: Read encoder
« on: August 05, 2021, 08:46:34 AM »
This is my code in the macro

local inst = mc.mcGetInstance()
   
   --get starting positon and encoder postion
   local hreg = mc.mcRegGetHandle(inst, 'iRegs0/StartPos')
   local hreg2 = mc.mcRegGetHandle(inst, 'iRegs0/StartEncPos')
   local StartEncPos = mc.mcRegGetValue(hreg2)
      
   --read rough position from position dro and set temp postion dro
   local TempPos = mc.mcAxisGetPos(inst, 0)
   
   --determine encoder counts moved
   local hreg3 = mc.mcRegGetHandle(inst, 'ESS/Encoder_0')
   local EncRawVal = mc.mcRegGetValue(hreg3)
   local EncMove = EncRawVal - StartEncPos
   
   --determine distace encoder moved
   local hreg4 = mc.mcRegGetHandle(inst, 'iRegs0/EncScale')
   local EncScale = mc.mcRegGetValue(hreg4)
   local EncPos = EncMove / EncScale
   
   --set position to encoder postion
   local GCode = string.format("G92 X%.4f\n", EncPos)
   mc.mcCntlGcodeExecute(inst, GCode)
   --wx.wxMilliSleep(2000)
   
   --calculate distance off
   local hreg5 = mc.mcRegGetHandle(inst, 'iRegs0/DistOff')
   local DistOff = EncPos - TempPos
   local rc = mc.mcRegSetValue(hreg5, DistOff)
   --wx.wxMilliSleep(2000)
   
   --if distance off too great move to position
   if (DistOff >= 0.010) then
      --move to position after actual position determined
      GCode = string.format("G1 F100 X%.4f\n", TempPos)
      mc.mcCntlGcodeExecute(inst, GCode)
   end
   if (DistOff <= -0.010) then
      --move to position after actual position determined
      GCode = string.format("G1 F100 X%.4f\n", TempPos)
      mc.mcCntlGcodeExecute(inst, GCode)
   end

192
Mach4 General Discussion / Re: Read encoder
« on: August 04, 2021, 05:37:31 PM »
I wrote a special M code.
At the end of the move I put in the M code.
It looks at the distance it was supposed to move, looks how far the encoder says it did move then corrects the move.
It will not work for an xy machine.
It only corrects at the end of the move.

193
Mach4 General Discussion / Re: Read encoder
« on: August 04, 2021, 02:21:06 PM »
I use it to verify and correct the position on a machine that does not need to be correct until the end.

194
Mach4 General Discussion / Re: Read encoder
« on: August 03, 2021, 12:22:23 PM »
I use an ESS and it puts the encoder value into a register.

Bill

195
Mach4 General Discussion / Re: API For Axis Homed
« on: July 21, 2021, 05:27:58 PM »
I think this is what you are looking for.

LUA Syntax:
homed, rc= mc.mcAxisIsHomed(
      number mInst,
      number axisId)


196
I could be wrong but i think you need to put a value for Running and Paused.

You have;
if (Paused) then

I think you need;
if (Paused=1) then


197
Mach4 General Discussion / Re: Carving comes out 4 inches off center
« on: July 02, 2021, 12:45:50 PM »
It wounds to me like either the motor is stalling or something is slipping.
Try slowing the move speed and make sure the screw or gear that moves it is tight.

198
Mach4 General Discussion / Re: Carving comes out 4 inches off center
« on: July 02, 2021, 10:26:04 AM »
Are you using stepper motors?

199
Sorry but I can not help you with that.
I just turn the spindle on and off.

200
Sorry I just turn a spindle on and off.
I use the same relays and I have the K1 relay jumper to the Pin "1" side and they work.