Built-in flattening feature idea

Note that since we are using a round tool, cosine error works to our favour and the tool should be pretty comfortably off the stock.

An undocumented feature is that the plunge rate is set to 1/4th the feed rate.

There is a loop which checks for if the last pass is beyond the Y-extent — if it is, the loop ends.

Yeah, abbreviating the number of decimal places is probably a good idea — that was actually a serious issue and caused a bunch of problems back in the Grbl 0.8? 0.7? days, but 0.9 allows for fairly long lines so I don’t think it’ll be an issue — if someone encounters a set of parameters which actually result in a problem on the machine let me know and I’ll work out how to truncate.

Any further adjustment is left as an exercise for the reader (Use the source Luke) and hopefully we can continue the discussion over at:

I just use top of stock and roughly the bottom left as reference points. On the computer that runs CM, I just have several leveling (flatting) programs saved in a folder with some rough sizes. Like a 12" x 12" and 0.010", 0.020", and 0.30" depths for example. That way I have some, that even if oversized, I just run. The various depths are to re-run deeper to quickly change the depth without having to change the Z.

That’s my easy work-around to quickly flatten. :slight_smile:

5 Likes

@WillAdams @Tod1d You brainiacs have waaayyyyy too much time on your hands :rofl: :rofl: :rofl:

1 Like

However, if one automates the right things in the right way, one can come out quite a bit ahead:

3 Likes

Tweaked it a bit

https://studio.flet.dev/apps/meGQ5oWzLm

3 dec pl
overtravel = diameter
Added tool dia
stepover defaults to 1/2 dia, but can be changed.
removed downward motion at end. (Z6.35, then Z3.175) and replaced with G53 Z-5
Added cut feedrate to cut motions
(taught myself enough python to modify code :laughing: )

3 Likes

Another option for surface finish, which would give a very smooth finish is a trochoidal / spiral path.

1 Like

Whoa! I’d like to see the gcode for that. I haven’t dived that deeply.

Hey folks, I watched Corbin Dunn’s video on chipout and he talks about surfacing in there.

I think it’s worth a watch for more than the surfacing part. But anyway, I put an option to choose the axis for the cutting pass, so that one can make a final pass with the grain and have tool marks that are more easily sanded out.

Here’s my gist again if you are interested. This is not meant as a contender in the “who’s code is the best” competition. :slight_smile: I just want to throw in my two cents.

@Tod1d That’s really cool that you can fill out the fields that way. I never thought of putting this into a web format. My command line is seriously long but I just scroll back in my history, change a variable or two, and hit enter.

EDIT: Whoops, here’s that gist:

3 Likes

It was generated using Cambam, not Carbide Create.
waste board.pocket.nc (15.2 KB)

A simple routine i do. I set zero to the top of my material when flattening, after my first pass, if not cleaned up I jog to a safe position, for me is usually the “S” rapid jog position. Rapid to z zero, change to the set zero screen use the -Z button jog the Z to my desired next depth of cut. Set Z 0, then run my program again and repeat this till my material cleans up. The downside is after every pass the machine goes to the home position and adds a lot of time to the flattening of material. I would rather have an optional stop that can be added to the program by a check box and a second check box to end the program. This would allow me to determine if I needed another pass by clicking ok. This way you can use the max depth to control the maximum amount of material to be removed and also allow you to set zero to the bottom of the part.

Ok, after I started working on this in Rust to help learn for work, I told my wife that I could probably get this done in 1 day if I was doing in Javascript and have a nice interface as well. So last night I decided to just do that so that it’s something shareable.

It’s not perfect but here are the basics:

  • Allows you to enter settings and bits that are saved into your browsers storage so they persist when you refresh the page and reopen the page
  • You can input as many bits as you want with all the normal settings
  • Set the zero point for the z axis to top or bottom
  • Set the xy zero point to bottom left, center left, top left, and center
  • Set the angle to either 0 or 90 degrees
  • Can work in inches or milimeters
  • Toggling between the two converts the bit values so you can enter your bits once and if you change between units you can still use them
  • Set your depth of cut, retract height, material thickness, material height, material width
  • Gcode output on the page so you can see what’s being generated
  • Button to download the Gcode as a file called flatten.nc

Still needs:

  • The interface needs to be more responsive to different viewport sizes
  • I don’t know what some of the top matter in the files generated by CC mean so I need to get better clarification. Specifically the stockMin, stockMax, and STOCK/BLOCK entries
  • Some of the styling should be tweaked for more clarity
  • I’d like to find a way to make this more touch-friendly because I plan on using it on my machine that I only interact with through a touchscreen. I need to test it first and see what does and doesn’t work, but I want it to be easy to use in that way otherwise I won’t bother using it myself

I have not yet tried the output with a real machine so if you try it, keep your hand next to the kill switch but also tell me if it does or doesn’t work. I’m hoping to give it a try tomorrow evening but we’ll see if my schedule permits.

Any feedback would be great. It’s written entirely in Javascript, CSS, and HTML.

@WillAdams @woodchip_breath

5 Likes

This looks great! I have only taken a cursory look so far and have not run your gcode.

I think you should set an option for how much overlap you want on each pass. It’s pretty simple to throw that in to what you already have.

You might consider going to the end of your pass / far edge of your material and then reversing direction instead of returning to X0Y0 but that’s not necessary; it would only save a little time. I throw all my X or Y coordinates into a list and reverse it – I’m pretty sure that’s easily done in JavaScript.

I can’t answer the questions about stockMin and stockMax. I have only used Carbide Create and my GRBL update has broken my ability to use Carbide Motion as my machine isn’t recognized (for now). I’ve been using CNCjs since the beginning.

If Carbide Motion accepts an outside GRBL file, then I think you have what you need already.

1 Like

Also, check out https://ncviewer.com/ for a browser rendering of gcode. It is a little clunky. There is a simulation, too.

1 Like

When you say “overlap…on each pass”, do you mean like stepover? or a different parameter? The way i have stepover implemented would seem to meet your description, but i’m curious if you know of something that would be more helpful. I have stepover set up as the only thing that determines how far in whichever direction it goes between passes and it might be nice to have a more job-specific way as well since one time I might want to use my 1" bit to do a 75% stepover and another time i might want to do a 25% stepover, but that wasn’t something I had thought about when i was working on this initially.

The idea to have it reverse course is a good one but would require a bunch of extra calculations for each pass so I don’t know if I would want to do that. It’s something I could add as an option so if you check that selection it does the extra work, but we’ll see.

I definitely want to test it some for real before I add any more features!

Thanks for the link! I’ve been looking at it a bit and found a couple bugs in my generated code that i’m fixing and pushing up

Yes, stepover is the word I was looking for.

What I did was to figure out an array of Y steps (or X steps) beforehand and then just step through that array on each pass. Then you could either flip the array or just read it backwards from the last value to the first. But there are many ways to skin a cat.

You could test it by running your code like 15mm over the height of your stock and setting a slow feed rate.

1 Like

My approach was to set a start value for the Y axis and an end value for the Y and every time through the loop the stepover was added to the start value until it would reach the end value.

I also set it up so that the gcode text was being generated as a string along the way so it’s a bit harder to manipulate it for doing something like reading it backwards or something. This was definitely more of an on-the-fly setup than really trying to think about every possibility so there is definitely a lot of room for my code to be optimized and slimmed down i’m sure.

I’ve made a few updates to the code and pushed them up thanks to checking on that visualizer. i think it’s at the point now where i’m good to try it for real.

if anyone tried it already, be sure to do a “hard” refresh (ctrl + shift + r or cmd + shift + r on a mac) and also click the “Clear saved data” button at the top. I noticed there was an issue with something calculating weird and even after the update was deployed and I tried refreshing the page, it didn’t seem to change until i cleared the locally saved data.

1 Like

I think it’s great that you crammed all of it into a web form that can crank the code out. With my code, I have to open a shell and spit out the code and transfer it to my working machine, and your method saves all those steps, as well as having to look at a very long command line to change one or two options.

1 Like

I’ve finally had a chance to try out my web app and except for a few things, it works great!

Disclaimer: I only tried it in inches, i’ll probably try it in mm but that’s not what i normally use so I don’t know for sure it will work but based on what i know, it should.

The tldr is that if your xy zero is bottom-left, center-left, or center and you only do the 0 degree direction, you’re good-to-go!

The issues I ran into:

  • When saving the gcode file out it would sometime generate multiple files. One time it made 10! Opening the files I can see values changing to reflect some of the changes i’d made, but it didn’t seem time-based necessarily because even when I’d only changed 1 thing, it generated 10 files
  • When I tried running it at a 90deg angle, so it would go up and down the Y axis primarily and step sequentially along the X, it acted like the material had been rotated 90deg. So I think an axis value isn’t being set correctly somewhere.
  • When i ran the xy zero at top-left, it started correctly from the bottom left corner, but it thought the material was twice as tall on the Y axis as it actually was. So it was acting like I’d centered it in the left-center and doubling the size of the board.

Otherwise, everything worked great! The only other issue(s) I had were user error, which was amusing since it meant that I’d used my own app incorrectly. But yeah, it worked great and I’m going to work on fixing those issues so I can get this fully functional.

If anyone has suggestions for tweaks or features, let me know. This was designed with my own needs in mind so if there are things I can do that would make it a bit more universally useful, i’m up for that.

1 Like

After a bit more tweaking, I think I have the main bugs worked out.

Disclaimer: I haven’t tried anything in mm, just inches. So if you have a problem with that, let me know and i’ll look into it.

Thanks to @woodchip_breath suggesting I look at ncviewer, I added a button that copies the gcode into your clipboard and opens a new tab with ncviewer loaded so you can paste the code in to check.

I have it pulled up on the computer I use for CM and set my browser to always ask before downloading files so this way I can have it go to the folder I want and it’ll also ask if i want to overwrite the previous file so I don’t end up with a ton of mostly identical files.

Here’s the link again if anyone is interested:

4 Likes