Unit position equivalence with GCode programas

Moderators: TomKerekes, dynomotion

Post Reply
Juanjo-Lasing
Posts: 25
Joined: Wed Sep 04, 2019 11:56 am

Unit position equivalence with GCode programas

Post by Juanjo-Lasing » Mon Sep 30, 2019 10:35 am

Hello again,

I am trying to run simple GCodes in my aplication using the metod KM.CoordMotion.Interpreter.Interpret("...")
This is the code I am trying to run, a simple square:
G0 X0 Y0 Z0
F50
G90
G21
G40
G1 X5 Y0
G1 X5 Y5
G1 X0 Y5
G1 X0 Y0
M2
In my aplication I put 3 position indicators with a timer to see the axies positions, like is done in SimpleFormsCS example.
The problem is that when I run that GCode, the feedback positions are multiplied by 0.03937 (equivalence between cm and inch is 0.3937, I don't know why is divided by 10), I discovered this using the metod KM.CoordMotion.Interpreter.UserUnitsToInches(1).
I tried add some changes to my program to solve this, just after Initialize the interpreter:
KM.CoordMotion.Interpreter.SetupFile = "...DefaultKeepOffsetsMM.set";
KM.CoordMotion.Interpreter.SetupParams.LengthUnits = CANON_UNITS.CANON_UNITS_MM;
but does not work.

When I run this program in KMCNC the feedback positions are correct (I select mm instead of inches). It seems that the movement is correct, but the positions units are wrong.

Any idea how can I solve this?

User avatar
TomKerekes
Posts: 2676
Joined: Mon Dec 04, 2017 1:49 am

Re: Unit position equivalence with GCode programas

Post by TomKerekes » Mon Sep 30, 2019 1:06 pm

Hi Juanjo-Lasing,

Have you configured all the Trajectory Planner Motion Parameters such as Counts/inch?

https://dynomotion.com/KMotion_dotNet/D ... rInchX.htm

You might look at how the .NET Console example uses the GCode Interpreter.

I’m not sure what “feedback positions” are?
Regards,

Tom Kerekes
Dynomotion, Inc.

Juanjo-Lasing
Posts: 25
Joined: Wed Sep 04, 2019 11:56 am

Re: Unit position equivalence with GCode programas

Post by Juanjo-Lasing » Tue Oct 01, 2019 7:55 am

Hi Tom,

The "feedback positions" are the destinations of the axies, I get them using Destination array from the status controller. I am not sure why I called them that, sorry.

Using CountsPerInchX with 2.54 (1 inch = 2.54 cm) the positions I get are an order of magnitude smaller than expected, so I have to indicate 25.4 instead of 2.54 to get a correct value in the readings.
I'm not testing this with real motors yet, so I'm not sure that the movement generated is the right one, but at least with this I get correct values.

Juanjo-Lasing
Posts: 25
Joined: Wed Sep 04, 2019 11:56 am

Re: Unit position equivalence with GCode programas

Post by Juanjo-Lasing » Tue Oct 01, 2019 8:13 am

Sorry I forgot,

Thank you Tom.

User avatar
TomKerekes
Posts: 2676
Joined: Mon Dec 04, 2017 1:49 am

Re: Unit position equivalence with GCode programas

Post by TomKerekes » Tue Oct 01, 2019 6:11 pm

Hi Juanjo-Lasing,

Sorry it still isn't clear what your parameters are, what you are expecting, or what is happening.
Using CountsPerInchX with 2.54 (1 inch = 2.54 cm)
Normally CountsPerInchX would be set to a big number (ie 10000) as the number of steps or counts to move your system 1 inch.

Also GCode G21 causes the interpreter to work in mm not cm. Could that be the issue?
Regards,

Tom Kerekes
Dynomotion, Inc.

Post Reply