Update:
I now have my CNC working (well... except for waiting for a few parts to finish the spindle motor driver).
With that done I turned my attention to figuring out the best tool to surface the fretboard, which got me thinking about how big a ball end mill I should have. That got me to realize that, regardless of the size of the ball end mill, the generator would always end up carving too deep since it puts the tip of the tool as the cut path. Grrr... not sure why I hadn't thought of that earlier. Here is a diagram to explain what I mean:
The two grey hemispheres show the position of the ball end of the mill for two adjacent passes. Everywhere they overlap the stock is a place where a cut is too deep. The larger the tool, and the smaller the fretboard radius the larger the error.
To be clear, the error isn't a huge amount. With a 9" radius board, 1/4" mill and 1 mm passes the error is about 0.15 mm (0.006"). The effect isn't catastrophic either, just that the effective radius of the board is a bit smaller than requested, but that is still too much of a problem for me to be happy.
Next I had to think about how to add tool path compensation. My brain is hurting again, but I believe I have it figured out:
Code:
tan_angle = asin(y / board_radius)
y-comp = cos((pi / 2) - ((pi - tan_angle) / 2)) * (((end_mill_diameter / 2) * sin(tan_angle)) / sin((pi - tan_angle) / 2))
z-comp = -sin((pi / 2) - ((pi - tan_angle) / 2)) * (((end_mill_diameter / 2) * sin(tan_angle)) / sin((pi - tan_angle) / 2))
Anyone care to check my math?
The new algorithm calculates the point where the end of the tool is tangential to the desired fretboard surface and moves the tool so that is where it cuts. Here is another diagram to explain the new behavior:
I will update the script and then check that it seems to be doing the right thing. Assuming it does then I will post it here for anyone interested.