KMCNC units

Moderators: TomKerekes, dynomotion

Post Reply
Moray
Posts: 113
Joined: Thu Apr 26, 2018 10:16 pm

KMCNC units

Post by Moray » Thu Jul 25, 2019 8:22 pm

When getting the position values from KMCNC in my probing program (which uses the key parts of MeasureFiducials), what units are the DROs in?
Are they always in inch?

I'm just looking at tidying up my Probing program (I finally got enough tool holders to get my mill set up for probing, hence the fresh enthusiasm to get my probing program useable!), and one of the things I've kludged is handling units. Everything I've done so far has just relied on using inches, with various hardcoded conversions from mm (i.e. I have a 2mm probe tip, and a 20mm ID bearing for calibration) where needed for testing, but now I'm trying to get probing to be more unit-less, I've realised that switching KMCNC to mm still results in my probing DROs showing inches..

I'm guessing I need to code things to convert the DROs when in mm (or at least use the functionality from MeasureFiducials that I've been ignoring!)

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

Re: KMCNC units

Post by TomKerekes » Sun Jul 28, 2019 4:38 pm

Hi Moray,

Yes I believe MeasureFiducials allows the Units to be used to be selected within the App by the user. See MainForm.cs variable Unitsmm.

We should probably add a mechanism to allow an App to read the Units in use from KMotionCNC.
Regards,

Tom Kerekes
Dynomotion, Inc.

Moray
Posts: 113
Joined: Thu Apr 26, 2018 10:16 pm

Re: KMCNC units

Post by Moray » Sun Jul 28, 2019 5:15 pm

My current issue is, although I've still got the Unitsmm variable and associated functions still in my program, I mostly ignored it while getting the barebones of probing to work.

It's only now I've tried using KMCNC in mm, I've realised KMCNC always outputs inches to my program. It's not a major issue as such, but it requires me to change code in a few places, as things like requests for offsets via the KFlop always return in the selected units, so I need to work through the various parts and check for what conversions are needed.

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

Re: KMCNC units

Post by TomKerekes » Sun Jul 28, 2019 5:31 pm

Hi Moray,

The approach I find simplest is to do calculations always in some standard Units (inches). Then just change what is received or displayed to the User to be in his selected Units.

I don't see GCode Offsets are necessarily in the selected Units. Rather they are just numbers (unitless) and should be considered in the selected Units.
Regards,

Tom Kerekes
Dynomotion, Inc.

Moray
Posts: 113
Joined: Thu Apr 26, 2018 10:16 pm

Re: KMCNC units

Post by Moray » Sun Jul 28, 2019 5:58 pm

Now that I've just had a quick look at the relevant code, I've just realised it's my code that's doing the conversion for offsets.
After reading the offsets via the KFlop, I'm running them through the ConvertToUser function before displaying them, which given they're always unitless, is not a good idea.

It's only the DRO values from KMCNC that I need to convert when needed.

Moray
Posts: 113
Joined: Thu Apr 26, 2018 10:16 pm

Re: KMCNC units

Post by Moray » Sun Jul 28, 2019 11:44 pm

I think I've now got a grip on this.

I don't really need the ability to switch easily between mm/inch, as I'm sure most people never switch between units during normal running of KMCNC, so I just need to redo my offset calculations to convert to mm if needed.
However I've just discovered a flaw in how I'm internally handling probing moves, which is going to need a bit rework. On the plus side, I can now find the centre of a hole :D

Post Reply