Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: gorf23 on August 17, 2017, 04:23:33 PM

Title: mc code to read and wirte to chance motor steps.
Post by: gorf23 on August 17, 2017, 04:23:33 PM
anyone know the mc code to read and wirte to chance motor steps with a script.

Thanks
Title: Re: mc code to read and wirte to chance motor steps.
Post by: gorf23 on August 18, 2017, 11:08:31 AM
in mach4 its called counts per unit looking for a way to read and write to make changes to the counts per unit
Title: Re: mc code to read and wirte to chance motor steps.
Post by: DazTheGas on August 18, 2017, 12:20:53 PM
To set the counts per unit you would need to use mcMotorSetInfoStruct, there is no mcLua bindings for this and can only be used from a plugin. Although I did do this a long while ago and I will see if I can find it, by writting to the profile then reloading the profile.

DazTheGas
Title: Re: mc code to read and wirte to chance motor steps.
Post by: gorf23 on August 18, 2017, 08:44:19 PM
Thanks DAZ

I figured it out

would be nice if they made the mcMotorSetInfoStruct call available in scripts...

gary
Title: Re: mc code to read and wirte to chance motor steps.
Post by: joeaverage on August 19, 2017, 02:45:09 AM
Hi Gary,
it might be nice to be able to use the InfoStruct in a script but how realistic is that?

If I understand correctly the only data structure that LUA has is  a table. While a table can and is used in some ingenious ways its not
like the MotorInfoStruct with Booleans, integers, longs and doubles all thru it.

There are a few data structures in Mach, AxisInfoStruct for instance. For the same reason you can't access that structure complete with LUA API
but quite a few of the individual variables in the structure can be accessed with the LUA API.

I'm wondering if you might be able to achieve what you want by having two motors assigned to the same axis but only one enabled at a time
each with different 'step per' values?

Craig
Title: Re: mc code to read and wirte to chance motor steps.
Post by: Steve Stallings on August 19, 2017, 09:46:42 AM
Curiosity, what are you doing that needs to edit the motor setup from Lua?

Could the same result be achieved using G code scaling by having Lua
execute a G51?