Hello Guest it is April 18, 2024, 05:22:01 PM

Author Topic: Add a laser to my CNC  (Read 17654 times)

0 Members and 1 Guest are viewing this topic.

Offline Pedio

*
  •  200 200
    • View Profile
Re: Add a laser to my CNC
« Reply #30 on: February 14, 2016, 12:33:30 PM »
The spindle (laser) on worked fine. I tried setting the power to 0 to turn off the laser but that did not work. The spindle CW button on the normal wxMach screen toggles the spindle on and off so this will work for my laser off.

Oops - spoke too soon. The code to position the laser works to turn on the laser at a very low power; however, after I use the code to position the laser the laser power stays at that level when I run the G code file. Even if I reload the G code file the laser stays at the lower level of the test. I have to restart Mach to get the laser power back to normal.

Offline Pedio

*
  •  200 200
    • View Profile
Re: Add a laser to my CNC
« Reply #31 on: February 14, 2016, 01:44:44 PM »
Bob - I added this code to the Spindle CW button and it seems to work.

local inst = mc.mcGetInstance();
local sigh = mc.mcSignalGetHandle(inst, mc.OSIG_SPINDLEON);
local sigState = mc.mcSignalGetState(sigh);

if (sigState == 1) then
    mc.mcSpindleSetDirection(inst, 0);
else
    mc.mcSpindleSetDirection(inst, 1);
    local rpm = 100;    -- Set this to the actual RPM you want as your starting point
    mc.mcSpindleSetCommandRPM( inst, rpm );
    mc.mcSpindleSetDirection( inst, 1 );    -- 1 == forward, 0 == off, -1 == reverse

end

Offline Pedio

*
  •  200 200
    • View Profile
Re: Add a laser to my CNC
« Reply #32 on: February 14, 2016, 02:48:28 PM »
Bob - I added this code to the Spindle CW button and it seems to work.

local inst = mc.mcGetInstance();
local sigh = mc.mcSignalGetHandle(inst, mc.OSIG_SPINDLEON);
local sigState = mc.mcSignalGetState(sigh);

if (sigState == 1) then
    mc.mcSpindleSetDirection(inst, 0);
else
    mc.mcSpindleSetDirection(inst, 1);
    local rpm = 100;    -- Set this to the actual RPM you want as your starting point
    mc.mcSpindleSetCommandRPM( inst, rpm );
    mc.mcSpindleSetDirection( inst, 1 );    -- 1 == forward, 0 == off, -1 == reverse

end
Nope still does not work. The laser will stay at a lower power. Hmmmmmmm????
Re: Add a laser to my CNC
« Reply #33 on: February 14, 2016, 10:32:03 PM »
First - you have two calls to mc.mcSpindleSetDirection( inst, 1 ) in you code.  You only need one.  The second shouldn't cause any problems, but is not needed and for the sake of code clarity should be removed.

Second - *IF* you want a spindle RPM of "100" to be the maximum intensity, then you need to edit the spindle RPM range to be from 0 to 100.  Go to the Mach4 "configure" menu and select "Mach...".  Then click on the "Spindle" tab.  In the first row, marked "0", make sure the MinRPM is zero and the MaxRPM is 100 (or whatever RPM you want to correspond to the maximum laser intensity).  If your mc.mcSpindleSetCommandRPM() call sets the RPM to the maximum value, then the SRO slider should NOT be able to make it brighter.  It should be able to make it dimmer.

Third - the documentation for your laser's PWM input (that I found at the link you poster earlier) says that the PWM input will control the laser intensity from 15% to 100%.  That implies (to me) that the lowest power setting attainable via PWM control is 15% of max brightness.  Outputting 0% PWM apparently *still* gives you 15% brightness.  So you need some other control to turn the laser off.

Are you using any other signal to control the laser on/off?  Or are you only using the PWM signal on Pin16?

Regarding the EStop not turning off the spindle/laser - when you say "the LED is on when estop is pressed", do you mean when you press an external EStop button (that is wired into the EStop input on the PMDX-132)?  Or do you mean when you click the "Disable" button in the lower left corner of the Mach4 screen?

Finally - please generate a Mach4 profile package (go to Mach4 "Help" and select "Support" and then "Package Current Profile").  Save the file somewhere that you can find it and then either email it to me at bob at this domain, or upload it here.  In order to upload the profile package, you will need to either (a) change the file extension from ".m4prof" to something like ".zip", or zip the profile package into a zip file.  This will hopefully make it so I don't have to keep asking questions about your configuration.

Bob

Offline Tweakie.CNC

*
  • *
  •  9,198 9,198
  • Super Kitty
    • View Profile
Re: Add a laser to my CNC
« Reply #34 on: February 15, 2016, 01:44:27 AM »
Quote
Nope still does not work. The laser will stay at a lower power. Hmmmmmmm?


Pedio,

It is still very early days with Mach4 and the development of motion controllers and although it may some while into the future, one day, I expect they will all support the M62/M63 commands.
From your testing it is apparent that you cannot switch your laser beam on/off by using the PWM signal so why not just use an imaginary axis direction signal as mentioned and demonstrated here…  http://www.machsupport.com/forum/index.php/topic,31495.msg218362.html#msg218362

Tweakie.
PEACE
Re: Add a laser to my CNC
« Reply #35 on: February 15, 2016, 02:47:48 AM »
From your testing it is apparent that you cannot switch your laser beam on/off by using the PWM signal so why not just use an imaginary axis direction signal as mentioned and demonstrated here…  http://www.machsupport.com/forum/index.php/topic,31495.msg218362.html#msg218362
The danger in using an otherwise unused motor "direction" signal to turn the laser on and off is that EStop will NOT necessarily turn off the laser.  EStop halts motion but does not return any motor "direction" signal to a per-determined, known state.  Certainly not on the SmartBOB boards, and I'd bet coffee money not on any other motion controller device.

Bob

Offline Tweakie.CNC

*
  • *
  •  9,198 9,198
  • Super Kitty
    • View Profile
Re: Add a laser to my CNC
« Reply #36 on: February 15, 2016, 04:50:25 AM »
Hi Bob,

Perhaps all the more reason for motion controller developers to support the M62/M63 commands ??

In my case (as shown in the linked video) I am combining the A axis direction signal (a modified logic AND) with the PWM on an Output# (as a laser power control method this is described in a bit more detail in my Laser thread). As a result Estop turns off the Output# and also the laser (the A axis direction signal is not passed through without the Output# being active). I appreciate that not everyone would want to use this method but it is just one way of achieving the desired result when I only had limited tools available.

Tweakie.

(I had to check a few things for accuracy so this post was deleted, corrected, then re-posted)
PEACE
Re: Add a laser to my CNC
« Reply #37 on: February 15, 2016, 06:35:12 PM »
E-stop should cut power to the laser via a relay or hardwire the laser power thru the estop switch, not rely on the motion controller.

Mike
We never have the time or money to do it right the first time, but we somehow manage to do it twice and then spend the money to get it right.

Offline Pedio

*
  •  200 200
    • View Profile
Re: Add a laser to my CNC
« Reply #38 on: February 15, 2016, 09:10:46 PM »
Gang - I added the laser to the spindle control because it was much easier for me to change my post processor for the CAD program (Vcarve Pro). My theory was that I could set up tools to use different feeds and speeds to handle different levels of laser. What I actually found is it was easier to leave the laser (3W) on full power all of the time and vary the feed rate or the depth (number of passes) to get the level of darkness I desired. Also, I have used the offset tool to make the lines thicker. I can add shadowing with offset and depth of cut (number of passes). The spindle control works very well. Not sure how I would use the A axis with my CAD program (Note - I tend to over think things).

The only problem I am having now are
  • The laser does not always turn off with the disable button. I know there has been a lot of talk about eStop button. My laser is controlled with a toggle switch to switch it on and off. I turn on the laser power and then the PWM controls the power. I have this wired to a mushroom button; however, sometimes I use the disable button on Mach 4 and the laser is still on. PMDX is working on this. They are great guys and will figure it out.
  • I am still having problems with controlling the laser at low power. When I use the script it seems to stay at low power even when I run a script. I think this is a post processor problem. I plan to look at it the next time I am at the CNC. Also, I think I can add to the script to turn off the laser to add a line to return it to full power. Will post what I find.
  • I am still having problems with Mach 4 freezing at spindle controls. Not every time but it can really mess up a work piece.
  • The feed rate is 7 (Inch per minute) and I have to go over the same line at least twice (leather and cutting boards). It is slow but it works.

Here is a leather jacket I made today. Really amazing what you can get for $5 at GoodWill and turn into a $*********+ jacket!!! Speed 7 in/min, three passes, and 3 W laser at 100%.
Re: Add a laser to my CNC
« Reply #39 on: February 16, 2016, 05:47:09 AM »
Nice work with a 3W laser.

Mike
We never have the time or money to do it right the first time, but we somehow manage to do it twice and then spend the money to get it right.