Mm to inch error

This may have been addressed before but I couldn’t find anything.

I’m using Ground Control 1.0, when I change the “Distance to Move” number in inches say to 20 and switch to mm it comes back with 500 instead of 508. Is there some floating point error some where?

1 Like

that sounds like there’s an int used when it should be a float (we’ve seen that
before)

I found the error in the frontPage.py. The newUnits divide and multiply by 25 instead of 25.4

def onUnitsSwitch(self, callback, newUnits):
self.units = newUnits
INCHESTOMM = 1/25.4
MMTOINCHES = 25.4

    if newUnits == "INCHES":
        self.data.gcode_queue.put('G20 ')
        self.moveDistInput.text = str(float(self.moveDistInput.text)/25)
        self.data.tolerance = 0.020
    else:
        self.data.gcode_queue.put('G21 ')
        self.moveDistInput.text = str(float(self.moveDistInput.text)*25)
        self.data.tolerance = 0.5
2 Likes

good catch

do you want to make a pull request for this fix or just have one of the regulars
submit it?

1 Like

I had to add the ‘%.2f’ to format the string or else you get overrun of numbers. I’m not real confident in my programming abilities so I would feel better having on of the regulars fix it.

This is what I did.

def onUnitsSwitch(self, callback, newUnits):
self.units = newUnits
INCHESTOMM = 1/25.4
MMTOINCHES = 25.4

    if newUnits == "INCHES":
        self.data.gcode_queue.put('G20 ')
        self.moveDistInput.text = str('%.2f'%(float(self.moveDistInput.text)/25.4))
        self.data.tolerance = 0.0
    else:
        self.data.gcode_queue.put('G21 ')
        self.moveDistInput.text = str('%.2f'%(float(self.moveDistInput.text)*25.4))
        self.data.tolerance = 0.0
4 Likes

That looks like the right fix to me.

1 Like

This is my fault. I set it to 25 instead of 25.4 there because I figured when switching from inches to mm mode for moving the machine around we would probably rather have nice round numbers. I liked that the defaults were 4 inches and 100mm. I’m more than happy to have it by 25.4 if we decide the other way is confusing

2 Likes

I liked that too. I just use this dialog is just for moving around, usually want a nice round number. If I want precision, I can get it after changing the units.

2 Likes

To me it makes more sense to have accurate conversions. I don’t fully understand what @bar and @blurfl like about not having accurate conversions though it also makes good sense when round numbers improve ease of use.

It’s a feature, not a bug issue? :slight_smile:
Or a bug with a nice feature?

I agree that the conversion should be accurate, Having the default be 4 in or
100mm is reasonable, but having it be off if you type one and convert it is not.

1 Like