• TalkBass has been independent since 1998. Add your voice.
    Create a free account to reply to discussions, view embedded media, and browse with fewer display ads.
    Join freeLog in
    Want zero display ads or expanded classifieds tools? Compare plans.

CNC fretboard G-code generator

so says the machinery "collector" with tons of space!:)

excellent points though actually.

:rolleyes: I have a big shop (about 3000 sf), but I don't have much space! I have it jammed full of machines, workbenches, machines, shelving, and a few extra machines. It's nearly solid with a few aisle ways.

I had a long career designing and building machines. I always encourage anyone building their own CNC machine to back off and think about the overall size and configuration. Optimize it for the job you are trying to do. Starting off with a good, carefully designed frame minimizes the problems later with feed, accuracy, chatter, etc. Choose an axis configuration that works best with the cutting tools and part shapes that you have.

One of my many ongoing machine projects is a neck shaping machine. Non-CNC, a precision pattern follower. I hand carve a master pattern, and the machine accurately copies the shape to the new neck. I've built a couple of pattern-follower machines in the past with mixed results. I think I've figured out a better configuration.
 
  • Like
Reactions: Jeff Siddall
One of my many ongoing machine projects is a neck shaping machine. Non-CNC, a precision pattern follower. I hand carve a master pattern, and the machine accurately copies the shape to the new neck. I've built a couple of pattern-follower machines in the past with mixed results. I think I've figured out a better configuration.

do you have experience with a Deckel pantograph?
 
do you have experience with a Deckel pantograph?

Not a Deckel, but I have a New Hermes VB. The VB is probably the best 2-D pantograph engraver made. It will reduce up to 100:1 (!), and engrave around rings and cylinders. It's from the 1950's. I use it to make all the engraved aluminum nameplates for my basses, plus some ingraved inlays for clients.

A Deckel 3-D pantograph mill is one of those machines that I'd love to have if one turns up for cheap or free. Pushing the limits of pre-computer technology. I see them for sale occasionally here in Los Angeles. Why do you ask? Do you have a lead on one?
 
Last edited:
Well... still no CNC parts so I decided to solve the next challenge: adding a G-code generator for multiscale curved bottom blind fretslots to go along with the compound radius fretboard. And I though my brain hurt after creating the fretboard part! :dead:

Anyway, after spending far too long on it, I am glad to finally be done and very happy I now have a way to carve all the fretboards for several upcoming builds :woot:

The script takes a few more parameters now:
  • Number of frets
  • Two scale lengths
  • Optional zero fret
  • Perpendicular fret
  • Fret slot depth
  • Fret slot feed rate
  • Fret end margin (for blind slots)
  • Amount of extra fretboard to carve on either end (ex: for building a zero fret string guide into the fretboard)
In the process of adding the fret slots I discovered a few new problems, including that the original generator wouldn't always cut both ends of the board wide enough while making a ruled surface. All fixed now!

Here's a couple of simulation shots for my multiscale 5 string build. Click to zoom:
fretboard.png

fretboard-toolpaths.png


For those geeky enough to care, the python script is 218 lines of code, and the G-code example above took 175 ms to create and, with max. 1 mm toolpasses, is 1955 lines long. Using moderate feed rates it should take about 1.3 hours to carve.
 
Nice work! I particularly like that you are cutting the fingerboard surface with angled passes, following the string paths. Hourglass shaping and offset hyperbolic parabaloids and all that good stuff. Most folks (and larger companies) that are using CNC to cut their necks are still cutting the fingerboard surfaces as simple cylinders. To me, this is the important part of what you've built. Locating the fret slots is a helpful add-on.

Have you factored in what shape router bit is being used to cut the surface? Most folks use a standard ball end or cove bit, which will leave the surface as tiny troughs. The ideal cutter bit would be a standard straight bit which has been reground to a shallow radius on the end, just a little smaller than the smallest radius of the fingerboard. For example, if the smallest radius you are cutting is 7 1/4" radius, a bit ground to 7" radius on the end would leave the smallest little troughs with the fewest number of passes.
 
Nice work! I particularly like that you are cutting the fingerboard surface with angled passes, following the string paths. Hourglass shaping and offset hyperbolic parabaloids and all that good stuff. Most folks (and larger companies) that are using CNC to cut their necks are still cutting the fingerboard surfaces as simple cylinders. To me, this is the important part of what you've built. Locating the fret slots is a helpful add-on.

Have you factored in what shape router bit is being used to cut the surface? Most folks use a standard ball end or cove bit, which will leave the surface as tiny troughs. The ideal cutter bit would be a standard straight bit which has been reground to a shallow radius on the end, just a little smaller than the smallest radius of the fingerboard. For example, if the smallest radius you are cutting is 7 1/4" radius, a bit ground to 7" radius on the end would leave the smallest little troughs with the fewest number of passes.

Thanks!

Yes, it is pretty easy to code straight cuts parallel to the centerline, and if I was happy with that I would have probably just bought a radius block and been done. But having a CNC means being able to do it right, so in the code I wrote, every tool path is a straight line on a [potential] string path. All a board should need out of the CNC is final finishing, and maybe a touch-up fret level at the very end.

Regarding router bits, my modest mill only has collets up to ~1/4" so I will likely use a 1/4" ball end. But you are right, a shallow dished end mill would be ideal. Kind of like a miniature bowl bit. Even better would be a 4-axis machine and a plain end mill. That way the board surface would always be tangential to the tool face. Gaaah, I've got to stop myself from even considering that or I will spend all my time building the coolest fretboard milling setup but never actually building a fretboard!

One thing I do have on my side is time. Getting an even smoother surface is as simple as reducing the tool path spacing, so a 0.5 mm spacing would be about 150 (!) passes, and would take a couple of hours to cut, but would result in a very fine surface with... hang on, gotta do some more math... less than 0.01 mm (about 0.5 mil) of surface roughness (assuming I did that calculation right). Anyway, I think I'll be able to sand it smooth!
 
  • Like
Reactions: ddtkills
Update: I now have my CNC working (well... except for waiting for a few parts to finish the spindle motor driver).

:hyper:

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:

before_ball_nose_compensation.png


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. :spit:

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? :laugh:

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:

after_ball_nose_compensation.png


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.
 
Last edited:
y and z comp look ok. tangency is the way to approach it. now all you have to do is settle on a stepover that will give you a tolerable scallop.

1/4" cutter diameter x .039" step over is a big bite. i would suggest a .75" dia cutter with a .025" stepover. finish sanding should level that out pretty good. or if your spindle can't handle that size try a .50" diameter cutter with a .0125" stepover. experiment of course to see what works best for you. not sure what your largest collet is for your machine?
 
Last edited:
  • Like
Reactions: Jeff Siddall
refining further, i created a typical fretboard surface with a 9.0" R into Mastercam 2020, using a .50" diameter ball endmill at a .050" stepover will leave a .0012" scallop height

a 1/4" diameter ball endmill with a .030" stepover will leave a scallop of .0009"

so initially you were pretty close with your toolpath. :)
 
Last edited:
My collet is an ER11 so 0.3125" is the biggest I can go. I could use a standard 1/4" router bit with a larger 0.5" or more diameter cutting head, but since I already have a ~1/4" ball end mill, and I have pretty much all the time in the world, I think I would just reduce the stepover if I really wanted a finer surface finish. Sanding off a mil or two doesn't seem like a big hardship!
 
My collet is an ER11 so 0.3125" is the biggest I can go. I could use a standard 1/4" router bit with a larger 0.5" or more diameter cutting head, but since I already have a ~1/4" ball end mill, and I have pretty much all the time in the world, I think I would just reduce the stepover if I really wanted a finer surface finish. Sanding off a mil or two doesn't seem like a big hardship!

collet size: got it

sanding: you'll be fine. i generally like to finish a finger board at 400 grit and that makes quick work of tiny scallops.

for extended cut times wood is real abrasive on cutters. i'd suggest a tool with a really good coating to help with the wear factor.
 
Last edited:
  • Like
Reactions: Jeff Siddall
Update: the script has been updated and generates G-code. Correction factors all seem sane so I will try to mill a board and take some measurements to confirm the radius is correct. Here's a render of a multiscale compound radius board generated with the updated code:
fiberd-fretboard.png


The actual milling won't happen right away as I need to finish building the motor driver (once the remaining parts arrive), but I will be sure to post an update once I have made some shavings!
 
This is fantastic work. I'm not a CNC guy, but I appreciate the work that goes into this, especially regarding the straight string paths along a more elaborate fretboard, say, fanned fret and compound radius. My recent adventures into twisted necks have led me to look further into string paths, string spacing and possible asymmetries, and it seems that you got it figured out, not just "close enough". Amazing!
 
One more update. On another thread @TFM94 gave me an idea to do a twisted board as well. A couple of hours later the script can now generate twisted, compound radius, multiscale, curved bottom blind fret slot boards:
twist-fretboard-png.png


And yes, all of the surfacing is done using linear interpolation (G01) moves that run the full length of the board, so it is a ruled surface:
twist-fretboard-toolpaths-png.png


Now that I have the G-code, and the CNC, I really don't have an excuse not to build another bass. Gaaah! :rollno:

Edit: build thread for that bass is over here:

Three piece maple/amboyna/ziricote twisted headless bass
 
Last edited:
Now that I have the G-code, and the CNC, I really don't have an excuse not to build another bass.
You could apply it to Ukuleles. Banjos. Mandolins. Mandolas. Guitars. ...aaaaand Basses.

If I ever get my Ur-ShopBot back in action (probably as a GRBL machine, since ShopBot is not very into support for the systems that started them off, other than if you dug deep to buy every upgrade along the way...) I can see this being highly useful.
 
  • Like
Reactions: dwizum
You could apply it to Ukuleles. Banjos. Mandolins. Mandolas. Guitars. ...aaaaand Basses.

If I ever get my Ur-ShopBot back in action (probably as a GRBL machine, since ShopBot is not very into support for the systems that started them off, other than if you dug deep to buy every upgrade along the way...) I can see this being highly useful.

Haha, yeah, I already have too many guitars planned but I could build myself a uke for sure!

What kind of steppers does the shopbot use? I gotta say, GRBL is shockingly good and controllers are cheap enough that I wouldn't expect there to be many good reasons not to replace your proprietary controller. GRBL won't win prizes for being the most full featured controller, but it seems be an everything you need, nothing you don't sort of thing that has worked great for me.
 
  • Like
Reactions: dwizum
State of 1997 or so. 6 lead motors, rewired at the connector as 5-lead due to 1997 driver electronics, will be back to 6 lead for modern drivers. I also have a whole other set of steppers and some Acme threaded rod in case I want something that's not cable-drive to work with, but the cable drive actually works, though it was abandoned early by ShopBot (first case of "spend 50% of the price of the machine you just bought for an upgrade" I said "nope" to.) So that will probably be another machine entirely if or when it happens. IIRC I have a GRBL board for each in the parts collection now, but they have been sitting a while.

stepper.jpg
 
  • Like
Reactions: Jeff Siddall
State of 1997 or so. 6 lead motors, rewired at the connector as 5-lead due to 1997 driver electronics, will be back to 6 lead for modern drivers. I also have a whole other set of steppers and some Acme threaded rod in case I want something that's not cable-drive to work with, but the cable drive actually works, though it was abandoned early by ShopBot (first case of "spend 50% of the price of the machine you just bought for an upgrade" I said "nope" to.) So that will probably be another machine entirely if or when it happens. IIRC I have a GRBL board for each in the parts collection now, but they have been sitting a while.

View attachment 4557886

Those steppers should be pretty straight forward to hook up to a GRBL controller. 6 wire is a common bipolar setup, and the integrated stepper drivers (ex: A4988) commonly used these days only need the outside wires of each pair of coils (i.e. only 4 of the 6 wires connected to the driver). Those integrated drivers also have 2 A drive capability with proper heatsinks so that should be fine also. Having said that, my experience with my Woodpecker board that has integrated driver chips has been that they have the current limits set pretty low to prevent heat problems. In any case, you can do a little soldering and hook up external drivers to the ATmega controller. The controller itself just provides logic level STEP and DIR outputs for each axis.

If you are interested in getting a GRBL controller setup and have any detailed questions about this just PM me.
 
Quick update: I did some testing this past weekend with a 0.023" fret slot mill, first with some shallow passes first, then a new 2 mm deep single pass through slot and finally a 2 mm deep blind slot in some hard maple:
20220127_220818.jpg


Unfortunately, in the process I discovered that even though plunging into the blind slot worked fine this time (it usually isn't a good thing with end mills) chip ejection was an issue because there was no empty space for the chips to go. I had to go back with a knife and clean out the surprisingly tightly packed slot. Rather than tempt fate again, I decided to implement a ramp into the slot generator portion of the script. This is less trivial than I initially expected because a normal linear ramp going from the top of one end of the slot to the bottom of the opposite end would result in overly-deep cuts in some parts of this curved-bottom application. That means my brain is hurting again while I figure out a better way to do it, but I think I have most of sorted now. Hopefully I can finish it and cut a real fretboard by this weekend.
 
  • Like
Reactions: Beej and TFM94