simple laser cutter ON/OFF control (Z-axis)

More
14 Apr 2014 20:19 #45939 by leintz
hi gururs!

How to switch on and off output pin depending of the height of Z-axis (negative-switch ON, positive switch OFF)
what to add into HAL and INI files....

I have seen only strange non-working samples

thanks!

Please Log in or Create an account to join the conversation.

More
14 Apr 2014 21:52 #45940 by PCW
One way is with the 'abs' component

In addition to the absolute value pin, the abs component has a
sign pin (with type 'bit') that can be used to drive an output pin

Please Log in or Create an account to join the conversation.

More
14 Apr 2014 22:37 #45942 by andypugh

How to switch on and off output pin depending of the height of Z-axis (negative-switch ON, positive switch OFF)


This isn't normally a very good way to do it. The movements in the "phantom Z" will tend to cause unnecessary motion blending with the XY axis motion.

You might find that M62 works better.
www.linuxcnc.org/docs/html/gcode/m-code.html#sec:M62-M65

Please Log in or Create an account to join the conversation.

More
15 Apr 2014 00:41 #45944 by leintz
yes, the phantom Z axis is good enough....
let me see working scripts for HAL and INI files please...

Please Log in or Create an account to join the conversation.

More
15 Apr 2014 01:56 #45947 by andypugh

yes, the phantom Z axis is good enough....
let me see working scripts for HAL and INI files please...


What does the G-code look like?

Do you want the laser on when the Z is above a certain height, or when it is moving in the positive direction?

Please Log in or Create an account to join the conversation.

More
15 Apr 2014 12:01 #45961 by leintz
g -code example

X8.787 Y-6.378 Z-0.1

if Z<0 then turn laser ON

Please Log in or Create an account to join the conversation.

More
15 Apr 2014 16:42 #45962 by cncbasher
[quote=if Z<0 then turn laser ON[/quote]

this is a very dangerous practice to do , you should wait until the z is at the correct cutting height and then turn on , so use M3 for on and M5 for off
as per a standard spindle , also take into consideration any time delays or shutters in the beam path ,

also remember there is a delay between issuing the command and the beam to actually be extinguished fully , and could in some cases still be high enough
to cut or mark the material your cutting . a simple delay command in gcode is all it takes for it to wait that small period before moving .

is this for etching surfaces or as a cutting laser ?

Please Log in or Create an account to join the conversation.

More
15 Apr 2014 16:59 #45963 by emcPT
If you need to do that, a component can do that for you.
It is something that you must read a bit of documentation before you start, and you need to program in C.
(but cncbasher is right on his tips)

Please Log in or Create an account to join the conversation.

More
15 Apr 2014 17:24 #45965 by leintz
this is slow surface etching laser in vector graphic mode

Please Log in or Create an account to join the conversation.

More
15 Apr 2014 17:35 #45966 by andypugh

g -code example

X8.787 Y-6.378 Z-0.1

if Z<0 then turn laser ON


I don't have a LinuxCNC machine in front of me right now, but I _think_ that the axis.2.joint-pos-cmd pin shows the commanded Z position. You would need to check this.

There is a problem with the G-code above. Assuming that the previous move was with Z = 0.1 then Z is only less than zero half way through the move, because the axes move in a coordinated way.
For example
F100
G0 Z0.1 X10 Y10
G1 Z-0.1 X20 Y10
Would only turn the laser on at X15 Y10, as that is the point that Z becomes negative.

So, I think what you really need is laser on with Z _velocity_ negative, and off with Z _velocity_ positive.
But then, what happens if there isn't a Z move in the XY move? Then presumably the laser needs to latch in the current mode.

So, we are going to need an abs to detect the direction of motion:
www.linuxcnc.org/docs/html/man/man9/abs.9.html
We also need a differentiator to convert position to velocity
www.linuxcnc.org/docs/html/man/man9/ddt.9.html
And a flipflop latch to hold the last value unless it needs to change.
www.linuxcnc.org/docs/html/man/man9/flipflop.9.html

Add this code to your custom.hal file
loadrt ddt count=1
loadrt abs count=1
loadrt flipflop count=1

addf ddt.0 servo-thread
addf abs.0 servo-thread
addf flipflop.0 servo-thread

net vel-calc axis.2.joint-pos-cmd => ddt.0.in
net vel-out ddt.0.out => abs.0.in
net beam-on abs.0.is-negative => flipflop.0.set
net beam-off abs.0.is-positive => flipflop.0.reset
net beam-command flipflop.0.out => parport.0.pin-04-out

There are many reasons that you might not be able to use this HAL fragment as-is. If you already have some abs, ddt or flipflop modules loaded in a different HAL file, for example. I have also assumed that the laser is controlled by a randomly-chosen parallel port pin. You probably want to use something else (you didn't say).

At the end of the day you need to understand HAL to use HAL.
The following user(s) said Thank You: leintz, howdozhangli

Please Log in or Create an account to join the conversation.

Time to create page: 0.089 seconds
Powered by Kunena Forum