Hello Guest it is April 17, 2021, 07:05:06 AM

Author Topic: mcAxisGetInfoStruct  (Read 1289 times)

0 Members and 1 Guest are viewing this topic.

mcAxisGetInfoStruct
« on: June 16, 2018, 04:13:22 PM »

        axis = Y_AXIS;
   rc = mcAxisGetInfoStruct(xh->mInst, axis, &ainf);
   if (rc)
      send_to_diag("mcAxisGetInfoStruct returned an error");

this is always returning -16 which is axis not found. I'm using the Sim plugin for a motion controller. Doesn't seem to matter what I send as an axis though, they all return -16.
xh->mInst is 0 and the structure is axisinfo_t. I'm using this function to gain access to  both Work coordinate's and machine coordinates.
I'm using build 3805 of Mach4. This is C++ code, not lua as i'm writing a plugin.
Re: mcAxisGetInfoStruct
« Reply #1 on: June 16, 2018, 08:22:29 PM »
part of the issue here is that if Mach4 is not in an enabled state, this function returns -16.  Not sure how to work around this, since I need to access the DRO position's in order to update my pendant display. This is because the state of the DRO's is saved and reloaded at Mach4 restart. The DRO's should be available at any time you request it. Setting them would be another story.
Re: mcAxisGetInfoStruct
« Reply #2 on: June 18, 2018, 11:05:19 AM »
If all you want is the axis position:

val, rc = mc.mcAxisGetPos(number mInst, number axisId)

HTH

RT

Offline Chaoticone

*
  • *
  •  5,626 5,626
  • Precision Chaos
    • View Profile
Re: mcAxisGetInfoStruct
« Reply #3 on: June 18, 2018, 02:46:20 PM »
mcAxisGetInfoStruct returns a table.

This is how I would get work and machine coords in lua.

Code: [Select]
local inst = mc.mcGetInstance()

local val, rc = mc.mcAxisGetPos(inst, mc.X_AXIS)

local xInfo, rc = mc.mcAxisGetInfoStruct(inst, mc.X_AXIS)

local xMpos = xInfo.Mpos --Machine position in user units.

;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!
Re: mcAxisGetInfoStruct
« Reply #4 on: June 18, 2018, 08:06:38 PM »
mcAxisGetInfoStruct returns a table.

This is how I would get work and machine coords in lua.

Code: [Select]
local inst = mc.mcGetInstance()

local val, rc = mc.mcAxisGetPos(inst, mc.X_AXIS)

local xInfo, rc = mc.mcAxisGetInfoStruct(inst, mc.X_AXIS)

local xMpos = xInfo.Mpos --Machine position in user units.



unfortunately though, if the machine is not enabled then you get a -16 error saying the AXIS does not exist. I'd prefer to use the structure myself since I get both work and machine coords.
Re: mcAxisGetInfoStruct
« Reply #5 on: June 18, 2018, 08:28:45 PM »
Hi,
is it possible that until the machine is enabled the info-structure/table is incomplete,
ie even if you could read the table it would not hold the info you require?

Craig
My wife left with my best friend...
     and I miss him!
Re: mcAxisGetInfoStruct
« Reply #6 on: June 18, 2018, 08:33:10 PM »
it's possible. but then mcAxisGetMachinePos and mcAxisGetPos shouldn't work either then.

I have it working now with the above two functions.. I just would have prefered the other way for cleanliness
Re: mcAxisGetInfoStruct
« Reply #7 on: June 18, 2018, 08:42:35 PM »
Hi,
good point, the info must be there somewhere.

How does this sound for an explanation....pure guess of course...ALL the required data is held in Registers, aka
the pound variables, but the info structure is only ever populated when the machine is enabled. If the structure is
not formed, or complete, or current it effectively does not exist.

Craig
My wife left with my best friend...
     and I miss him!

Offline Chaoticone

*
  • *
  •  5,626 5,626
  • Precision Chaos
    • View Profile
Re: mcAxisGetInfoStruct
« Reply #8 on: June 19, 2018, 12:26:46 AM »
Works fine here (enabled or disabled). I do not get the -16 in either case.

I think another issue is the AxisInfoStruct.Pos does not return the value you think. I spoke to Steve today and he is going to change it so Pos returns work coords. That is not what it does right now. As it is should be override axis + Mpos. If you don't have an override axis with some value assigned, it will return the same as Mpos. In the next release Pos should return work coords.
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!
Re: mcAxisGetInfoStruct
« Reply #9 on: June 19, 2018, 09:14:55 AM »
that would have been an issue for sure. I was going by the .chm helpfile. This looks definitely like it should have returned what i needed. but I have what I need now, so I'm good on this issue. Now I just need to find out why I never get a MSG_HOME_AXIS or a MSG_DREF_AXIS

   double Pos;             // Position in user units.
   double Mpos;            // Machine position in user units.