Hello Guest it is March 28, 2024, 02:31:21 PM

Author Topic: set machine cordinate  (Read 926 times)

0 Members and 1 Guest are viewing this topic.

set machine cordinate
« on: May 01, 2021, 04:41:46 PM »
i want use absolute encoder ,and each time i turn on the mach ,or run any program,i want set the machine position
according value i read from driver
i tried:
local hsig = mc.mcMotorSetHomePos(0,0,num)
mc.mcAxisSetMachinePos
mc.mcAxisSetPos

all this but nothing work
how can do this?
Re: set machine cordinate
« Reply #1 on: May 01, 2021, 05:59:26 PM »
i even try this:
local bb=    mc.mcCntlSetPoundVar(0,5021,250)
local aaa = mc.mcCntlGetPoundVar(0, 5021)
   val = string.format(aaa)
   val2 = string.format(bb)
          mc.mcCntlSetLastError(0,val)
         mc.mcCntlSetLastError(0,val2)
and i can see that its show on the history that its change the value
but actually its didnt change it
and machine coordinate remind as its was before

Re: set machine cordinate
« Reply #2 on: May 04, 2021, 04:37:19 AM »
i'm probably wrong about this but machine position is the G53 coordinates ???

so, maybe Mach4 can only tell what these coordinates are only if the machine is homed.

then telling the computer to make the machine coordinates different should be illegal because then it destroys the purpose of referencing or homing machine.

maybe just use work offsets to move the machine to position after home. but then you'll have to calculate the encoder value relative to home which might be a PITA

but then again encoders typically just show counts which are usually have some sort of per unit division, so real-time position will be much more calculation.
« Last Edit: May 04, 2021, 04:40:30 AM by compewter_numerical »
Re: set machine cordinate
« Reply #3 on: May 04, 2021, 05:04:11 AM »
Its can't done by G because its should be something not done by user
I already find away( very complex but...)but there api that should do this ,but its not work,so i think maybe some one from mach can see and tell why its not work
Re: set machine cordinate
« Reply #4 on: May 04, 2021, 05:15:17 AM »
sorry, i don't understand your response.

would be helpful if you shared your result. it could probably help someone later.

you might find that what you think is complex.


« Last Edit: May 04, 2021, 05:16:56 AM by compewter_numerical »
Re: set machine cordinate
« Reply #5 on: May 04, 2021, 05:33:43 AM »
Sure
I define "home in place"
Then i made script that read the encoder value and put it in home offset
Then i make event that this script rise
In panel load i get the event and each time its rise( mean lua update the position) its make "all home reference"
Its sound crazy but this only way its work
But there bug
If one of the motor cofig as reverse,then some times value can be minus some times plus randomly without any rules
Thks
Re: set machine cordinate
« Reply #6 on: May 04, 2021, 05:43:25 AM »
the home offset lua api call doesn't change anything in the Mach4 core. it says that in the notes in the .chm file

I also replied this in another post, https://www.machsupport.com/forum/index.php?topic=44769.0

sorry but 'panel load' and 'script rises' is difficult to understand
« Last Edit: May 04, 2021, 05:46:40 AM by compewter_numerical »
Re: set machine cordinate
« Reply #7 on: May 04, 2021, 05:47:12 AM »
Now im far from computer but at night ill send you what i did,and its work fine, only that bug i told you,so if motor in reverse need change on driver
Re: set machine cordinate
« Reply #8 on: May 04, 2021, 05:48:49 AM »
well if you got it to works then good job