Autoleveling and CNC journey

I decided to add autoleveling to snapmaker for cnc, I don’t have a problem milling pcbs but I would like to make the process easier. Right now I can mill a board in 1 shot correctly, but it’s slow and loud due to having to move at 6% speed, I’ve attached a picture of the results below:


This is a good result but it could be better, namely if there was autoleveling, I could move faster and also use isolation routing.

Based off Lubans source code I’m trying to figure out what CNC controller is used

3 Likes

Day 2

Reading the code more the controller for CNC is still marlin, this means that there are two ways forward with autoleveling, the first is to modify luban, and use an external circuit to hook onto the pcb and the v bit, and use that make luban capable of modifying the gcode to handle autoleveling, because I’m unfamiliar with CAN bus tech, this is probably the route I’m going to take.

The second route is by modifying Marlin firmware to use autoleveling, and adding a connector via CAN bus, this is probably the *right way to do it, but I’m not familiar enough with CAN to do this, nor can I find enough resources, Marlin I’ve been looking at and can understand but there’s some custom code in the firmware to handle the toolhead switch between cnc & 3d printer that I’m not quite sure how works yet

4 Likes

What’s your approach to do the auto leveling? Looks like the second route you need to modify the firmware of SM 2.0.

Hi Mika,

Below are some links which might help

  1. https://www.instructables.com/id/Make-your-own-PCBs-on-an-inexpensive-desktop-CNC-m/
  2. https://hackaday.com/2014/12/12/mill-warped-pcb-blanks-on-an-uneven-bed/
  3. http://www.autoleveller.co.uk/

We are currently working on enhancing PCB carving leveling, too. And you are right, the more elegant solution is have a build-in solution like 3D Printing bed leveling. We plan to add a new module which use the electric connectivity to trigger a signal, then sent it to the motherboard.

Having an external DIY module, for example, a RasperryPi / Ardunio collect the the probe data, then sent those data to Autoleveller / Luban(Need to implement a plugin) would be a great idea, too. Let us know your progress.

3 Likes

Thanks for the links, I’ve seen all of these and was planning on using autoleveler software to do the final output once the probing is done since that will save me a bunch of time :smile:

I’m thinking I will use an external probe because while it would be possible to modify the firmware (I’ve gotten the latest source from support) I don’t think it has much long term use since once SM releases firmware I’m stuck trying to compatibility patch my firmware constantly.

Doing it externally would also allow a larger amount of people to access autoleveling since I haven’t found software that uses an external probe yet, though seemingly that’s probably the easiest way to guarantee universal support and ease of access

1 Like

Day 3:

I’ve decided to go the external route, just getting the Arduino side of things setup, I will of course open source everything once I’m finished. This is probably going to be the easiest part :joy:

2 Likes

Day 4:

I’ve started on the route to building out an app for this, I was originally going to extend Luban but I think by stealing some of the OSS code for controlling the machine I can make it more adaptable by building my own GUI and allow people to implement their own controllers for further integrations with more machines.

The goal will be to accept a G-Code file and generate autoleveled G-Code after probing using an external probe. I’m trying to make this as open ended as possible and allow whatever type of input you want from a probe, the only mandatory part will be some sort of message over serial. I will release a schematic for how to do this in arduino but honestly it’s probably one of the most basic circuits since it’s just a push button but with aligator clamps, the only necessary code is for when the probe connection is trigged.

I’ve started on the electron app here https://github.com/MikaAK/cnc-autoleveler although what’s done is mostly just basic setup of the app and ensuring a frictionless and reactive communication method between main & renderer. I was trying to decide if I would use angular, react or svelte but really just landed on vanilla with rxjs since there’s not really pages or much rendering to do.
I was also able to setup Serial Port connections to read from the ardunio

2 Likes

Day 5:
Serial code has been wrapped up and I’m able to get the state of the probes connection instantly from the arduino and it’s live updating. I’ve also set up some code to allow uploading and viewing gcode files, I know the app looks beautiful right now. I’m still trying to think of a theme, if anyone has ideas let me know!

I’ve started working on the GCode generation for the probe gcode commands, the strategy I’m going to use is to figure out the boundaries of the gcode and setup the gcode commands for each step (eg move to probe point 1), that way I can run the step and then use gcode commands to fine tune the actual level.

The hardest part will be using the probe results and the original gcode file and combining them to produced leveled gcode, originally I was going to use autoleveler but this may be more of a challenge than just doing the leveling myself (I was looking at https://github.com/chilipeppr/widget-autolevel/blob/master/widget.js for ideas of how to do it)

4 Likes

Maybe this helps integrating:

1 Like

@Mika, @parachvte
Thanks for starting this thread. Chen (@parachvte), it is not about the leveling as for the 3D module, because the problem can be on the material as well. If the material is flat (I’m carving on 16mm MDF), the leveling is not about removing hills and valleys out of the material. For me, it is about getting the bed/base level (spirit level) over the X as well as Y-axes.

I’ve noticed that due to the single mounting on the Y modules, my bed is lower on the back as on the front. With the downward force of the CNC, the bed is pushed downwards. The linear modules might be strong with the downward force on the connection point of the platform onto the Y axes. However, when the downforce is at the end of the bed, there is a rotational linear moment on the connection points.

In order to prevent these moments on the Y-axes, I’m planning to add additional support for the bed. I know there is someone that used an extension to the Y-axes to allow for 2 connection points per module but I’m looking into merely putting a rail below the platform with support vertically below the module (directly below the X-axes). Thus, the rail attached to the platform and the rail block (or linear bearing mounting) fixed to the base plate. I see there are holes in my A350 base plate at the correct positions. This will support the bed when the Y-axes are at the minimum and maximum points. Thus, the supports will counter the linear moment. The only problem with this will be that the bed can be pinched between the support rail and the CNC module (cutting bit). The second issue comes into the exact height for the support rail. Making small changes will need to be a manual change, similar to a manual bed leveling of other printers with a skrew setting.

I will copy both @Mika and @parachvte on my progress on this. Chen, I know you are on the software development side, I will copy @Edwin on this.

Regards
Waldo

2 Likes

@parachvte, @Mika
I think the words “Auto Leveling” is where part of the problems comes in. For Auto Leveling, there needs to be a sensor or external feedback.
What would be great for a start is to have normal or manual leveling? The same Manual Leveling as with the 3D Printing module.
From what I’ve seen is that my board is 0.5mm lower at the back compared to the front. If I want to etch something, it etches at the front but doesn’t touch the surface at the back.
If I can manually level the bed/surface with my drill bit, a 3x3 or a 5x5 matrix, and the results are stored in the M503. The manual levelling will be the paper touch test… Then this can be used with the GCode to calculate the correct Z and effectively level the surface.
Regards
Waldo

2 Likes

Are there commands for marlin, that would mirror the functionalities of a probe on a cnc machine?
(of course if there is some kind of probe attached)

@Melanchrom I believe the standard Bed Leveling G29, M420 should work. Last time I was playing with the CNC, I noticed that there were no values when I called the M503 values. I’m planning to test and see if I can manually generate M420 values and save these when the CNC module is connected. Thus, effectively doing Manual Levelling procedure and storing the values in M420. If this works for my CNC, I will let you know. The next question will be if these can be stored with a M500 command.
It might be that the firmware will erase the M420 values when the module is changed.

That would be an interesting first step. Although you would probably need to etch below 0. That might raise problems. What I would really like is a possibility to probe the edges of a workpiece. This way you could find the corner and the orientation of your material on your bed.

Hi Waldo, your feedback has been forwarded to our team. Thank you :+1:

Thank you @JKC20 . I’ve tested my suggestion and am happy to tell you that it works. Following is my process explained;

1 Like

Sad to hear that you stopped developing the auto-leveler app. I am considering to starting giving it a shot of my own. I already did something similar with a prusa-like 3d printer where I had easier access to the controller, and it was surprisingly devoted of any major setbacks.

Could you explain a little bit how did you set up the Arduino probe? Does it reads or sends any information from/to the snapmaker controller?

Thanks for your work so far and for sharing it with the community :slight_smile:

1 Like