Hello Guest it is April 18, 2024, 06:52:31 PM

Author Topic: How to stop a movement when input is active?  (Read 11681 times)

0 Members and 1 Guest are viewing this topic.

How to stop a movement when input is active?
« on: February 11, 2011, 02:40:29 PM »
Hello all!

First a littel introduction of myself. I´m a student at a technical school in Germany.
At the moment I´m building a CNC plasma-router, running with mach3.

I want to write a macro that should automatically set the right hight from the sheet metal.

For this application I need to code something that will stop the movement of the Z-axis when a Input Signal is active.

I wanted to try something like that:

Code: [Select]
Input = IsActive(INPUT1)

If Not (IsActive(Input)) Then
Code "G1Z-20F100"                 "Z-Axis is moving a in Z - to touch down on the sheet an trigger the sensor"
While isMoving()
Sleep 100
Wend
Else
DoOEMButton(1003)                   "I wanted to stop the Axis moving with that, but this seems to be wrong in that way!"
End If


This code doesn´t work for me ( Unfortunately, I dont have a big idea about basic  :(  )

So I just want to stop an Axis movment by an Sensor.
Can anybody help me with that problem?

Thank you in advance!

Greets
Bob

P.S. Sorry if there are to much mistakes in my speech  ;D

Offline zealous

*
  •  489 489
  • HI!
    • View Profile
    • Artsoft Solutions
Re: How to stop a movement when input is active?
« Reply #1 on: February 11, 2011, 05:11:53 PM »
I dont have all the info on what you are trying to do but following the code you have this would be how you would do it:

Code: [Select]
Code "G1 Z -20 F100"
While isMoving()
If (IsOutputActive(Output1)) Then
DoOEMButton(1003)
Sleep 100                
End If
Wend

Offline zealous

*
  •  489 489
  • HI!
    • View Profile
    • Artsoft Solutions
Re: How to stop a movement when input is active?
« Reply #2 on: February 11, 2011, 05:34:40 PM »
BTW: you could use G31 is what I quess you are looking for.
G31 Z-20.0 F100 (Probe in Z)
Re: How to stop a movement when input is active?
« Reply #3 on: February 12, 2011, 08:45:24 AM »
Hi,

Thank you Jason!

I tryied it with your code and the axis is stopping.

But I want it to return straight after it has stopped, and move it incremental to maybe Z +5 ( sorry I didn´t mentioned that in my first explanation ).
With the G31, it is stopping when the Input is active, but not moving any more when the input is active, when I disable the input manually it starts to move back.

Maybe to be clearer I wanna do something like the guy in this short clip (Machine is doing a touch probe with the torch before every cut)

I tryied it like that :

Code: [Select]
Code "G31 Z -20 F100"
While isMoving()
If (IsInputActive(Input1)) Then
Code "G91"
Code G0 Z5
Sleep 100                
End If
Wend

But aint working

Any ideas?

Thanks
Bob
« Last Edit: February 12, 2011, 08:47:46 AM by bob1 »

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: How to stop a movement when input is active?
« Reply #4 on: February 13, 2011, 04:00:31 AM »
Bob - I'm not sure if you have been told to do this via a VB macro by your school but this is not generally how this is done. IHS (Initial Height Sensing) from the hardware point of view is usually done by one (or more) of: Floating head, Ohmic sensing and capacitive sensing. It sounds from what you've said that you are using the floating head method with a microswitch. If so, you have the option of using either probe based IHS (G31) or home based IHS (G28.1). I'd suggest home based to start with.

In this method, you set your floating head microswitch as a home switch and set home to be -ve (in home/limits). You then use something like the following gcode at the start of each cut:

Code: [Select]
G28.1 Z3.00  (home downwards from safe height, 3 is just an example)
G92 Z0.0      (Homed, so set Z to 0)
G00 Z2.8000 (back off for switch travel - yours will likely be different - set distance appropriately)
G92 Z0.0      (set Z to 0)
G00 Z3.8000 (Move up to piearce height - see your plasma cutter manual)
M03             (fire torch)
G04 P0.3      (wait pierce delay - see your plasma cutter manual)
G01 Z1.5000 (descend to cut height - see your plasma cutter manual)
....               (commanded moves in x, y)

Hope this helps

Ian
Re: How to stop a movement when input is active?
« Reply #5 on: February 13, 2011, 05:39:01 AM »
Thanks Ian,

Yes, I ve got a sensor to do the floating head method. But I ´ve got a home sensor for homing of the Z-axis as well



here on that picture you can see the lower sensor for the probe and the upper sensor for homing.

I still want to use the upper one for homing.
So wouldn´t it be better to use the G31 option?

Which input do I have to use then? ( Touch probe?)

Could you explain what "-ve" is?
Quote
to be -ve (in home/limits).


Btw:
Quote
I'm not sure if you have been told to do this via a VB macro by your school
It´s not a school project it´s my private project :-)

Thank you!

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: How to stop a movement when input is active?
« Reply #6 on: February 13, 2011, 07:45:04 AM »
Yes you can use the G31 method if you want. It's one of those things that creates much discussion - G28.1 or G31 - which is better? They both have advantages and disadvantages. To use G31 you'd use the probe input in ports and pins. Then use something like G31 Z -100 instead of the G28.1 line in my previous code. The -100 is just an example - it doesn't really matter as long as your probe touches the metal at some point of course. You might want to add a feedrate in there to control the descent.

-ve is just shorthand for negetive.

Ian
« Last Edit: February 13, 2011, 07:54:07 AM by stirling »
Re: How to stop a movement when input is active?
« Reply #7 on: February 13, 2011, 11:42:40 AM »
Thanks again Ian.

I got it working now.
But I still wrote it into a macro, since I don´t want to edit the G-code every time after it comes from my Cam-System.
So now, it does the touch probe automatically with every M3. And thats the way I wanted it, yeah I´m lucky  ;D :)
Thank you again!

I made a short clip to prove that It´s working ;)

Bob

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: How to stop a movement when input is active?
« Reply #8 on: February 13, 2011, 12:07:24 PM »
That's good - thanks for the video too.  :)

Just a note though. If you prefer a macro, that's fine but you shouldn't even need to edit your code to insert that - ideally your CAM should be set up to insert it for you - either inline code or macro.

Ian
Re: How to stop a movement when input is active?
« Reply #9 on: February 13, 2011, 12:11:52 PM »
I see

Well I´m not very into my Cam yet. ( all new for me )

First I thought I´d have to edit the post processor - which doesn´t seem to be that easy aswell :-)

But it´s ok im pleased now ;-)

Bob
« Last Edit: February 13, 2011, 12:21:46 PM by bob1 »