A big thanks to Ron Gerrits who has taken my original bed-leveling application and expanded on it. He's modified the Marlin Gen6 firmware to respond to the M117 code used during the bed leveling process. He's also made the process faster and automatically scaled the resulting plot.
The whole Marlin pack can be downloaded from here and selecting the Marlin.rar download.
Showing posts with label Bed. Show all posts
Showing posts with label Bed. Show all posts
Saturday, October 29, 2011
Wednesday, June 8, 2011
Bed Mapper Application and STL Files
I've finally got round to publishing the Bed Calibration Application that I discussed in this post.
The calibration application is now available, along with the STL for the bracket here.
This series of scripts requires the Python libraries: PySerial, Matplotlib and NumPy
Note: This script banks on the Mendel firmware supporting the M117 GCode. Without it, it won't work!
RepRapComms.py: Comms library for communicating with a Mendel.
ZCal.py: Main calibration routines.
PlotBed.py: Bed plotting routines.
gui.py: A GUI to make calibration easier.
To use the GUI:
The calibration application is now available, along with the STL for the bracket here.
This series of scripts requires the Python libraries: PySerial, Matplotlib and NumPy
Note: This script banks on the Mendel firmware supporting the M117 GCode. Without it, it won't work!
RepRapComms.py: Comms library for communicating with a Mendel.
ZCal.py: Main calibration routines.
PlotBed.py: Bed plotting routines.
gui.py: A GUI to make calibration easier.
To use the GUI:
- Use the Printer Menu tab to configure the various settings to match your printer.
- Calibrate Button, will perform a series of measurements across the whole bed at the specified X & Y step size.
- Quick Cal Button, will perform a quick test at four specified points across the bed.
- Variance Button, will perform a repeated measurement at a specified point to see what the variance is for the microswitch.
Thursday, April 28, 2011
A More Advanced Way to Level the Bed
Ever since I first built my Mendel I've felt there has to be a more advanced way to level the bed than rolling a bit of dowel under the extruder nozzle. The Mendel is a very advanced CNC machine, but relies on a bit of wood to level the bed. Leveling the bed is important because even a deviation of 0.1mm can make the difference between the first layer sticking or not. A spirit-level is not accurate enough and measures the plane between the bed and the bench, not the plane between the extruder and the bed.
I wanted to find a way to use the Mendel itself to calibrate the level between the bed and the extruder. After thinking through various different approaches over the last few months, I settled on the following solution.
It would be based on a micro-switch that could be suspended beneath the extruder. The micro-switch would be connected in place of the normal Z-axis end-stop. The micro-switch would then be used to 'probe' the bed at various spots, each time the end-stop registered it should be possible to determine how many steps ahead or behind of where the end-stop was expected to be the extruder head had moved. The GCode M117 is already specified to provide this kind of information, mainly for determining if an axis is skipping steps, but it works here too.
The Micro-Switch Holder
I needed a way to hold the micro-switch that wouldn't require the extruder to be removed. I also wanted an approach that would allow the micro-switch to be added and removed easily. The easiest way to achieve this was to use magnets to attach the holder to the nuts on the bottom of the X-carriage. I designed a bracket that could be easily printed. The bracket was U-shaped, so that the magnets could contact the nuts but it would clear the extruder head. There was a foot on the bottom of the bracket to hold the micro-switch, which was offset so the switch lever was under the extruder nozzle.
Developing the Test Code
I had to create a simple application that controlled the Mendel to perform the calibration and collate and graph the results. I wrote it in my favorite language, Python. The program essentially takes a reference reading on the bed, then probes the bed at a number of points across its surface, recording the number of steps above or below the expected stop point. Since the Z-axis is screw-drive, it has incredibly high accuracy. My Mendel requires about 2700 steps per mm in the Z-axis. There does appear to be some variation in the micro-switch activation. Making repeated measurements in the same spot shows that it doesn't always return to zero, but the variation is relatively small, +/- 12 steps. Compared to a layer of blue-tape at ~230 steps, I'll live with the variance.
The firmware that is running on my Gen6 Mendel does not actually support the M117 command, so I had to port the appropriate code across from the current firmware into my version. The changes were relatively straightforward, but due to some interim changes in the firmware builds, not just a cut-and-paste job.
The First Test Results
The first set of results for my bed, which I considered to be relatively level, where quite surprising to say the least. The plot showed that the bed was bowed, clearly being pulled down in the corners by the screws and forcing the middle up. The total variation across the bed was 0.18mm, which explains why I was having some first layer adhesion problems on large prints. I could clearly do better.
Tuning the Bed
My first task was to remove the bed and look at it more closely. Holding a straight edge across it clearly showed that there was some initial level-ness issues. The aluminium bed is too thick to bend by hand, and the deviations were rather small (0.1mm), so I decided to grind the bed flat.
Using some 220-grit sandpaper taped to a sheet of 1/2" plywood, I ground down the bed until the visible gaps under the straight-edge were gone. I then reattached the bed very loosely and repeated the auto-calibration. It clearly wasn't level.
Using a spirit level was a bad idea, it measured the level-ness of the bench!
Using the old-dowel method was pretty good, but still not perfect.
Tweaking the bed screws and repeating the calibration it was clear that the force of the bed springs was distorting the bed. To get one side level, it skewed the opposite corner.
To try to correct this I decided to switch out the printed springs with wire springs. The same problem occurred. The upward force of the springs caused problems when leveling the bed.
In the end I opted to do away with the springs completely and use bolts fixed to the bed as pillars, resting on nuts on the Y-carriage for easy adjustment. It was much easier to adjust the bed to be completely level with this approach. I think I'll change the regular nuts out to locking nuts though, it will prevent them moving through vibration.
The downside with this approach is there is no give in the bed if the extruder plows into it. To overcome this, I think I'm going to put some small compression springs on top of the extruder connection screws. This should allow the extruder to move up slightly if anything goes wrong.
Level At Last
After six-days of tweaks and experiments, the bed is finally level and I'm happy. It is now level to within 0.08mm. I'm ignoring the last set of measurements at the back of the bed. They were made at the very back edge of the bed where I can't print anyway and no amount of screw adjustment can fix it.
Next Steps
Now I have a calibration method that allows me to either perform very detailed mapping of the bed flatness without removing the extruder or breaking out the dowel. If I do have to make adjustments, I won't spend ages adjusting bolts to find that they have changed something on the other side of the bed.
I also have the ability to perform very quick verifications of bed flatness. A four point test at the four screw locations takes under 2-minutes and is very good indicator of how flat the bed is now. I can also save the resulting graphs for future reference to see if things have changed over time.
Also, because I now know the deviation of the bed in millimeters, it takes the guess work out of how much to adjust the bed by. Each revolution of a M4 screw moves the nut by 0.7mm. Since the nuts are 6-sided, by moving the nut by one face I can get 0.116mm of adjustment very easily.
This work has some other potential uses that I am going to investigate. It could be possible to take the surface map of the bed and use it to dynamically adjust the first layer of GCode to overcome any minor surface variation by changing the Z-height while printing. I might try developing a Skeinforge plug-in that does this. Another use might be to use it to make point-clouds of objects placed on the bed - allowing me to create crude 3-D scans. I think that I'll need something more pointy than a micro-switch lever for the probing, but the calibration utility I have written will definitely work.
I'm just tidying up the calibration application and will post it shortly, along with the bracket STL file, if anyone is interested. I should also document the changes I made to the Gen6 FW to add the M117 command, because I'm sure I'll forget before the next release comes out!
8-Jun-11 - Update:
The calibration application is now available, along with the STL for the bracket here.
This series of scripts requires the Python libraries: PySerial, Matplotlib and NumPy
Note: This script banks on the Mendel firmware supporting the M117 GCode. Without it, it won't work!
RepRapComms.py: Comms library for communicating with a Mendel.
ZCal.py: Main calibration routines.
PlotBed.py: Bed plotting routines.
gui.py: A GUI to make calibration easier.
To use the GUI:
I wanted to find a way to use the Mendel itself to calibrate the level between the bed and the extruder. After thinking through various different approaches over the last few months, I settled on the following solution.
It would be based on a micro-switch that could be suspended beneath the extruder. The micro-switch would be connected in place of the normal Z-axis end-stop. The micro-switch would then be used to 'probe' the bed at various spots, each time the end-stop registered it should be possible to determine how many steps ahead or behind of where the end-stop was expected to be the extruder head had moved. The GCode M117 is already specified to provide this kind of information, mainly for determining if an axis is skipping steps, but it works here too.
The Micro-Switch Holder
Micro-Switch Bracket |
Developing the Test Code
I had to create a simple application that controlled the Mendel to perform the calibration and collate and graph the results. I wrote it in my favorite language, Python. The program essentially takes a reference reading on the bed, then probes the bed at a number of points across its surface, recording the number of steps above or below the expected stop point. Since the Z-axis is screw-drive, it has incredibly high accuracy. My Mendel requires about 2700 steps per mm in the Z-axis. There does appear to be some variation in the micro-switch activation. Making repeated measurements in the same spot shows that it doesn't always return to zero, but the variation is relatively small, +/- 12 steps. Compared to a layer of blue-tape at ~230 steps, I'll live with the variance.
The firmware that is running on my Gen6 Mendel does not actually support the M117 command, so I had to port the appropriate code across from the current firmware into my version. The changes were relatively straightforward, but due to some interim changes in the firmware builds, not just a cut-and-paste job.
The First Test Results
The first set of results for my bed, which I considered to be relatively level, where quite surprising to say the least. The plot showed that the bed was bowed, clearly being pulled down in the corners by the screws and forcing the middle up. The total variation across the bed was 0.18mm, which explains why I was having some first layer adhesion problems on large prints. I could clearly do better.
![]() |
Bowed Bed |
My first task was to remove the bed and look at it more closely. Holding a straight edge across it clearly showed that there was some initial level-ness issues. The aluminium bed is too thick to bend by hand, and the deviations were rather small (0.1mm), so I decided to grind the bed flat.
Using some 220-grit sandpaper taped to a sheet of 1/2" plywood, I ground down the bed until the visible gaps under the straight-edge were gone. I then reattached the bed very loosely and repeated the auto-calibration. It clearly wasn't level.
![]() |
Unfortunately, not level straight out of the gate. |
Using a spirit level was a bad idea, it measured the level-ness of the bench!
![]() |
The bubble was between the lines! |
![]() |
The trusty old dowel wasn't actually that bad. |
Tweaking the bed screws and repeating the calibration it was clear that the force of the bed springs was distorting the bed. To get one side level, it skewed the opposite corner.
![]() |
Adjusting one corner pulled the others out of whack. |
To try to correct this I decided to switch out the printed springs with wire springs. The same problem occurred. The upward force of the springs caused problems when leveling the bed.
No springs, just screw pillars |
The downside with this approach is there is no give in the bed if the extruder plows into it. To overcome this, I think I'm going to put some small compression springs on top of the extruder connection screws. This should allow the extruder to move up slightly if anything goes wrong.
Level At Last
After six-days of tweaks and experiments, the bed is finally level and I'm happy. It is now level to within 0.08mm. I'm ignoring the last set of measurements at the back of the bed. They were made at the very back edge of the bed where I can't print anyway and no amount of screw adjustment can fix it.
![]() |
Looks bad, but look at the scale! |
Now I have a calibration method that allows me to either perform very detailed mapping of the bed flatness without removing the extruder or breaking out the dowel. If I do have to make adjustments, I won't spend ages adjusting bolts to find that they have changed something on the other side of the bed.
I also have the ability to perform very quick verifications of bed flatness. A four point test at the four screw locations takes under 2-minutes and is very good indicator of how flat the bed is now. I can also save the resulting graphs for future reference to see if things have changed over time.
Also, because I now know the deviation of the bed in millimeters, it takes the guess work out of how much to adjust the bed by. Each revolution of a M4 screw moves the nut by 0.7mm. Since the nuts are 6-sided, by moving the nut by one face I can get 0.116mm of adjustment very easily.
This work has some other potential uses that I am going to investigate. It could be possible to take the surface map of the bed and use it to dynamically adjust the first layer of GCode to overcome any minor surface variation by changing the Z-height while printing. I might try developing a Skeinforge plug-in that does this. Another use might be to use it to make point-clouds of objects placed on the bed - allowing me to create crude 3-D scans. I think that I'll need something more pointy than a micro-switch lever for the probing, but the calibration utility I have written will definitely work.
I'm just tidying up the calibration application and will post it shortly, along with the bracket STL file, if anyone is interested. I should also document the changes I made to the Gen6 FW to add the M117 command, because I'm sure I'll forget before the next release comes out!
8-Jun-11 - Update:
The calibration application is now available, along with the STL for the bracket here.
This series of scripts requires the Python libraries: PySerial, Matplotlib and NumPy
Note: This script banks on the Mendel firmware supporting the M117 GCode. Without it, it won't work!
RepRapComms.py: Comms library for communicating with a Mendel.
ZCal.py: Main calibration routines.
PlotBed.py: Bed plotting routines.
gui.py: A GUI to make calibration easier.
To use the GUI:
- Use the Printer Menu tab to configure the various settings to match your printer.
- Calibrate Button, will perform a series of measurements across the whole bed at the specified X & Y step size.
- Quick Cal Button, will perform a quick test at four specified points across the bed.
- Variance Button, will perform a repeated measurement at a specified point to see what the variance is for the microswitch.
Wednesday, April 6, 2011
Leveling the X-axis and the Bed
Tonight's main focus was on leveling the X-axis and the bed to try to correct this continual Z-offset that keeps occurring. Last nights attempt to adjust the Z-flag had helped but it was still occurring.
I started by verifying that the Y-rods were level, which they were. Then I used those as a reference to measure the distance between the X-rods. There was a delta between the two ends of a few tenths of mm. Given that 0.1mm variation in extruder height can make a difference between good first layer adhesion and not, this needed to be corrected.
I loosened the tensioning pulley on the Z-belt and manually adjusted each Z-screw until the reading on the calipers was the same for each Y-rod to front X-rod distance. Then I tightened everything back up making sure that nothing moved. When it was all back together I reverified the measurements to make sure nothing had moved.
I then used a similar technique to set the height of the bed from the Y-rods. This was a loooong process as each adjustment changed the other spring heights slightly. Once they were all the same I could proceed to verify the bed against the extruder nozzle. It was fairly level now, but did require some minor adjustments to bring the separation between the nozzle and bed even in all corners.
I also discovered something interesting with the printed 'W' bed springs. They don't apply even force to the bed. I had them running parallel with the bed, but I found that on the top of the spring was not always flat and applied more pressure either before the bolt or after (depending on how the top was distorted), changing the bed height very slightly. I decided to rotate the springs 90-degrees to be perpendicular to the bed, so their top surface has less contact along the length of the bed. This appears to help these slight bed distortions.
I then was able to get on to some more test prints. I dialed down the flow rate to 1200 (from 1300), the print quality was very good. Possibly one of the best to date. The first layer still had too much flow, so I may need to play with the first layer settings. As the print went on, the higher layers got more ropey, I put that down to how I have my spool of filament. It doesn't turn very easily and after some time printing the force required to pull filament off the spool is too much for the extruder - unless I manually turn the spool a bit. Must get a better spool!
The print continued to pause nearly every layer - just like last night, so I did roll-up my sleeves and dive into the G-Code. Skeinforge appears to be generating the deprecated M108 code (old code to control the extruder). A quick search and replace removed them all and the GCode printed without issues. I need to add M108 to my replace file.
I also updated my Gen6 Firmware to the latest version that came out earlier this year. Tomorrow I'll write a detailed article on how to upgrade the firmware and some of the changes I made (these for my own benefit so I can figure out how to do it again when the next release comes out!)
I started by verifying that the Y-rods were level, which they were. Then I used those as a reference to measure the distance between the X-rods. There was a delta between the two ends of a few tenths of mm. Given that 0.1mm variation in extruder height can make a difference between good first layer adhesion and not, this needed to be corrected.
I loosened the tensioning pulley on the Z-belt and manually adjusted each Z-screw until the reading on the calipers was the same for each Y-rod to front X-rod distance. Then I tightened everything back up making sure that nothing moved. When it was all back together I reverified the measurements to make sure nothing had moved.
I then used a similar technique to set the height of the bed from the Y-rods. This was a loooong process as each adjustment changed the other spring heights slightly. Once they were all the same I could proceed to verify the bed against the extruder nozzle. It was fairly level now, but did require some minor adjustments to bring the separation between the nozzle and bed even in all corners.
I also discovered something interesting with the printed 'W' bed springs. They don't apply even force to the bed. I had them running parallel with the bed, but I found that on the top of the spring was not always flat and applied more pressure either before the bolt or after (depending on how the top was distorted), changing the bed height very slightly. I decided to rotate the springs 90-degrees to be perpendicular to the bed, so their top surface has less contact along the length of the bed. This appears to help these slight bed distortions.
I then was able to get on to some more test prints. I dialed down the flow rate to 1200 (from 1300), the print quality was very good. Possibly one of the best to date. The first layer still had too much flow, so I may need to play with the first layer settings. As the print went on, the higher layers got more ropey, I put that down to how I have my spool of filament. It doesn't turn very easily and after some time printing the force required to pull filament off the spool is too much for the extruder - unless I manually turn the spool a bit. Must get a better spool!
The print continued to pause nearly every layer - just like last night, so I did roll-up my sleeves and dive into the G-Code. Skeinforge appears to be generating the deprecated M108 code (old code to control the extruder). A quick search and replace removed them all and the GCode printed without issues. I need to add M108 to my replace file.
I also updated my Gen6 Firmware to the latest version that came out earlier this year. Tomorrow I'll write a detailed article on how to upgrade the firmware and some of the changes I made (these for my own benefit so I can figure out how to do it again when the next release comes out!)
Subscribe to:
Posts (Atom)