354,833 Registered Members
Welcome to the CNC-Arena Forum
Results 1 to 9 of 9
  1. #1

    Join Date
    Jan 2008
    Posts
    447

    LinuxCNC laser control (or why you don't need a DSP)

    I've just in the process of finishing a DIY large format (~1200mmx700mm) CO2 laser cutter and wanted to share my control system.

    It's commonly said you need a DSP (costs ~$500) to be able to both vector cut and engrave in the same file, and is considered nearly essential by many for a usable laser. But thanks to some great work by some people over at buildlog.net, that is far from true.

    bjj (Ben Jackson) developed a linuxcnc component + configuration that allows software PPI. His code is available on github
    jv4779 (Jeremy Van Grinsven) built on Ben's work adding a 'duty cycle' mode in addition, as well as a simple control panel with useful information (such as power level) and control such as go to origin and set origin. His code is available on github
    Their work is built on work by others, whom they credit in their github pages.

    In to the details:
    I'm using:
    40W glass laser + analog power supply taken from a cheap K40 laser, which came with Moshidraw.
    TB6560 red 3 axis stepper driver board (~$40 shipped from ebay) Manual
    12V 180W PSU
    Aluminium extrusion frame - my own design.

    Set up LinuxCNC
    Easily done via the LiveCD.
    Stick it in a computer, boot up and install.
    Other guides cover this, so I won't. But it is very simple.

    Basic settings
    Use Stepconf wizard to get your machine moving.
    Set the pins.
    Test movement and velocity and acceleration.
    For a laser you'll want very high acceleration.
    Find the maximum settings before your steppers stall and then scale back ~30%

    Laser firing
    The bjj and jv4779 configs allow a few methods to fire the laser.

    The simplest is 'magic Z' in which the laser is turned on when the Z axis is negative, and turned off when it goes positive.
    This has the advantage of working with any CAM program without modification of a post processor.
    Simply set a very small Z move (e.g. Z0.01 to Z-0.01) at a very high velocity (this is to avoid any pause as the machine thinks the Z axis is moving).

    There is also the option to trigger via a digital out. This would require modification of a post processor for in most CAM software.
    Bart of buildlog.net fame has done exactly that for Vectric products and covers it in a guide: Creating A Laser Post Processor at Buildlog.Net Blog

    To control the laser with the TB6560 board and other breakout boards that don't actually break out all the parallel outputs you'll need to do a quick bit of soldering.
    I soldered a wire on to pin 8 of the parallel port on the TB6560, and a wire on to a ground pin of the port. I connected the wires to J4 (red wires) on my powersupply (which was originally hooked up to a head marked laser and ground on the Moshidraw board). The test button goes on to the other pins of J4.
    I also soldered a spare on to pin 9 for any future output needs (as the 3 axis board only uses 6 output pins for motors, and 1 for relay control)

    I've hooked up the 240V supply for the laser power supply to the relay on the TB6560, so that the laser cannot fire when I'm not expecting it to, for example if an estop is triggered.
    The relay stays open for a number of seconds specified in the .ini - this is great for hooking up air assist or exhaust. I've got air assist (90L/min aquarium air pump) hooked up that turns on at the start of a job and turns off 10 seconds after lasering is done.

    Laser power control
    This is the real magic part of the bjj and jv4779 configs. They allow software control of power level, even using an analog power supply (non-pwm).

    bjj has implemented 'PPI' - it's actually done in pulses per millimeter (ppmm), which means you'll use values ~1/25th quoted for PPI.
    This is triggered by M3 Sxx, where M3 is the gcode for spindle on clockwise and Sxx is the pulses per mm. S10 is 10 ppmm, S100 is 100ppmm. Over a certain number of pulses per mm you'll get continuous cutting (depends on the minimum firing time of your laser, which seems to be around 3ms, as well as feedrate).
    M3 also turns the relay on, so without M3 code active the laser can't fire. This also means that the laser can't fire if M5 (stop spindle) is called in the gcode, or if M3 S0 is present.
    PPMM/PPI differs from conventional laser firing in that cutting power is not determined by 'power / speed' where slower = deeper cut. The laser is pulsed precisely based on distance, so that in fact running faster results in more power delivered to the material in a given time frame. This means adjusting settings is not a simple linear thing.

    jv4779 has expanded on bjj's configs by adding duty cycle.
    M3 is ppmm (PPI mode) and behaves the exact same.
    M4 (gcode for spindle counter-clockwise) is duty cycle mode which he talks about in the buildlog forum
    Duty cycle is a bit easier to adjust because it is simpler relationship. To cut deep at the same power, just slow down the feedrate.

    Integrating the configs
    Once you have a basic linuxcnc config tested, with appropriate pin outs, and axis velocities etc, you'll need to edit those values in to bjj or jv_4779 config.
    This requires some editing of the .hal file and the .ini.
    In the .hal you'll need to replace the pins and whatever limit / home switches you've set

    For the above TB6560 board my pins are:
    Code:
    net xstep => parport.0.pin-02-out
    setp parport.0.pin-02-out-reset 1
    setp parport.0.pin-03-out-invert 1
    net xdir => parport.0.pin-03-out
    net ystep => parport.0.pin-04-out
    setp parport.0.pin-04-out-reset 1
    setp parport.0.pin-05-out-invert 1
    net ydir => parport.0.pin-05-out
    #net zstep => parport.0.pin-08-out
    net laser-final => parport.0.pin-08-out
    setp parport.0.pin-08-out-reset 1
    net zdir => parport.0.pin-09-out
    setp parport.0.pin-14-out-invert 1
    #net spindle-on => parport.0.pin-14-out
    net laser-exhaust => parport.0.pin-14-out
    net min-home-x <= parport.0.pin-10-in
    net max-home-y <= parport.0.pin-11-in
    Note I've commented out zstep and replaced it with 'net laser-final' (the hal pin that fires in the laser).
    Spindle-on is with 'net laser-exhaust' which controls the relay and leaves the relay on for the number of seconds specified in the .ini file. This is handy for air assist, which I keep on for 10 seconds after laser has turned off.

    In the .ini file you'll need to put in the appropriate values for your machine in the axis settings, as well as edit the paths to a couple of files.

    Raster engraving
    Both bjj and jv_4779 have implemented raster engraving features.
    I haven't tried either yet.

    The simple way to do raster engraving, that allows engraving (raster) and cutting vector) in the same file is to do the raster in CAM. Generate a pocket operation using the kerf of the laser as the tool diameter, with appropriate power settings.

    Workflow
    Drawing -> CAM -> LinuxCNC
    I'm using Vectric Aspire mainly, which has adequate drawing tools. Sometimes I'll use Solidworks (as I love relationship / dimension based drawing - if there is a good cheap 2D drawing program that works like this I'd like to know).
    Once I've got the vectors in Aspire I start generating toolpaths.

    I've set up a few 'tools' that are the laser with different settings. E.g.:
    'Laser Cardstock Cut' with tool diameter 0.3mm, spindle speed 15 (= M3 S15 in gcode = 15ppmm)
    'Laser Cardstock Score' with tool diameter 0.3mm, spindle speed 3 (= M3 S2 in gcode = 3ppmm)

    I haven't worked out how to choose M3 or M4 (ppm vs duty cycle) in Aspire - there doesn't seem to be a way to choose spindle direction. So at present I quickly hand edit / replace M3 with M4 if desired.

    Conclusion
    While the above requires a bit of editing some config files, it doesn't require in depth coding (others have kindly done the work!).
    I managed to get my laser going with minimal fuss, in a couple of hours.
    I've only done this recently, so there is a lot more fiddling to be done. But I'm impressed at being able to take a K40 laser, add a $40 stepper controller and now have a system that blows Moshidraw out of the water and allows software control of laser power.
    Much cheaper than a DSP.

    Please post any questions / comments. I'll aim to add some pictures at some point.

  2. #2

    Join Date
    Nov 2008
    Posts
    111
    Good stuff. Had a similar discussion a couple weeks back about alternatives to DSP. From a cost perspective you've taken it to a new level. I like the setup except for the use of the LPT port. Do you think this can be done with a USB controller?

  3. #3

    Join Date
    Jan 2008
    Posts
    447
    Dean,

    LinuxCNC doesn't really deal with USB controllers. The argument is that USB creates a whole host of issues due to timing and addresses. Worth noting the SmoothStepper has now moved to ethernet. Parallel port cards can be bought for $10 shipped on ebay.
    You can get a hardware (FPGA based) step generation solution (this is what the Smoothstepper is) from Mesanet for $89 that is compatible with parallel port breakout boards / controllers. It's called the 5I25 and has two parallel ports, therefore 34 IO if paired with standard PPT devices. Or you can add their 7I76 breakout board, which is a 5 axis step/dir board with 32 inputs and 16 outputs, plus spindle control! (The combo will set you back $200, the same price as a Smoothstepper).
    I've not tried these cards, because I find the parallel port fine. Ben Jackson (bjj) had posted that he was working on PPI laser control with one of these cards, I'm not sure where he got up to.

  4. #4

    Join Date
    Sep 2012
    Posts
    1317
    Crap... Says the guy that just bought a whole dsp setup...

  5. #5
    Registered
    Join Date
    Apr 2013
    Location
    italy
    Posts
    0
    Great review Pippin, thank you for sharing!
    How about Graster solution?
    LinuxCNC Documentation Wiki: Rastering With A Laser
    Which is the main difference with the Ben's raster method?

  6. #6

    Join Date
    Sep 2012
    Posts
    1317
    Oh, my DSP is operational and WAY better than stock. I'm happy!

  7. #7

    Join Date
    Jan 2008
    Posts
    447
    Quote Originally Posted by nasopwr View Post
    Great review Pippin, thank you for sharing!
    How about Graster solution?
    LinuxCNC Documentation Wiki: Rastering With A Laser
    Which is the main difference with the Ben's raster method?
    I haven't had a chance to try rastering yet. My laser build is stalled until I get my 3D printer going (nearly done but having power supply issues...).
    It looks like Ben and Jeremy's solutions should be a bit easier to get going.

  8. #8

    Join Date
    Apr 2011
    Posts
    0
    Hello. I'm coming to the end of my wits. I have a Blacktooh Laser from BuildYourCNC.Com using a fairly straightforward parallel break out board. I've been trying to add the PPI/Duty cycle mod and I've found that I have to keep commenting things out of the ini and hal files to get it to load.

    It is set up to use the relay on the mist to act as a failsafe and control the over all flow of power as outlined here: blackTooth DIY Laser Cutter Engraver Assembly from buildyourcnc.com: Mach 3 Configuration Settings

    I used the Ubuntu 10.04 Live CD that is pre-configured with LinuxCNC for control, and I'm using Inkscape and the GcodeTools extension as a cam. I have four end stops (xmin/home, xmax, ymin/home, ymax) as well. My pins are set like so:
    Attachment 207888
    Attachment 207890

    I set up a test cgode to use the M4 with a couple different S values (15, 50, 75, 100). When I finally get LinuxCNC running, I have the modified GUI with the power indicators. My Duty Cycle/PPI bar reads the correct value, but the power level reads 0 even when firing, and on my ammeter I have seen no variation in milliamp measured.

    If I don't comment out anything in the combined 2X-laser.ini file, I get the follow errors on load:
    Debug file information:
    Can not find -sec MOT -var MOT -num 1
    Can not find -sec IO -var IO -num 1
    Can not find -sec LINUXCNC -var NML_FILE -num 1
    HAL: ERROR: thread 'charge-pump-thread' not found
    2x_Laser.hal:34: addf failed
    5941
    PID TTY STAT TIME COMMAND
    Stopping realtime threads
    Unloading hal components

    If I comment out 'addf charge-pump charge-pump-thread' I get:
    Debug file information:
    Can not find -sec MOT -var MOT -num 1
    Can not find -sec IO -var IO -num 1
    Can not find -sec LINUXCNC -var NML_FILE -num 1
    2x_Laser.hal:160: Signal 'zpos-fb' can not add OUT pin 'axis.2.joint-pos-fb', it already has OUT pin 'stepgen.2.position-fb'
    6190
    PID TTY STAT TIME COMMAND
    Stopping realtime threads
    Unloading hal components

    If I comment out 'net zpos-fb <= axis.2.joint-pos-fb => laser-magic-z-comp.in0' it will load, and like mentioned above, I'll get the DC/PPI indicator showing the right level, but there won't be any variations in power level on the actual lazing.

    I have two settings currently: LaserBox (which I configured using the stepconf wizard, and 2X-Laser which is the modified files from the repository that I tried to follow the instructions and copy my axis and pin settings into.

    If anyone has an idea and/or could take a peak at my conf files, I would appreciate it. I've included the complete folders from the two configurations, as well as my header and footer files for InkScape, and also the sample gcode I've been trying to use.

    This is all compounded by trying to learn Linux at the same time. :/

  9. #9

    Join Date
    Jan 2008
    Posts
    447
    Hardwyre, sorry for slow reply, I've been on night shift. I'll have a look over the next few days.

    To clarify: are you able to get LinuxCNC to turn on and off the laser?
    Is the problem lack of power control or the laser is not controlled by LinuxCNC at all?

    I had a quick look:
    You have commented out "loadrt threads name1=base-thread period1=[EMCMOT]BASE_PERIOD fp1=0 name2=charge-pump-thread period2=100000 fp2=0"
    This is why you get the "HAL: ERROR: thread 'charge-pump-thread' not found" (I think, not in shed to quickly test)
    Try uncommenting that line, I suspect that may solve your issue.

Similar Threads

  1. Another G0704 conversion - Hoss's plans - LinuxCNC control
    By otto_pjm in forum Benchtop Machines
    Replies: 9
    Last Post: 11-14-2013, 06:26 PM
  2. LinuxCNC vs Your favorite control!
    By tjamscad in forum General CNC (Mill / Lathe) Control Software (NC)
    Replies: 0
    Last Post: 02-19-2013, 09:01 PM
  3. LinuxCNC laser cutters and gcode generation
    By fishface in forum General Laser Engraving / Cutting Machine Discussion
    Replies: 1
    Last Post: 10-24-2012, 12:25 AM
  4. LinuxCNC + USB breakout control
    By DiaLFonZo in forum LinuxCNC (formerly EMC2)
    Replies: 5
    Last Post: 10-01-2012, 04:15 PM
  5. Replies: 0
    Last Post: 10-16-2007, 04:46 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Advertising