Hello Guest it is January 19, 2020, 12:06:05 PM

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

0 Members and 1 Guest are viewing this topic.

Offline Pedio

*
  •  200 200
    • View Profile
Re: Add a laser to my CNC
« Reply #20 on: February 03, 2016, 08:18:53 PM »
Got to play with the laser a little more today. The spindle start on each feed move was causing the toolpaths to be a little jerky. I replaced these with a laser on for a plunge and a laser off for a retract. I have changed my machine to exact stop instead of constant velocity. I plan on playing with this a little more in the next few days.

I still can't figure out how to turn off the laser on an eStop. Also, I tried making a button to turn on the spindle but did not get it to work. Any suggestions?

Here is the post processor code I am currently using. Will let you know how it goes.

Code: [Select]
+================================================
+                                               
+ Mach2/3 - Vectric machine output configuration file   
+                                               
+================================================
+                                               
+ History                                       
+                                               
+ Who      When       What                         
+ ======== ========== ===========================
+ Tony     15/11/2005 Written
+ Tony     06/01/2006 Added ATC option   
+ Tony     14/05/2006 Fixed G20 inch in header   
+ Tony     24/07/2006 Added G2 & G3 Arc support + removed (( ))
+ Tony     18/06/2007 Replaced the Tool comment       
+ Mark     14/08/2008 Added G1 to Feed moves, added New_Segment
+                     Removed 2nd G20 in header.
+ Mark     28/08/2009 Added G91.1 to force use of incremental arcs
+                     Added Substitution, File & Toolpath Notes.
+ Mark     30/11/2009 Added TOOLPATHS_OUTPUT.
+ Brian    15/12/2009 Remove M05 from NEW_SEGMENT
+ Mark     18/01/2014 Added Dwell
+Peter     2/1/16     Converted to Laser
+Peter     2/3/16     Used plunge and retract commands instead of spindle start on each move to avoid jerkey moves
+================================================

POST_NAME = "Mach Laser Arcs (inch) (*.txt)"

FILE_EXTENSION = "txt"

UNITS = "inches"

DIRECT_OUTPUT = "Mach|Mach4.Document"

SUBSTITUTE = "({)}"

+------------------------------------------------
+    Line terminating characters                 
+------------------------------------------------

LINE_ENDING = "[13][10]"

+------------------------------------------------
+    Block numbering                             
+------------------------------------------------

LINE_NUMBER_START     = 0
LINE_NUMBER_INCREMENT = 10
LINE_NUMBER_MAXIMUM = 999999

+================================================
+                                               
+    Formating for variables                     
+                                               
+================================================

VAR LINE_NUMBER = [N|A|N|1.0]
VAR SPINDLE_SPEED = [S|A|S|1.0]
VAR FEED_RATE = [F|C|F|1.1]
VAR X_POSITION = [X|A|X|1.4]
VAR Y_POSITION = [Y|A|Y|1.4]
VAR Z_POSITION = [Z|A|Z|1.4]
VAR ARC_CENTRE_I_INC_POSITION = [I|A|I|1.4]
VAR ARC_CENTRE_J_INC_POSITION = [J|A|J|1.4]
VAR X_HOME_POSITION = [XH|A|X|1.4]
VAR Y_HOME_POSITION = [YH|A|Y|1.4]
VAR Z_HOME_POSITION = [ZH|A|Z|1.4]
VAR SAFE_Z_HEIGHT = [SAFEZ|A|Z|1.4]
VAR DWELL_TIME = [DWELL|A|P|1.2]
+================================================
+                                               
+    Block definitions for toolpath output       
+                                               
+================================================

+---------------------------------------------------
+  Commands output at the start of the file
+---------------------------------------------------

begin HEADER
"[N]M05"
"( [TP_FILENAME] )"
"( File created: [DATE] - [TIME])"
"( for Mach2/3 from Vectric )"
"( Material Size)"
"( X= [XLENGTH], Y= [YLENGTH], Z= [ZLENGTH])"
"([FILE_NOTES])"
"(Toolpaths used in this file:)"
"([TOOLPATHS_OUTPUT])"
"(Tools used in this file: )"
"([TOOLS_USED])"
"[N]G00G20G17G90G40G49G80"
"[N]G70G91.1"
"[N] (Tool: [TOOLNAME])"
"[N](Toolpath:- [TOOLPATH_NAME])"
"[N]([TOOLPATH_NOTES])"
"[N]G94"
"[N][XH][YH][F]"

+---------------------------------------------------
+  Commands output for rapid moves
+---------------------------------------------------

begin RAPID_MOVE

"[N]M05"
"[N]G00[X][Y]"


+---------------------------------------------------
+  Commands output for the first feed rate move
+---------------------------------------------------

begin FIRST_FEED_MOVE

"[N]G1[X][Y][F]"


+---------------------------------------------------
+  Commands output for feed rate moves
+---------------------------------------------------

begin FEED_MOVE

"[N]G1[X][Y]"

+---------------------------------------------------
+  Commands output for the first clockwise arc move
+---------------------------------------------------

begin FIRST_CW_ARC_MOVE

"[N]G2[X][Y][I][J][F]"

+---------------------------------------------------
+  Commands output for clockwise arc  move
+---------------------------------------------------

begin CW_ARC_MOVE

"[N]G2[X][Y][I][J]"

+---------------------------------------------------
+  Commands output for the first counterclockwise arc move
+---------------------------------------------------

begin FIRST_CCW_ARC_MOVE

"[N]G3[X][Y][I][J][F]"

+---------------------------------------------------
+  Commands output for counterclockwise arc  move
+---------------------------------------------------

begin CCW_ARC_MOVE

"[N]G3[X][Y][I][J]"


+---------------------------------------------------
+  Commands output for a new segment - toolpath
+  with same toolnumber but maybe different feedrates
+---------------------------------------------------

begin NEW_SEGMENT

"([TOOLPATH_NAME])"
"([TOOLPATH_NOTES])"

+ ---------------------------------------------------
+  Commands output for Retract Moves
+ ---------------------------------------------------
begin PLUNGE_MOVE

"[N][S]M03"

+ ---------------------------------------------------
+  Commands output for Retract Moves
+ ---------------------------------------------------
begin RETRACT_MOVE

"[N]M05"

+---------------------------------------------
+  Commands output for a dwell move
+---------------------------------------------

begin DWELL_MOVE

"[N]G04 [DWELL]"

+---------------------------------------------------
+  Commands output at the end of the file
+---------------------------------------------------

begin FOOTER

"[N]M05"
"[N]G00[ZH]"
"[N]G00[XH][YH]"
"[N]M09"
"[N]M30"
%



Offline Pedio

*
  •  200 200
    • View Profile
Re: Add a laser to my CNC
« Reply #21 on: February 11, 2016, 04:18:29 PM »
I found out what was going on with the manual spindle control of the laser. If you set the spindle too high the laser does not see the PWM signal. The slider bar for spindle is defaulted 0-250%. Not sure why it goes that high? I changed this to 0-100%

Re: Add a laser to my CNC
« Reply #22 on: February 11, 2016, 09:01:19 PM »
I found out what was going on with the manual spindle control of the laser. If you set the spindle too high the laser does not see the PWM signal. The slider bar for spindle is defaulted 0-250%. Not sure why it goes that high? I changed this to 0-100%
Are you sure that the slider wasn't the "spindle speed override" and not plain "spindle speed".  Specially since it is marked in percent.  In the wxMach screen set, the slider in the "Spindle" group is marked "SRO%" and the values go from 1 to 250.  In the wx4 screen set, the slider in the spindle group is marked "SRO" and goes from 50% to 150%.  Those take the currently commanded spindle speed and increase it or decrease it by a percentage.

Offline Pedio

*
  •  200 200
    • View Profile
Re: Add a laser to my CNC
« Reply #23 on: February 11, 2016, 10:27:37 PM »
I am using the wxMach screenset as the basis for my screen set.

So what does the SRO% represent when you don't have a g code file loaded. I use this slider and the Spindle CW button to turn on my laser so I can focus it to the right level.

Also, when I hit eStop the laser will stay on (it looks like a lower output) is there anyway I can turn off the laser (spindle) on an eStop?
Re: Add a laser to my CNC
« Reply #24 on: February 12, 2016, 12:14:31 PM »
So what does the SRO% represent when you don't have a g code file loaded. I use this slider and the Spindle CW button to turn on my laser so I can focus it to the right level.
SRO is "spindle rate override" and changes the spindle speed to the given PERCENTAGE of the currently commanded spindle speed.  For example, with SRO = 100%, enter 1000 as the spindle RPM (presuming that is a valid RPM for you setup).  The spindle should turn at 1000 RPM, or in your case the PWM should reflect a duty cycle of ((commanded RPM) / (maximum RPM)) * 100.  Now if you slide the SRO slider up to 150%, the actual spindle speed will change to (1000 * 150%) = 1500 RPM.  The "commanded" spindle speed is still 1000 RPM.

So I am presuming that you set *some* non-zero spindle speed ("S" command) before you try sliding the SRO slider.  Because if the current spindle speed is zero, the SRO slider shouldn't change anything until a non-zero spindle speed is entered.

You can edit the screen set (please copy wxMach.set to some other name and use/edit that so you don't loose your changes in the next Mach4 upgrade/install) and change the SRO slider to be "spindle RPM".  Select the slider and change the "Code" field to "Spindle RPM".  You should also change the name and label, and min/max limits.  I would suggest configuring your spindle range as "1 to 100" in the "Spindle" tab of the normal Mach4 configuration dialog.

Quote
Also, when I hit eStop the laser will stay on (it looks like a lower output) is there anyway I can turn off the laser (spindle) on an eStop?
Something definitely isn't right here.  EStop (or Mach4 Disable) should turn off ALL outputs, including PWM.  It may be that the PWM is getting set to 0% duty cycle as it should, which maybe the laser interprets and "on but very dim"?  But I thought you also had some output signal controlling the on/off signal (or was it turning power on and off).  If you do, THAT output should also go "in-active" during EStop and turn the laser off.  If that is not happening, it sounds like a possible bug in the SmoothStepper plug-in or something unconventional in your configuration that prevents the laser from turning off.

For example, when I try this with our plug-in, when EStop is activated I see messages from the Mach4 core to turn off my "Spindle On" output and it sets the spindle speed to 0.  All the outputs on our board turn off and the PWM output goes to steady-state zero volts (0% duty cycle).

Bob

Offline Pedio

*
  •  200 200
    • View Profile
Re: Add a laser to my CNC
« Reply #25 on: February 13, 2016, 02:39:21 PM »
Bob - thanks. I got to play with the spindle a little more today and it works as you said. The problem I am having is I want to position the laser at the 0,0 point of my work piece. Until I run the g code file Mach 4 does not have a laser setting so I can not turn the laser on using the spindle control to center the work piece. Is there any way I can make a button that turns on the spindle to a known setting?

The other problem is with eStop. Sometimes it turns off the spindle and sometimes it does not. The LED on Mach 4 even shows the spindle on when it does not turn off the spindle. I am using Mach 4 (not the latest but one rev back) and PMDX 410 with a PMDX 132 breakout board.
Re: Add a laser to my CNC
« Reply #26 on: February 13, 2016, 10:43:11 PM »
Bob - thanks. I got to play with the spindle a little more today and it works as you said. The problem I am having is I want to position the laser at the 0,0 point of my work piece. Until I run the g code file Mach 4 does not have a laser setting so I can not turn the laser on using the spindle control to center the work piece. Is there any way I can make a button that turns on the spindle to a known setting?
Yes, there are a couple of ways to do this.

(1) In my test screen sets I've added a DRO near the "Spindle CW" button.  I set the "DRO Code" to "Spindle RPM", and set the "Format" field to "%.1f" which displays 1 fractional digit.  I don't remember why I did that as I don't need that kind of resolution.  Setting to "%.0f" will display no fractional decimal digits.

or...

(2) Add a button. Then edit the button's "Left Up Script" to something like this (UNTESTED!!!!):

local inst = mc.mcGetInstance();
local rpm = 1000;    -- 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

Quote
The other problem is with eStop. Sometimes it turns off the spindle and sometimes it does not. The LED on Mach 4 even shows the spindle on when it does not turn off the spindle. I am using Mach 4 (not the latest but one rev back) and PMDX 410 with a PMDX 132 breakout board.
Rats.  I don't know *WHY* I thought you had an ESS.  I could have sworn I read that earlier in this thread, but (now) obviously not.  Well then, I guess in all fairness I need to say that maybe this is an issue in OUR plug-in.  So I'm going to get niggly here:

- Exactly which version of Mach4 are you running
- Exactly which versions of our plug-in are you running
- Which LED on the Mach4 screen is on when the spindle is still on during EStop?
- Which Mach4 output signal do you have controlling the spindle on/off (ex "Spindle On" or "Spindle Fwd")?
- Which SmartBOB output pin do you have that Mach4 signal mapped to (ex "Pin1", "Pin11", etc.)?

I'm sure I'll have more questions later, but this is a start.

Bob

Offline Pedio

*
  •  200 200
    • View Profile
Re: Add a laser to my CNC
« Reply #27 on: February 14, 2016, 10:09:58 AM »
Bob - In answer to your questions:

Mach 4 - v 2797
Smart Bob - V 33.159
The LED that is on when eStop is pressed is the Spindle CW LED on the main page of wxMach screen set
It appears this LED is driven by the 'Spindle Fwd'
I am using Pin 16 on the PMDX 132 for the PWM

I will try the code for turning on the spindle today and let you know how it goes.

thanks

Offline Pedio

*
  •  200 200
    • View Profile
Re: Add a laser to my CNC
« Reply #28 on: February 14, 2016, 11:05:28 AM »
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.

Offline Pedio

*
  •  200 200
    • View Profile
Re: Add a laser to my CNC
« Reply #29 on: February 14, 2016, 12:15:59 PM »
Bob - also, are you sure the PWM works the way you indicated? If I set the PWM slider for 100% and turn on the laser to the max I have the spindle set for (100) it is very dull. If I set the slider for 250% everything works well. It seems 250% is actually 100% of the laser. It could be that I am confused.