Introduction: Goodbye Moshi or How to Run Your Laser Printer on Arduino

Picture of Goodbye Moshi or How to Run Your Laser Printer on Arduino

Update 19/04/2016:
MarlinKimbra is here!
This is one of the best firmwares based on Marlin I have seen for a long time, no feature is missing.
But for our purpose here it is just about being up to date and getting better results.
Please check the last step of this Ible as I will keep future updates there.


Update 11/04/2016: The new firmware is available now in my Ible about 8bit engraving.
This means the power level is now from 0 to 10000, giving a higher resolution for the power without compromising speed or other functions.
Engravings on fragile things like paper are now possible without burning holes.
All SD and display functions have been modified to suit the firmware, so you can move the head, do testburns at various power levels and even tweak most of the settings to be totally independant from a PC / laptop.
I tried my best to implement WiFi as well but could not get it working properly, so if you do want to transfer your Gcode files without swapping the SD use a WiFi enabled SD card instead.
Never tried it due to a lack of hardware but it should also work using Octoprint.

Update 27/02/2016:

True 8bit photo engraving is now possible, please check the addition here.

Update 26/02/2016:
I was able to change the Marlin code so that now a much higher resolution for the Laser PWM signal is possible.
Please beware that I also found a problem in the code.
The curent power settings are not deviced in 256 steps but limited to 100 - reflecting the original machines 0-100% settings!
I will do some tests on the weekend and if all good upload the modified firmware for everyone interested to test.
With that it should now be possible to do true 8bit engravings with a CO2 laser - something even Picengrave can't do at this stage.
I will also add links to the software used to used to generate the code the true greyscale engravings and how to modify the Gcode for proper placement on the machine. - Stay tuned!

When it comes to starting with CO2 lasers the beginner on a budget will be tempted to get one of the K40 clones from china.

As requests, problems and postings of general frustration about these machines flood the internet I though I jump in too.
Don't get me wrong, I did it on purpose as the price for the entire machine was about the same as just a 40W laser tube imported to Australia - and that is without a power supply...
I already started a topic in the forum on why not buy them but if you already did or still want to get one, this Ible might be helpful on your way.

What you will get in this Instructable:
All the info, sofware and tips you need to convert your budget laser cutter to run on an Arduino board - for far under 50$.
Also the satisfaction that you can now create all your things directly in Inkscape (or other vector programs).

What you need, tools, and such:
1. Patience...
If your machine is anything like mine you don't want to rush things as not everything is perfect in China.
2. A basic understanding of wiring some cables and some very soldering skills.
3. Basic toolset.
Flat and phillips head screwdriver, 7mm spanner (keep the set at hand, you never know...), pliers, side cutters, soldering iron, heat shrink tube or if in doubt electrical tape.
4. Arduino Mega with Ramps board, optional a display with encoder and SD support to have a stand alone solution.
5. Some old computer cables, connectors and such - I tried to keep the original cables the way they are, it is no problem not to use connectors and to solder directly.
The only thing I really suggest using connectors fo is on the pins for the ramps board, I used single LED pins from an old computer.
You can source the complete kits including Ramps and stepper drivers for around 30-40$ either through Ebay or your trusted local dealer.
6. Two 10kOhm resistors.

First to the specs:
40W CO2 laser - claimed power, so we can assume it is around 30W when you would measure it.
Unlike most of them I got mine with a digital power control and not the analog meter with potentiometer.
Rest is like any other chinese clone out there except the electronics...
Here can already make out if you might get some fun out of it or not.
Mine came with the totally outdated "Corel Laser draw", from 2013 and with a golden dongle.
Others have newer software and other dongle colors, indicating a newer control board.
The 2016 versions also support vector cutting and speed/power settings by line color definition (but they cost more and are very hard to find).
So unless you got the latest model you will most likely have it shipped with Moshi Draw, Corel Laser Draw (2013-2014) or in very rare cases with real software like you would find on high end machines - again for a much higher price.

Is this Ible interesting for me and does help my machine?
If you can only do engravings and cuts with raster images like BMP,JPG,TIF,PNG but not in any vector format then it can help you.
If your machine and software already come with full vector support and a print driver to use it with any software out there you might want to find other reading material.
Although some of the mods might be of interest to you anyway... ;)

I will start with some basics of the crippled stuff and how to improve your work a bit but the real deal starts at step 4 with the replacement of the controller board.

Can I use it for something else?
Of course you can!
As it is a "generic" approach this mod can also be used on your homemeade diode laser engraver.
You will need to modify the Marlin firmware to suit your needs though in terms of endstops, buil dimensions and such (easy!).

Info on the above images:
The pegasus was engraved on cheap, 3mm plywood - not a good choice LOL
My niece was engraved on plywood too but with the original Turnkey release and before the full 8 bit support was added.
And the old movie image with Billy the kid was engraved on Arakaria wood with the latest firmware mods.

Step 1: The Hardware Limitations of the Original Controller

If you don't have one of the latest controllers installed you won't have any DSP or true vector support.
Even if it looks in the software like you do, you might have notices that your dimensions come out wrong in a lot of cases.
This is due to the simple fact that the cutter can only handle raster images but no true vector images.
Moving the head line by line to "print" and engraving is easy enough as simply the image is transfered line by line and pixel by pixel.
Where there is a dot there will be a burn mark.
That of course is also the reason why you can't just take a nice color image and burn it on some wood.
The software will transfer it to a grayscale image and use some algorithm to determine at which level there should be a burn or no burn.
Usually the result is far from satifying...
When you create some simple cuts within the software it will really look like it is doing vector cuts, while in relality the software just uses the lines to move the head around.
Saving such a cut and analysing it with a Hex editor shows everything is saved within the cryptic file, like dimensions of the table and work area but also the stuff to cut - as a transparent PNG image - again raster format.
All this comes from a controller that is unable to move the axis like a CNC machine.
The later software versions can sometimes cover for this but never really satisfy in the long run.

Ok, the controller might be crap, what about the rest?
On my tube was no sticker, mark or so telling me the claimed power or other electrical data.
The Y-axis has a linear rod and bearing only on one side, might be enough for a small work area but the loose other end tends to cause vibrations.
The X-axis is made from a weird profile that gives really good stability and uses only simple rollers to hold the laser head in position - again for short distance it might be enough.
You see where I'm getting?? ;)
Enough but never really good enough, like using just bots and nuts, no washers, lock washers or lock nuts.
If someting is a no fit or not aligned properly force it into the right place as the customer might never see it...
Let's just say you really get what you paid for it.
This means identical looking machines costing twice as much as the china version might have started the same way.
The difference is that someone took the time to make them compliant with local safety and electrical standards.
Things like adding a switch for the lid, flow and temp control for the water, plug on the machine for the fan and pump...
Means someone spent a lot of work hours getting the machine right for you ;)

Step 2: Software Limitations of the Original Setup

As said if you can't define power or at least speed with different colors you might be frustrated every now and then.
The 2013, 2013 and 2014 software versions (to my knowledge) only support raster images.
To make things worse doing cuts from raster images might at first look like it is working fine but:
A vector line is a straight line, no matter what angle, a line on a raster image is always made from dots and quite often these dots overlap.
With a software being unable to put this into a clean and single movement you often see your head doing all sorts of movements except following the lines in the image.

Engraving seems to be the only thing really working with these machines but even there you need a lot of time and external programs to get really good results.
But if you manage to transfer a nice picture into a B/W bitmap that does not look to have too many totally black areas the result can be stunning.

Step 3: Ripping the Old Machine Apart, Well Sort Of...

At first I decided to take a lot of pictures for this step so every little detail is covered.
Then the reality hit me by letting me know that there are several variations of the hardware out there :(

So I will try too keep it really simple....
Disconnect power and USB!!!
The original controller has to go out, same for the laser power supply.
The controller is mounted with 4 screws - take them out including the spacers and washers - if you find washers...
The power supply is mounted with 4 screws towards the inside on the machine, in some cases it might be mounted to the floor instead.
There might be a short cable channel or just cable ties used to sort the wires, get all wires loose without disconnecting them so you take out the power supply and controller with all cables attached.
Important!!: Now take a permanent marker and mark all connectors and sockets so if you have to re-connect you will be able to know where and in which direction!!
Check your pic so you are certain you see all details you need!
Disconnect all cables from the controller, it should be one plug with 4 wires going to the power supply, two 4-wire connectors for the stepper motors and one 3-wire connector for the endstops.
Put the controller, dongle and software somewhere safe.
Slide out the power supply if not already done to get access to the control panel above.
If you have problems getting to the 4 nuts holding it use a small ratchet and 7mm socket instead - I tried for 30 minutes to break my fingers until I realised the ratchet was right next to me.
Once you have the panel out take another pic of the connectors there - just in case...
Disconnect the panel from the laser power supply.
Here you either have a flat ribbon cable or similar plugs like used on the stepper motors.

Check the images from my hardware for comaprison - I will refer to them later again for the wiring of the Arduino.


As you can see the vital wires are all clearly marked on the circuits boards to make it easier for us ;)

Step 4: Adding the Arduino

A huge thanks for doing all this hard work already goes to Dan Beaven who inspired my to try it myself.
Also without the work of Turnkey Tyranny we would not have a working firmware for our Arduinos or the Incscape G-code export plugin - great job!
Of course I also need to mention the great guys at the Lansing Makers Group who started all this pioneering work.
So don't be fooled to think I did all the hard work - thank those above for it!

To continue please prepare your RAMPS board so it can cater for 24V.
Check the Wiki page, in the power section you will find the location of the D1 and D2 diodes - D1 needs to be removed!
The two big, yellow plates are polyfuses and we need to short them with a lenght of wire so the board can handle the 24V properly if not done you might encounter random disconnections.
If you want to keep them for safety reasons please replace them with 30V types.

Now it is time to connect everything - I won't bother too much at this stage to make proper mounts an such as I still plan do some further mods to be covered in another Ible.

Please use the images from the last step as a reference, your internals might differ a bit but the basics are still the same, even if yours has a analog meter.
On the ramps board you need to check under the drivers if the jumpers are set correctly for 1/64 microstepping!
As it is the maximum these cheap drivers support you can put all 3 jumpers in there.
Dending on you skills and material at hand you will either use connectors or solder the wires without the right connectors directly - either I will only refer as "connecting" in this matter.
Check this nice diagram Dan Beaven made as a reference:

In my case there was no ribbon cable at all, just two identical connectors for the steppers, which caused me a bit of a headache at first.

To spare the headache use the above image a s a reference and do this:
The big cables between controller and PSU are the power supply, start with them and disregard the wire on the "LO" connction - you only need 5V, 24V and GND.
Only if your Laser power supply does not offer a PWM control you still need the power adjustment and the analog meter - plus make some minor changes in the firmware (documented).
Next connect the Laser fire and PWM signal wires - if your PSU is different check the circuit boards for the corresponding connections and use them.
Now do the stepper motors and if you have a ribbon cable for motor and endstops follow the above diagram, otherwise plug the motor in and prepare the endstop or cable to cater for pull up resistors.
If you are unsure about this step check this Wiki for the wiring details of the resistors.
Connect the endstops to ramps board, 5V and GND - it does not matter which 5V terminal or ground terminal is used here.
There is a chance your stepper motors will run in the wrong direction, if that happens simply put the connectors on in "reverse".
That should be the electronics for now, display with full motion control will be covered in the next Ible.

Step 5: Flashing the Firmware Onto the Arduino

Update 19/04/2016:
Please ignore the files here as there is another step added for the latest firmware.
Go there and download always the lastest release I offer.

Right now all should be mechancially good on your end, the electronics back in the machine and all wiring double checked.
Time to get the software part working...

I tried firmwares directly from Dan Beaven as well as other releases based on the Turnkey Tyranny mods but either they totally failed to compile or did not work together with my machine.
The solution was to modify the firmware to suit the needs of a direct conversion without display or additional controls.
You will need the Arduino 1.05 ISP with the corresponding libraries to compile the firmware.
I spared you this nightmare and packed all the software for this Ible into one archive.
So please download it from here (200mb).
Everything is in there, so unpack to a folder on your computer and leave the folder structure as it is.
Connect the Arduino with the PC but do not power up the laser cutter yet.
Start the Arduino IDE and open the "Marlin.ide" file - the Marlin releas is located in the folder "My Machine/Marlin".
From the IDE tool menu set the Arduino Mega 2560 256 Serial Buffer as the board to make use of my changes in regards to the increased buffer sizes, but that is totally optional, you can use the standard Mega 2560 as well.
Select the serial port as it shows up in your systems device manager - it must be a match.
Upload the sketch and be patient it can take a while.
There should be no errors in regards to missing libraries, dependcies or includes and I won't help out if you used you own Arduino ISP to get it all going.

If your Ardunio does not connect or Windows can't find any drivers you might have a clone that uses the 341 chipset, I included them in the Archive as well.
The standard drivers for the Arduino are included with the IDE if Windoes fails to find the right ones online when you plug the Arduino in.

Step 6: Firing Up the Machine

You are now at the point that turning on the machine should not cause any problems.
That means it is ready to use, well sort of...
Right now your new toy only knows how to communicate over USB and to accept G-Code commands through the serial connection.
Might not be as fancy as having dedicated printer drivers but our controller was well under the 50$ mark ;)

Does not look too nice right now but for the testing it was good enough, I suggest to screw the Arduino in place instead of placing it on isolating plastich sheets:

In the next stage this will be all cleaned up, a display and SD support added and if possible some tweaks in the firmware to get higher engraving speeds.
Note that only the drivers for the x- and y- axis are needed on the board, but I left them all on there for future upgrades and so I won't lose them.

Step 7: Getting the Software Running

To generate the right g-code for this mod you need Inkscape and the corresponding plugin by Turnkey Tyranny.
I did not include Inkscape in the downloaded archive to be flexible with updates, please download your 32 bit version here.

I don't know if the plugin works with outher releases, like for the Mac but I do know it won't work with the 64 bit release.
After installing Inkscape copy the plugin into Inkscapes extension folder as explained in detail in the included "Readme.md" - basically just copy the .inx and .py file into the Inkscape extension folder C:\Program Files\Inkscape\share\extensions .
Now you can start Inkscape and select the plugin from the Extension menu.
A good start is to use the supplied "cutting_surface.svg" from the designs folder (in the folder of the plugin), it has some nice examples to try included.


WARNING:
Before you do anything with laser power make sure you never forget to keep the power levels low!
Through the direct PWM control of the Arduino the laser will be working at 18mA when 72% power is reached - this is the limit for these 40W tubes, 50 or 60W tubes might be able to use 100% if you dare to try.

Basic usage:
I won't explain all fine details of the possible settings, that will leave you some playtime for later.
But I will provide you with what you need to get going without ripping your hair out.
Inkscape can do a lot of things when it comes to creating your 2D designs but for the purpose of using the design with the laser we need to stick to some rules.
Line art:
Everything you design must end up as a path!!
This means you you have to convert your objects into a path to be able to cut it.
You can combine the paths group by group (e.g. make each hole into a seperate path) or for the entire object.
Keep in mind that overlapping lines in your design will be cut twice, so make sure all is "one piece".
Raster images:
If Inkscape can import it you can use it.
But I do not recommend using the plugin directly on any image that was not prepared prioe for laser cutting.
Tried it a few times with grascale and color images but the result was not really satisfying to say the best.
But if you convert your image before importing it into your project into a nice looking BW bitmap it will be "engraved" very nice indeed.
Preparing for the laser:
As said, make sure your design is either a raster image or a combined path.
The plugin works with two possible option to set the job.
a) Only trought the popup menu settings.
b) By naming your layer according to how you want to cut / engrave it.
Examples on the naming are included in the cutting_surface.svg file.
The good thing here is that you can set independent settings for each part of the job, like engraving an image at low speed and low power and a frame cutting at high power and medium speed.
A very nice feature is the PPM setting.
Here you specify how many pulses per mm are fired.
Depending on the material this really does make the job easier or gives better results.
Take glass engravings.
With the old hardware the machine fired a constant beam wherever there was someting to fire at.
Now you can specify to only fire 10 pulses per mm and prevent glass chipping for a nicer finnish.
Stinky materials like polysterene hard sheets just melt with the constant beam while with pulses you can shoot through the material without too much excess heat.
Requires some tweaking and testing to get it right though.
One of the big downsides I found is how the actual g-code is generated.
There is simply no way to specify the job order for a complex task.
To be precise: The plugin will only make sure that raster engravings come first, everything after seems to be total random to me.
So it is possible that by default the machine will cut out the part before trying to add the holes in the already dropped part.
If you use a nice honeycomb frame for the build area it does not matter too much for clamped objects it is not so nice.
I was unable to find a fix for this and I still struggle with Python to adjust the plugin to cater for some user settings for the cutting order.
But like for everything on Instructables there is a workaround.
Export the jobs one by one through the plugin in the order you wish and combine the g-code manually with an editor.
In the top of each .g file you will find something like this:

G21 ; All units in mm
M80 ; Turn on Optional Peripherals Board at LMN
; Raster data will always precede vector data
; Default Cut Feedrate 3600 mm per minute
; Default Move Feedrate 2400 mm per minute
; Default Laser Intensity 0 percent G28 XY; home X and Y

M5 ;turn the laser off

;(************************************************************)
;(***** Layer: 60 [feed=120] *****)
;(***** Laser Power: 60 *****)
;(***** Feed Rate: 120.0 *****)
;(************************************************************)


This defines the start and the initial setting for the first job are listed.
At the end of the file you always see something like this:

M5 ;turn the laser off

G00 X0 Y0 F4000 ; home


Turns off the laser and sends the head in the home position.
To combine your g codes you cut the M5 and G00 commands out of the first job.
From the next job you cut the top part off including the M5 command before the listing of the job details.
Add the second job to the first.
For the last job you only cut off the top part - again till the the listing of the job including the M5 command.
Leave the end of this job alone and add it to the rest.
Save the file with a new name and use it for your machine.

Cutting / engraving your creations
Sadly there is g-code sender included in the plugin so we have to substitude a program from the 3D printing world.
I included Proterface in the big download but other solutions should work the same.
Please keep in mind that Pronterface only acts as g-code sender but will be unable to give anything else.
You can load the g-code, start the job, pause it and adjust the speed on the fly - that's it.
Unless you added a lifting table to your machine the z-homing will not work.
So you should not use the home all button as otherwise the Arduino will wait forever for something to hit the z-endstop.
If I ever manage to get the compiler working properly I will change the UI of pronterface a bit to remove functions that are not needed.


You can see the machine running on the first firmware I got running properly in this video:

If you got enough from the engraving skip to 5:40 to see the raster engraving and cutting done.

Speeds:

I am still finetuning the firmware settings but vector cuts should work fine with up to 2400mm/s depending on the line lengths and complexity.
Raster engravings can run a bit faster but sometimes there is still a glitch causing massive rattling noise from the stepper and lost steps - if that happens lower your spped and reduce the laser power accordingly.
Simple things and contours can be lasered in vectors at up to 3600mm/min.
But I suggest to use lower speeds when possible and to test really high speeds on some cardboard first to prevent wasting some expensive material if you lose a step or two.

Accuracy:
The parts come out to the specified dimensions, some materials might cause a bit more loss, especially if the focus of the laser is not set properly.
Repeating a job did not give me any negative results at normal speeds, all lines match up perfectly.
If the speed is too high, or the motor current too low there will be lost steps though.
As cutting speeds are quite low anyway I guess for the time being the speed restrictions set in the firmware should still be higher than what the mechanics are good for.

Step 8: Troubleshooting the Mechanics

If you really made it all the way here it means you either want to read it all or that something is not working as planned.
Before you continue confirm your driver boards are set to the correct stepping as the defined steps per mm are correctly defined in the firmware.
So any problems related to wrong dimensions should be gone once the stepping is jumpered correctly.

Loosing steps:
Although it should not happen it does not mean that it never will.
Assuming you did not lower the current for the motors too much the only thing left is the movement speed.
Trying to do a vector engraving of a really complex piece with 5000mm/min or more will just not work.
The algorithms in the firmware are optimised for 3D printing and have quite a bit of ballast we will never need and without documented changes I am unable to update all files to the latest Marlin RC.
This means you should keep your speed to sane levels.

Stepper motors won't work at all or stutter all the time:

If your stepping and the current setting on the driver boards is correct there is a chance that your EEPROM settings are messed up.
This happens quite easy if the Arduino was used for other projects before or simply by making a typo when manually sending commands to the machine.
To fix this open the example sketch in the EEPROM Library, replace the 512 for the memory size with 4096 and upload the sketch.
After that re-upload the Marlin firmware and your EEPROM should work as planned.

Axis won't move the right lenth:
This usually means the stepping on the driver boards is not a match for the motor stepping in the firmware.
Best solution is to set the jumpers on the Ramps board correctly or if the driver won't support the stepping to adjust the steps per mm in the firmware.
No complicated calculations needed, to go to the next lower stepping simply divide the steps per mm by two.

My cuttings and engravings burn through everything:
Keep in mind you no longer need to work with just a constant laser beam and that the laser is controlled differently now!
For cuts don't use the PPM control, for everything else do use it to get the best looking result.
The speed and power settings you are used to might no longer match now.

Step 9: Things Planned for the Next Upgrade

For the second Ible on this topic you can expect the following:
1. Adding a nice case and fan for the Arduino.
2. Adding a display with encoder and SD support.
3. Adding a new control panel for the display and some more switches to remove all these plugs for fan, pump, compressor and so on.
4. Adding a better air assist system.
5. Adding safety switches for the lid and water flow.
6. Adding a manual firing button for testing purposes if I can add this into the firmware otherwise hardwired to the laser power supply.

These mods mostly depend on my long overdue display and finding the time to do the electrical mods, so it might be just a matter of two or three wekks.

For the third Ible on this topic you can expect the following:
1. Adding a motorized table with control through Pronterface.
2. Maybe adding a red laser for extra guidance with the manual control throught the display controller.
3. Checking the options to add a custom rotary adapter for round objects.
4. Making a new exhaust and adding a stronger fan.
5. If possible adding firmware support for the water pump, compressor and safety features.
6. Adding a lens mount with adjustable focus if the motorized table should fail for some reason.

Timeframe for these mods to be announced once the second part was running to my satisfaction for a while.

Step 10: Firmware Mods

Picture of Firmware Mods

We now can cut in a proper way and also do raster engravings - but what about true 8bit engravings of greyscale images?
The above was done with a slightly modded firmware and the Gcode generated with Image2Gcode - the guys at vicious1.com did a great job with the tool.
But to get the best results from a CO2 cutter I had to make some slight changes.
If you are interested in quality engravings on your chinaware then check this Ible out - everything you need is there ;)

For the above image I had to do quite a few testruns as the target was a sheet of copy paper!
Size of the engraving is 65mm wide and 56mm high.
Engraving time: 26minutes.

Step 11: The Latest Firmware Is Here!

I teamed up with some great guys working on the MarlinKimbra firmware.
Thanks to their work I can now offer the latest Marlin release to work with the K40 Laser clones.
Full 8bit engraving support through the Inkscape plugin allowing photo engravings with ease.
All configured for your K40.
Please download the attached hex file if you want to just flash with XLoader or go to Github and download the source files.
For the source files you will need the lates ArduinoIDE as the release requires it.

The firmware is already completly configured for the modifications of this Instructable.
Only if you use single pin control for firing your laser you need to check the wiring diagram and make the change in configuration_laser.h.

#define LASER_CONTROL 2
needs to be changed to

#define LASER_CONTROL 1

Display and SD are working fine so full standalone operation is possible.
No WiFi support as yet directly in the firmware but you can use a WiFi enabled SD card to transfer the files and forget about swapping the card.
Octoprint should work too but due to a lack of hardware I can't check.


Here is a video showing the machine engraving a photo.
Sorry for the bad quality but it is a pain to get proper focus through the orange lid - have to replace it with a clear one.

Here is an imaged engraved at 7200mm/min, size is 240x180mm, material: paper.
Time to engrave: 62minutes

Comments

Milkierich (author)2017-10-01

ok, complete idiot here, I work mostly with pictures.

Uploaded the firmware, after clearing the eeprom,

Checked and double checked my wiring,

Looking at the laser tube, the pwm is working a treat, but I cannot for the life of me get the x and y axes to move. I checked the servos by shorting pins and seem ok, however, both axes seem to run freely (push) when powered on (as if x and y on ramps not initialised? I am sure I am doing something stupid, so happy to take any ridicule but would greatly appreciate any help

Milkierich (author)Milkierich2017-10-03

figured it out, I am a moron and didn't plug the drivers in. Still, all seems ok now, just need to replace the end stops as I replaced ribbon cables with headers and it's now a bit tight!

Gerard1 (author)2017-09-18

Great Job :)
I also want to upgrade the 4030 laser :)
I will use your tutorials, but i also want to use a display to see the settings of the laser and what the laser is doing :)
Can you send / give me / us your latest firmware of the upgrade for the Arduino Mega in .PDE or .INO format ? or did i mis something ?

MarcoM235 made it! (author)2016-12-27

At last i made it, thanks for your tutorial, very exhaustive , with the new hardware and software I also made a new control panel. Just one thing bugs me, I cannot compile the firmare (I used that supplied by you), I receive this message from the Arduino IDE: /var/folders/gt/7pnl3r5j2vb38dck7rl2gk8h0000gn/T//ccBGwCiM.ltrans0.ltrans.o: In function `main':

/Users/marcomazzocchi/Library/Arduino15/packages/arduino/hardware/avr/1.6.16/cores/arduino/main.cpp:43: undefined reference to `setup'

/Users/marcomazzocchi/Library/Arduino15/packages/arduino/hardware/avr/1.6.16/cores/arduino/main.cpp:46: undefined reference to `loop'

collect2: error: ld returned 1 exit status

exit status 1

Any clue?

Cheers

Marco

DavidG747 (author)MarcoM2352017-01-09

I can confirm it is the version of IDE I couldn't figure it out then I followed the advice here and I was able to compile with version 1.6.8. I have a different LCD so I had to make the changes.

MarcoM235 (author)DavidG7472017-01-09

Thanks David!
Indeed with ver. 1.6.8 works without problem, You saved me a heavy headache!
Marco

Downunder35m (author)MarcoM2352016-12-27

Thank you very much for the pics!
Great job on you end and I hope it will encourage more people to try it.

Downunder35m (author)MarcoM2352016-12-27

The only clue I have here is the one that was already true for all the 3D printing firmwares out there.
Get the right IDE version and the right libraries together.
The code must compile with no significant error that would cause a stop.
In 99% of cases when I encounter problems with code posted somewhere that is known to work I simply try different versions of the Arduino IDE.
Real trouble only starts when mixing code from different projects or when just copying libraries from one IDE version to another.
Try a 1.6 version for compliling and once you get the first error make sure to download the missing libraries for this version that correspond to the error - should be only two if they are not already included in the standard release.
The rest should all be included in the files you got, especially the base64 stuff.
Sometimes you can get into trouble if the IDE uses a library already included in the project that is different.
Here you can manually load the correct library and override the default.

Downunder35m (author)2016-12-27

Last but not least a little update on the stalled progress here:
I had to move house and am now quite limited on space and options until I find a suitable new home.
The landlord does not allow me to use the laser as he claims it is a fire risk and the fumes will cause the room to stink.
All
based on a subsection of the rental agreement stating that I need
approval from the landlord if using any kind of stationary machines :(
This gave me some time for other projects that are still in the developing phases but also to re-think the approach here.
I
mean we already showed that a cheap chinese laser can do much more than
advertised once converted with a "better" controller, but the hardware
is still '$%&*"....
One of the big downsides IMHO is the size of
the workspace with only the clamp for thicker things and the less than
vibration free x-axis system.
With currently over 150 likes I can only assume that more than a hand full of people tried this with their machine - and I Like it!
But let's talk options for a change:
By now you already realised the potential of your refurbished toy and might want to do even more.
An adjustable work table would be great or not?
Something that actually provides a proper enclosure so the fumes are all extracted instead of polluting your room might be nice too?
But how about all the above plus a much bigger area to work with? ;)
We are not afraid to modify our laser cutter and most of us are not afraid to use tools either, so let's combine those skills.
Think with me now and read again from here if you struggle to follow.
The actually work area is mounted to the frame holding the rest of the machine.
Making it a systems that is limited to the physical dimension of the rails inside.
Industrial systems work in a similar way but without the enclosure.
Thankfully the chinese copied the industrial system in the cheapest way possible instead of designing something based on a printer.
This means we can quite easy upscale working area up to the limit where the laser beam becomes too wide for the lens to handle due to thedistance from the source.
My current idea would require a custom mounting system for the tube and custom rails for the mirrors and lens.
The hobby CNC projects already showed that you don't always need expensive linear rails to achive good accuracy and also that you can make normal stepper motors run quite fast with a 32bit processor behind them.
The current firmware already allows for the implementation of a height adjustable table, even with automatic bed levelling if required.
But instead of lifting the work platform we could lift the entire frame.
And for really big work pieces we could simply place the laser directly onto it - flat surface permitting.
No more cutting by hand of these big sheets, just put the machine directly on it and do what you need without any waste to throw away.
Downside is that instead of having a unit with lid and exhaust van you need to build a suitable sized housing.
Here I was thinking of a big enclosure similar to sand blasting cabinets with these brush strips on the front and side to allow feeding bigger sheets without compromising on the fume side of things.
Once the cheap laser tube is burnt out such a system makes it quite easy to install a 100 or even 200W tube instead of the 40W one to actually work with some metals.

Let me know what you think, post your ideas or comments on this and let's work together to make a reall big laser cutter.


RobertS319 (author)2016-12-21

All sorted now, I found another preconfiled Hex of yours that works perfectly I must have been using an older version before, I cant find any faults what so ever, it just works!.

thank you.

On a side note though, is there any way of visualizing what a raster engrave will look like before i actually cut it? All the tools I've tried so far fail to display it, Vectors display fine just not rasters.

Downunder35m (author)RobertS3192016-12-21

I think you are not the only one struggling with the raster, so I will try to explain it in more detail:
Inkscape can't really create complex rasters, a solid filling at a specified level of gray is fine but a photo for example won't work.
For this you need to import the raster image into Inkscape.
Best way to do this is to prepare the image externally so the size is already correct - but you can change that in Inkscape at any time.
It makes sense to import or move the bitmap into a dedicated layer.
If done this way Inkscape will recognise the image as a raster and same for the laser plugin.
For true raster images the output is exactly what you have in the image - a burnt hole fore every single dark pixel.
For a grayscale image or photo the laser intensity will be adjusted according to the pixel value.
Here you need to play around a bit to get it right with the power settings as every machine and material is slightly different.
For exapmle on cardboard I use a power level of 1100 as a max and play with the speed to prevent actually burning off the material.
On glass I prefer to use raster images only at power levels around 1600 - 1800.

RobertS319 (author)2016-12-18

Hi, first I would like to say a huge thank you to the work that you
have done and put together for us to follow. I have now followed both of
your indestructible's and have the set up working almost perfectly. For
some reason however if I compile your latest source from https://github.com/Downunder35m/MarlinKimbra-K40

The K40 always burns at the same power setting, no matter what i set in the inkscape layer name.

Your
precompiled hex linked above works perfectly but I cant jog properly on
the LCD panel. This isn't really that much of an issue at the moment
but I can see it being a problem when and if I want to print from an
SDcard in the future. do you know what the changes made where, in the
precompiled hex and the latest github source?

many thanks

Downunder35m (author)RobertS3192016-12-18

The only thing I can think of that is different is the definition for the display controller.
With the jog it is always a pain in the ...., you might need to change the stepping and sensitivity for it.
If i remember correct it is set to just 1 by default.
Increasing the steps to 2 or 4 might help to avoid unwanted clicks to register and make it work properly.

bparker2 (author)2016-11-27

Hi The link for the file download is taking me to filefactory and I cant get to the file.

smc653 (author)2016-11-10

Pretty much made it. Two problems remain.

1. How do I export raster objects along with vector inside of Inkscape? I want to vector cut things and fill in some of the area but it seems only to export the vector outline

2. The laser cutter pauses while igniting the laser, the dwell time isn't always the correct amount of delay and leaves holes in thin material. Is there somewhere to control this, even if only in the firmware?

Downunder35m (author)smc6532016-11-10

1. You need to define what you want to do through the layer name.
This goes for the power level, speed and if required the ppm setting.
If you only get a vector outline instead of an engraving then usually the image properties are wrong.
It works best to import the picture or bitmap into Inkscape instead of trying to create it within Inkscape - Inkscape works only with vectors by default ;)
2. What do you mean by that? I never encountered a pause unless the object in question is far too detailed, e.g. vector works with line lenghts below 1mm.

smc653 (author)Downunder35m2016-11-11

1. When I try to export rasters it gives me the following error:

"Unable to generate raster for object flowRoot4133 as it does not have an x-y coordinate associated."

Inkscape seems inconsistent in when it's willing to try to export things as raster (I likely don't understand some deciding parameter yet), but when it does it throws that error. Is there something you're doing to avoid this?

2. The effect is shown in the attached picture, you can see the circles it burns at the start or end of each path. I have limited experience with cnc subtractive machining, but it looks similar to the burn patterns I've seen during plasma cutter startup/shutoff. I couldn't find any controls on pause/dwell after laser ignition in Marlin (didn't look line by line though), so perhaps it's simply processing time after reception of each new gcode command.

Downunder35m (author)smc6532016-11-11

1. Use the currect Inkscape version, if that is not the case:
Convert your image to grayscale and then import it directly into an active layer that you want to use for engraving.
The error you see originates from Inkscapes inability to know what to do with un-defined sections of a project.

2. If you want to do vector work with stuff not created in Inkscape it pays off to have the things in a compatible file format that you can import.
How do you name the layer for these tasks and what is the original/work size of the object?
There is a tiny delay with extensive vector stuff, same when you import something that is really big and downsize it to a few cm.
The dragon that comes with the extension is a good example for this.
Once you go to about 10cm or smaller the fine details are killing the performance.

smc653 (author)Downunder35m2016-11-12

Which version of Inkscape? I went looking for version/bit-count information and couldn't find specifics.

Everything I'm talking about is created in Inkscape, I'm not importing anything, I'm building stuff in Inkscape and it's still doing this. And the vectors are extensive, the files are not complicated.

Downunder35m (author)smc6532016-11-12

Inkscape 0.91 should work fine.
One problem with Inkscape and designing there for laser work is that you need to mae sure your creations actually matching at the endpoints.
The next step would be to combine the paths before using the plugin to export it to the laser.
Otherwise you will end up with hundreds of single lines instead of a few objects.

smc653 (author)smc6532016-11-12

*not extensive.

Is there no way to edit posts?

timberwolfl made it! (author)2016-10-01

Great instructions. Vector cuts all work perfect. Next up for me is engraving.

Downunder35m (author)timberwolfl2016-10-01

Great and thanks for jumping in on it!
Hopefully more people will use your example to abandone the chinese crippleware :)

timberwolfl (author)Downunder35m2016-10-02

Yes sir, the Arduino and Incscape is so much better!

dale6998 (author)2016-08-16

Hey, I was wondering, I have the power supply that has the K+ and K- as mentioned in another comment. I can get the supply to fire when using the pot, of course, but the PWM seems to have no effect. Is there any trade-offs to consider by changing to a single input to drive the laser as opposed to one input for enable and one input for PWM? My suspicion is that this input feeds a comparator that is tied to a triangle wave on it's other input, and that's how it's controlling the power...By feeding a ready made PWM signal into the wiper pin, this makes no sense in that sort of topology.

What should I do? I see there's a #define to set the number of inputs to one, but I'm not sure if that's all there is to it or if there's more to the story than that.

Thanks! Great work!

Downunder35m (author)dale69982016-08-16

The power supply needs the "Laser ON" to actually activate the HV output.
The "Laser PWM" controls the actual power level.
That means if the power supply is for dual pin control then you can't switch it over to a single pin operation.
With the digital controller that mine had the PWM signal was always present as set on the display.
The testfire button was wired directly to the Laser ON pin.
So whatever value was set for the PWM was also used for the testfire.

dale6998 (author)Downunder35m2016-08-17

That sounds pretty good...I've wired the pot wiper back up to the pot wiper and left the PWM pin disconnected. Then I changed the #define LASER_CONTROL to 1. Now, I do see a variable output on the laser, but it's still very much linked to the bias set by the pot....this is probably less than ideal. What's your thoughts on bringing in a DAC with a PWM interface to stand between the wiper and the PWM output on the RAMPs board? I was thinking about something like the 2644F from Linear Tech. What do you think of that? I would have to change the duty cycle mapping in FW to get a reasonable voltage swing on the wiper terminal.

Downunder35m (author)dale69982016-08-17

Personally I don't see the point.
Apart from the testfire function in the menu it would be easier to program another pin on the board if a physical button is required.
Just set your prefered values and link them to the analogwrite outputs as used for the normal operation - or link it it to the menu function...

dale6998 (author)Downunder35m2016-08-17

So, you're saying to rewrite the FW to look at the PWM that's being asked for with whatever function it is that controls PWM and remap that to an onboard DAC on the Arduino? I'm into that, and that sounds like a good idea....do you have any hints for where to look in the code and what functions should be looked at/called to make the most sensible conversion? I guess what I'm asking is, where's the best place to feed a DAC function?

Downunder35m (author)dale69982016-08-17

No, I am saying to use a dedicated input pin on the Arduino for the same function that the test fire in the menu does.
I still fail to see why you think you need to add more hardware....

DeanSmithok (author)2016-08-11

Hi All

Does anyone know what each ribbon cable does?

https://goo.gl/photos/d1P6HMoJXNEp1vhf9

This is where the ribbon connects on a K40.

Regards

Dean

Downunder35m (author)DeanSmithok2016-08-11

Don't get me wrong, but it is quite obvious where they are connected to, wouldn't you agree? ;)

DeanSmithok (author)Downunder35m2016-08-12

Hi

I am asking what each wire in the ribbon is for. I can see in the image where it connects, but now I need to split it out on the new RAMPS board. So what each wire is for is now my next challenge.

Best regards

Downunder35m (author)DeanSmithok2016-08-12

Can't say as I don't have one in my machine but a simple multimeter will show - or simply count the traces...

DeanSmithok (author)2016-08-06

Hi

I have this board https://i.ytimg.com/vi/QM7SRyvqrSg/hqdefault.jpg

MKS Base V1.4 - based on Ramps 1.4

Please can you tell me where I would connect the Laser power. I cannot see D5 and D6 - please can you give me a quick pointer.

Regards

Downunder35m (author)DeanSmithok2016-08-06

I would not have a clue as I neither know the pinout of the board nor the real hardware configuration, sorry.

DeanSmithok (author)Downunder35m2016-08-07

Hi

Your code :

I have your latest hex compilation. But I am on linux, so can't use your upload program. Please could I have your latest code so that I can work it for my board.

Question to the manufacturer:

There is a D5 and D6, actually D5, D6, D7, D8 & D9, but they look like axis connectors. I can ask the manufacturers for help on the laser power, but please help me with the question to them...:: Should I ask to help me identify the connection to one of the axis controllers?

Best regards

Downunder35m (author)DeanSmithok2016-08-07

At this stage I am not too confident to release the source as I am
still working on improvements and some other nice people might actually
allow me to add their variations to get even more control of the 8bit
engravings.
Once all that is sorted I will certainly offer the surce to anyone willing to work on it.
In the meantime I give you the hint of Github ;)

The features like motor control, endstops, temperature or for out additions the laser stuff depend on the board configuration.
Even
if your board is RAMPS based it neither means it actually uses the same
inputs and outputs nor that you have access to the pins required for
the laser additions.
On the image it looks you only have what is
required for 3D printing but no pins, headers or similar for the
"unused" pins of the controller - which would be required.
The best I can offer to you would be to just invest in the RAMPS-Mega-Display deal and use it.
I
won't offer support for hardware I don't use, so if you want to use
different stuff you need to sort out the compatibility yourself sorry.

DeanSmithok (author)Downunder35m2016-08-08

Hi Downunder35m

Thanks for getting back to me.

I also understand now that the differences betyween the controller hardwares is that your controller has it's pins exposed and mine not. I can fix that :)

I am quite new to electronics but have been coding for 20+ years. So if you need any help with the code then I offer it.

I think I now got the question for the manufacturer how I connect to the
Arduino mega CPU pins D5 and D6 (as in digital) - Does that look right
to you?

Best regards

Downunder35m (author)DeanSmithok2016-08-08

I don't see a thing here...
But even if you get the two pins out somehow, you will miss the internal pullup resistors and once the other things come, like safety switches or a moving cutting table you will need even more pins....

DeanSmithok (author)Downunder35m2016-08-11

Hi downunder35m

I got in touch with the board manufacturer. The suggested I use the spare pwm pins of D11 and D12 ( instead of the D5 & D6 ) This would work great :)

All I need now is your code so that I can recompile it for these pins.....so will you release it in the near future, or will you keep this to yourself?

Best regards

Deansmithok

Downunder35m (author)DeanSmithok2016-08-11

That might be a great idea if you are programming your own code but not for an existing project of this kind.
The PWM signals depend on the timers and those are only available on specific pins.
Changing from 5,6 to 15,16 means you use timers that are not synced and prepared for this.
It will be a bit but the source code should be fully available within the next 3 months.

Downunder35m (author)2016-02-12

Little update on the firmware side of things:
I have been digging through the Marlin code, removed not needed things as far as I could, optimised the buffers and what else was required to get it running smooth.
However there is one fundamental flaw that ruins the results of true 8bit engravings.
This flaw is the massive power of a CO2 Laser!
With just 255 steps between zero and full power it might sound still ok but the truth is that on most materials we only use power levels between 8 to 15 for engraving purposes.
If you know how to calculate than you soon realise there is no way to fit 16 shades of grey in there, let alone 256...
My attempts to change the handling of the S values internally ended in a moderate disaster not only because of the coding but also because of the generated code itself.
With power levels changing pixel by pixel the buffers run full faster then Marlin can process them.
As a result the speed goes down in several areas - which of course totally alters how much burning the laser is doing.

Reluctantly I will now try to modify GRBL to run on the Mega2560 with increased buffer sizese (GRBL is meant for the UNO and it's limited capabilities).
Within GRBL it is quite simple to modify the code so S values between 0 and 10000 are used instead of 0-256.
This should allow for the selected power levels to still keep all shades of grey as they are.
Still the buffer problem for the commands itself is a problem as GRBL only uses 18 commands internally for the look ahead buffer and calculations.
So even with increased buffer sizes the code needs to be modified to allow for more commands to be processed - ideally enough for a single line of an image in 300DPI.
One major drawback of GRBL is the lack of display on control support.
The UNO can only handle so much and there is not enough room left for such gimmicks.
One way to overcome this problem would be to make the machine independend by using an Android tablet to serve as the host controller.
With a WiFi enabled tablet all g-codes can be processed on the computer and send over for lasering.
But not sure if that will still fit in my now pretty limited time.

The slightly changed roadmap for this project:
Instead of another Ible for the display and hardware mods, I will update this one with some extra steps for those that don't really need 8bit engraving.
The next Ible will instead cover the topic of using GRBL on the Mega and how to set everything up so it can run the laser cutter with standard g-code.

pauldg99 (author)Downunder35m2016-06-29

hi downunder35m you can install grbl on a mega. Version0.9 allows you to do so with just selecting the correct board. I have installed grl on an uno and wired it up to my k40. What setting do you use for steppers? I use drv8825's on 1/32 stepping. Haven't measured the travel yet so have used a rough setting of 350 steps per axis. Yet to connect the spindle to the laser enable and pwm.

MartinV67 (author)2016-05-01

Hi Downunder35m, thanks for this thread. I use the fw Marlin ( https://github.com/timschmidt/buildlog-lasercutter... on my DIY laser cutter. I´ve tried to use your fw, it installed ok but it didn´t work. I don´t know where the problem is.

In your video, the head moves smoothly and continuously. At my fw Marlin the movement is inconsistent and unfortunately, I can´t yet use pvm. I need to know how you´ve set the acceleration, jerk, and speed on your fw. My engravings are burnt through at the edges and kind of undone in the middle. Thanks a lot!!!

Downunder35m (author)MartinV672016-05-01

Don't get me wrong but I support my work and programs but not whatever else is out in the WWW.
"Didn't work" is no error- or problem description I know.
And the speed and engraving problems were the reason I started this project, so again I fail to see why I fix the firmware that other people supply.
Contact Tim Schmidt and I am sure he knows where the problem is.
If the wiring is done correctly there are only two things that might cause a slight problem with my firmware:
A) Power supplies with single pin control (can be quickly fixed in the firmware).
B) Laser refuses to fire because someone flipped the laser pins, either while wiring or on the power supply itself - simply flipping them on the right pins fixes that.

Downunder35m (author)2016-04-30

Thanks to HakanBastedt we know have a working DPI selection for the Inkscape plugin.
This means you can select at what resolution your image will be rastered.
254DPI is the default, which corresponds to 0.1mm pulses and line widths.
508DPI would equal to 0.05mm, which is already a bit over the limit for CO2 systems but well within the capabilities of a good diode laser of the lower wavelenght.

Downunder35m (author)2016-04-27

Seems I am getting into the final stages with the firmware.
Engravings works now reliable at 7200mm/min, the result can be seen in the last step of the Ible.
Will update the Github files later this day so everyone who tried already can benefit from the latest changes.

Downunder35m (author)2016-04-25

I thought it is time for a little Update although I already know it will end up in the totally wrong order here.

So far progress was really good.
With some tweaks and a reduced motor stepping I can now engrave at up to 6000mm/min if the edges are covered to prevent pinholes burns during the line changes.
For up to 4200mm/min all works just fine, which is enough speed for most engraving jobs anyway.
I might do some test in regard to using smaller base64 segments to prevent buffering problems at higher speeds but currently I am doing the last tweaks on the Inkscape plugin.
My aim here is to optimise the raster resolution from the current 270DPI to the real DPI possible with this machine.
This should prevent any tiny gaps between lines or total data overload when going too high.
508DPI here is a really good value for diode lasers which can produce a much smaller focal point than CO2 lasers (if good optics are used).
Since their speed is much slower anyway the added data to get this resolution should not affect the movements or buffers.
The current 270DPI result in about 10.6 pixel or pulses per mm.
If we consider a spot size of 0.2mm as good for these cheap chinese machines than the theoretical resolution would be just 127DPI.
This goes along with the kerf of between 0.15 to 0.18mm when cutting.
However, during engravings we move very fast compared to cutting so only the area of the spot that is producing enough energy to actually burn the material is of use.
For higher speeds it will be smaller and for lower speeds bigger.
Right now it looks like the sweet spot @ around 4000mm/min is at around 400DPI.
It should be possible to adjust the focal height in small increments or to find the right speed to get a spot size that works well with standard image DPI values.
After all there is little point to blow a 300DPI image up for a 600DPI engraving or to loose a lot of possible detail on a 600DPI image being engraved at just 270DPI.

A constantly changing speed as used by other engraving programs out there might work for the low power diode laser that move quite slow to begin with.
But for the power levels of a CO2 laser it would require extensive studies and logging on a lot of materials to create a table with engraving values that give proper results.
The constant speed approach with changing laser power levels makes much more sense here considering the higher overall speeds.
Recent developments in diode laser allow now for reasonable low prices for laser diodes with quite short wavelengths.
As shorter wavelengths allow for much smaller focal points the energy density is far greater compared to a CO2 laser of the samer power.
It might not be too much longer and we can see affordable diode laser systems that allow for both good speeds and high cutting power due to the higher energy density.
Right now it is more a matter of money and how much you want to build on your own.
The cost for a good laser diode including driver and optics for the lower blue range is about the same as for a complete CO2 cutter from china with an added controller.
I guess what we really need is more people building their own laser cutters and engravers to get costs down by volume.
Also of course more Instructables about the machines and modifications you made ;)

Downunder35m (author)2016-02-02

I just noticed that I did not include any screenshot in regards to the plugin use in Inkscape, that will be rectified by the next weekend - sorry for the miss.

Currently I am experimenting with different plugins for picture engraving as I want to avoid using commercial software for this project.
The Turnkey plugin is great but lacks the ability to engrave images with the power levels based on the pixel brightness.
The results of engraving a good bitmap are still impressive but there is room for improvement.
Sadly my Python skills are a bit rusty to say it nicely so I will have to seek some outside help to make these modifications.

As an alternative there is still the GRBL route including different plugins, software and so on.
But the problem is basically the same as there is (not yet) any single solution that offers proper bed setup, easy vector works and proper photo engraving from within one program.
So until the next step of the harware mods I will still to Marlin and the listed plugins.
Later on I might also offer links to other alternatives and the steps to get them running with the Arduino board.

If anyone with interest in this project speaks fluent Python I would really welcome some help with the plugins. (hint! ;) )

About This Instructable

26,367views

181favorites

License:

Bio: I like to improve myself and things I find :) Learning new things every day is next to impossible but I still try - only a working ... More »
More by Downunder35m:X96 (S905x) Android TV Box - Updating the Firmware and Costom RomsThe Paracord Stubbie HolderMy Little Paracord Splicing Guide
Add instructable to: