Hello Guest it is April 16, 2024, 05:17:30 PM

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 - duritskiy

Pages: 1 2 »
1
Mach4 General Discussion / mc.mcIoSetDesc() not save in profile
« on: August 04, 2023, 09:26:41 AM »
hIo, rc = mc.mcIoGetHandle(inst, "Sim0/Input0")
ioinf, rc = mc.mcIoGetInfoStruct( hIo)
rc = mc.mcIoSetDesc(hIo, "Input0 test desc")

-- this code not saving changes to profile

rc = mc.mcProfileFlush(inst)
rc = mc.mcProfileSave(inst)

-- and this code not help

2
Mach4 General Discussion / Encoder -> Updetae Planner
« on: July 28, 2023, 12:36:43 PM »
Configure/Control/Aux Positions/  Updates Planner

What is it mean "Updates Planner" ?

I did not notice that the inclusion of this checkbox would affect anything.
Can this be used for position correction by optical linear encoders


3
Mach4 General Discussion / noticed two problems with MACH4
« on: July 15, 2023, 07:55:27 AM »
I have two computers:

Work computer with CNC machine:
Windows 10 x64, Integrated video card, Mach4 v5157, ESS v298

home laptop:
Windows 7 x64, integrated and optional graphics card, Mach4 v5157.

Settings and scripts on Mach4 are the same for both computers.

1) First problem:

In PLCScript,
this code
Code: [Select]
local ActiveWindowText , rc = scr.GetActiveWindowText()
mc.mcCntlLog(0, tostring(ActiveWindowText), "", -1 )

prints the name of the active window to the Log, and in Windows 7 this code works without problems.
But in Windows 10 it works with glitches. It looks like the scr.GetActiveWindowText function is not limiting the string length correctly, and writes after the correct text any rubbish. It would be nice if you fix this, or add a new function scr.GetActiveWindowTextLength()

2) Second problem:
On Mach4 on Windows 7, if you check the CheckBox "Use a frame to draw the tool path? (Restart required)"
then the ToolPath graphics window stops responding to the mouse wheel, that does not change the magnification.
On Windows 10, I don't remember if there is such a problem. If so, I'll write about it later.

4
in the screenset you can see the code of the button yourself

5
function SaveMachinePosition()   
   local inst = mc.mcGetInstance()
   mc.mcProfileWriteDouble(inst, "MyConfig", "MachinePosX", mc.mcAxisGetMachinePos(inst, mc.X_AXIS))
   mc.mcProfileWriteDouble(inst, "MyConfig", "MachinePosY", mc.mcAxisGetMachinePos(inst, mc.Y_AXIS))
   mc.mcProfileWriteDouble(inst, "MyConfig", "MachinePosZ", mc.mcAxisGetMachinePos(inst, mc.Z_AXIS))
   mc.mcProfileWriteDouble(inst, "MyConfig", "MachinePosA", mc.mcAxisGetMachinePos(inst, mc.A_AXIS))

   mc.mcProfileWriteDouble(inst, "MyConfig", "PosX", mc.mcAxisGetPos(inst, mc.X_AXIS))
   mc.mcProfileWriteDouble(inst, "MyConfig", "PosY", mc.mcAxisGetPos(inst, mc.Y_AXIS))
   mc.mcProfileWriteDouble(inst, "MyConfig", "PosZ", mc.mcAxisGetPos(inst, mc.Z_AXIS))
   mc.mcProfileWriteDouble(inst, "MyConfig", "PosA", mc.mcAxisGetPos(inst, mc.A_AXIS))
   mc.mcProfileSave(inst)
   mc.mcProfileFlush(inst)
end

function LoadMachinePosition()   
   local inst = mc.mcGetInstance()
   
   local MachinePosX = mc.mcProfileGetDouble(inst , "MyConfig", "MachinePosX", 0)
   local MachinePosY = mc.mcProfileGetDouble(inst , "MyConfig", "MachinePosY", 0)
   local MachinePosZ = mc.mcProfileGetDouble(inst , "MyConfig", "MachinePosZ", 0)
   local MachinePosA = mc.mcProfileGetDouble(inst , "MyConfig", "MachinePosA", 0)
   
   local PosX = mc.mcProfileGetDouble(inst , "MyConfig", "PosX", 0)
   local PosY = mc.mcProfileGetDouble(inst , "MyConfig", "PosY", 0)
   local PosZ = mc.mcProfileGetDouble(inst , "MyConfig", "PosZ", 0)
   local PosA = mc.mcProfileGetDouble(inst , "MyConfig", "PosA", 0)

   local HomeOffsetX_Saved, rc = mc.mcAxisGetHomeOffset(inst, mc.X_AXIS)
   local HomeOffsetY_Saved, rc = mc.mcAxisGetHomeOffset(inst, mc.Y_AXIS)
   local HomeOffsetZ_Saved, rc = mc.mcAxisGetHomeOffset(inst, mc.Z_AXIS)
   local HomeOffsetA_Saved, rc = mc.mcAxisGetHomeOffset(inst, mc.A_AXIS)
      
   local HomeInPlaceX_Saved, rc = mc.mcAxisGetHomeInPlace(inst, mc.X_AXIS)
   local HomeInPlaceY_Saved, rc = mc.mcAxisGetHomeInPlace(inst, mc.Y_AXIS)
   local HomeInPlaceZ_Saved, rc = mc.mcAxisGetHomeInPlace(inst, mc.Z_AXIS)
   local HomeInPlaceA_Saved, rc = mc.mcAxisGetHomeInPlace(inst, mc.A_AXIS)
   
   local SoftlimitEnableX_Saved, rc = mc.mcAxisGetSoftlimitEnable(inst, mc.X_AXIS)
   local SoftlimitEnableY_Saved, rc = mc.mcAxisGetSoftlimitEnable(inst, mc.Y_AXIS)
   local SoftlimitEnableZ_Saved, rc = mc.mcAxisGetSoftlimitEnable(inst, mc.Z_AXIS)
   local SoftlimitEnableA_Saved, rc = mc.mcAxisGetSoftlimitEnable(inst, mc.A_AXIS)
         
--   local MachinePosX=math.random()*100
   
   mc.mcAxisSetHomeInPlace(inst, mc.X_AXIS,1)
   mc.mcAxisSetHomeInPlace(inst, mc.Y_AXIS,1)
   mc.mcAxisSetHomeInPlace(inst, mc.Z_AXIS,1)
   mc.mcAxisSetHomeInPlace(inst, mc.A_AXIS,1)
   
   mc.mcAxisSetSoftlimitEnable(inst, mc.X_AXIS,1)
   mc.mcAxisSetSoftlimitEnable(inst, mc.Y_AXIS,1)
   mc.mcAxisSetSoftlimitEnable(inst, mc.Z_AXIS,1)
   mc.mcAxisSetSoftlimitEnable(inst, mc.A_AXIS,1)
   
   mc.mcAxisSetHomeOffset(inst,mc.X_AXIS, MachinePosX)
   mc.mcAxisSetHomeOffset(inst,mc.Y_AXIS, MachinePosY)
   mc.mcAxisSetHomeOffset(inst,mc.Z_AXIS, MachinePosZ)
   mc.mcAxisSetHomeOffset(inst,mc.A_AXIS, MachinePosA)

   rc=mc.mcProfileSave(0)
--   rc=mc.mcProfileFlush(0) --Flush changes to the INI file.

--   rc = mc.mcAxisDeref(inst, mc.X_AXIS);
--   rc = mc.mcAxisDeref(inst, mc.Y_AXIS);
--   rc = mc.mcAxisDeref(inst, mc.Z_AXIS);
--   rc = mc.mcAxisDeref(inst, mc.A_AXIS);

   rc = mc.mcAxisDerefAll(inst);
   
--   Message(HomeOffsetX_Saved.. " -X> ".. MachinePosX .. " mc.mcAxisGetHomeInPlace(inst, mc.X_AXIS)="..mc.mcAxisGetHomeInPlace(inst, mc.X_AXIS))
--   Message(HomeOffsetY_Saved.. " -Y> ".. MachinePosY)
--   Message(HomeOffsetZ_Saved.. " -Z> ".. MachinePosZ)
--   Message(HomeOffsetA_Saved.. " -A> ".. MachinePosA)

   local OSIG_MACHINE_ENABLED_saved = GetSignal(mc.OSIG_MACHINE_ENABLED)
   if (OSIG_MACHINE_ENABLED_saved==0) then
      mc.mcCntlEnable(inst,1)
--      Sleep(100)
   end
   
   mc.mcCntlReset(inst)
   rc = mc.mcAxisHome(   inst, mc.X_AXIS)
   mc.mcCntlReset(inst)
   rc = mc.mcAxisHome(   inst, mc.Y_AXIS)
   mc.mcCntlReset(inst)
   rc = mc.mcAxisHome(   inst, mc.Z_AXIS)
   mc.mcCntlReset(inst)
   rc = mc.mcAxisHome(   inst, mc.A_AXIS)
   mc.mcCntlReset(inst)
   
   mc.mcAxisSetHomeOffset(inst, mc.X_AXIS,HomeOffsetX_Saved)
   mc.mcAxisSetHomeOffset(inst, mc.Y_AXIS,HomeOffsetY_Saved)
   mc.mcAxisSetHomeOffset(inst, mc.Z_AXIS,HomeOffsetZ_Saved)
   mc.mcAxisSetHomeOffset(inst, mc.A_AXIS,HomeOffsetA_Saved)
   
   mc.mcAxisSetSoftlimitEnable(inst, mc.X_AXIS,SoftlimitEnableX_Saved)
   mc.mcAxisSetSoftlimitEnable(inst, mc.Y_AXIS,SoftlimitEnableY_Saved)
   mc.mcAxisSetSoftlimitEnable(inst, mc.Z_AXIS,SoftlimitEnableZ_Saved)
   mc.mcAxisSetSoftlimitEnable(inst, mc.A_AXIS,SoftlimitEnableA_Saved)
         
   mc.mcAxisSetHomeInPlace(inst, mc.X_AXIS,0)
   mc.mcAxisSetHomeInPlace(inst, mc.Y_AXIS,0)
   mc.mcAxisSetHomeInPlace(inst, mc.Z_AXIS,0)
   mc.mcAxisSetHomeInPlace(inst, mc.A_AXIS,0)
   
   rc=mc.mcProfileSave(0)
   rc=mc.mcProfileFlush(0) --Flush changes to the INI file.
   
   mc.mcAxisSetPos(inst, mc.X_AXIS,PosX)
   mc.mcAxisSetPos(inst, mc.Y_AXIS,PosY)
   mc.mcAxisSetPos(inst, mc.Z_AXIS,PosZ)
   mc.mcAxisSetPos(inst, mc.A_AXIS,PosA)
   
   mc.mcCntlEnable(inst,OSIG_MACHINE_ENABLED_saved)
end

6
Mach4 General Discussion / How to get Input0 User Description from lua?
« on: October 07, 2022, 03:42:57 AM »
How to get Input0 User Description from lua?
I couldn't find a suitable function for this.

7
Mach4 General Discussion / MODBUS issues...
« on: October 06, 2022, 07:08:04 AM »
"Write multiple registers 32bit (0x10)" - work without bit packing mode
"Write multiple registers 32bit (0x10)" - does not work in bit packing mode

"Write multiple registers 32bit (0x10)"  - working
"Write multiple registers Float (0x10)"  - not working

"Read Holding Registers 32bit (0x3)" - working
"Read Input Registers 32bit (0x4)" - working
"Read Input Registers Float (0x4)" - not working
"Read Holding Registers Float (0x3)"  - not working

8
Mach4 General Discussion / Quick way to update lua scripts in Mach4.
« on: October 04, 2022, 03:12:14 PM »
I found a way how to quickly change the lua script of Mach4.

At first I wanted to write a complete description of how to do this, but then I got too lazy and decided to just post the source code. I think you will understand.

If anyone decides to review this method on YouTube, I will only welcome.

https://disk.yandex.ru/d/jUAfp_VWt4r9jg

9
As far as I understand, modbus has not yet been brought to the ideal?
For example, it looks like the function
"Write multiple registers 32bit (0x10)" does not work in bit packing mode. And "Write multiple registers 16bit (0x10)" works.

10
The serial speeds are actually coming from the MODBUS library we use.  I'll ask them to see if they will make it customizable.

There is a possibility to use non-standard baudrate.
I already use these settings now and it works.
[Machine.ini]
Baud=1000000

Pages: 1 2 »