Question on using FP numbers in python 2

Gene Heskett gheskett at wdtv.com
Sat Feb 15 12:27:38 EST 2014


On Saturday 15 February 2014 12:13:42 Steven D'Aprano did opine:

> On Sat, 15 Feb 2014 00:07:49 -0500, Gene Heskett wrote:
> >> Can you extract the float calculations and show us, together with
> >> some sample data, expected result, and actual result?
> > 
> > Not extract, but let you get & look at the code, its the top entry on
> > this page:
> > 
> > <http://wiki.linuxcnc.org/cgi-bin/wiki.pl?Simple_LinuxCNC_G-
> > Code_Generators#Counterbore_Software>
> 
> Here is the direct link to the Python code:
> 
> http://wiki.linuxcnc.org/uploads/counterbore.py
> 
> > Assume no bolt size is clicked on, but a wanted diameter is entered in
> > the lower left pair of boxes, and its to carve .700" deep in the other
> > box. The cutting tool is .250 in diameter, its to do a stepover of 25%
> > of the tool diameter, while carving an additional .015" out of the
> > .850" hole with the tool bit turning 2000 rpm as it spirals down.
> 
> If I've understood the purpose of this program correctly, it generates
> code in some language called "G-code", presumably to control some sort
> of actual physical cutting machine.

More or less standard cNC machine control language.

> So the first thing you ought to do
> is have a G-code expert look at the generated code and tell you it does
> what it is supposed to do.
I think I might qualify for that expert label.  Looking at the output code, 
take the maximum X values it outputs plus and minus, add, then add the tool 
diameter to get the size of the pocket it will cut.  I don't need a 
graphical backplot to check that.

> Or perhaps your cutting machine is buggy.

Not impossible, but that part of the scaling code is 20+ years mature.  It 
knows exactly how many times to step the motor to move the tables 20 feet 
with micron accuracy if there is no mechanical backlash between the motor 
and the table.  Unfortunately there is in my toy mill, which is whats 
driving me to install ball screws in the table drives, which can have 
backlashes well under .0001" if properly made.

> > But the hole it will cut will only be .650" in diameter,  And the
> > backplot, shown in the axis interface, shows no spiral, its doing what
> > it thinks is full diameter in one circular plunge cut.
> 
> Scroll to the GeneratePath method, and read the comments at the top of
> the method. They tell you that the *intention* is:
> 
> * If the tool diameter equals the hole diameter, then just Plunge
>   down to the hole depth.
> 
> * If the tool diameter is less than 80% of the hole diameter,
>   then Plunge to each Level and Spiral out.
> 
> * If the tool diameter is greater than 80% of the hole diameter,
>   then Spiral to each Level and Spiral out.
> 
> But a little later, we see this code:
> 
>     # Figure out what kind of entry into the hole
>     if (self.ToolDiameter * 1.25 <= self.HoleDiameter):
>         self.CutType = 'Spiral Down to Depth of each Pass and Spiral
> Out' else:
>         if (self.ToolDiameter < self.HoleDiameter):
>             self.CutType = 'Plunge Down to Depth of each Pass and Spiral
> Out'
>         else:
>             self.CutType = 'Plunge Down to Hole Depth'
> 
> 
> Assuming that the comments are correct, the CutType is wrong. It looks
> like a simple logic error, and should be something like this:
> 
>     # Figure out what kind of entry into the hole
>     if (self.ToolDiameter * 1.25 <= self.HoleDiameter):
>         self.CutType = 'Plunge down and spiral out'
>     elif (self.ToolDiameter * 1.25 > self.HoleDiameter):
>         self.CutType = 'Spiral down and spiral out'
>     else:
>         self.CutType = 'Plunge down'
> 
> CutType is, I believe, merely a comment, but it leads me to believe that
> there are probably similar logic errors in the rest of the GeneratePath
> method. In fact, the description states:
> 
> "At this time there is a bug if you have a path that does not require a
> spiral... working on it"

And I just heard back, he is looking at it again.

Thanks Steven.

Cheers, Gene
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page <http://geneslinuxbox.net:6309/gene>

NOTICE: Will pay 100 USD for an HP-4815A defective but
complete probe assembly.




More information about the Python-list mailing list