Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: Jim G on January 08, 2016, 03:34:58 PM

Title: code for a repeat single axis driller
Post by: Jim G on January 08, 2016, 03:34:58 PM
Having trouble getting the code to work. Using Mach3
Basically want the start with an input to the driller - then when the driller finishes signal the stepper to move the desired amount then signal the driller to drill and so forth - usually a set repeat.
Controller has 3 outputs and inputs...
Can get it to cycle and dwell for a short time but send or receive the signal.

any ideas - new to the g-code stuff but have some experienced help..
Title: Re: code for a repeat single axis driller
Post by: BR549 on January 08, 2016, 04:31:09 PM
It will depend on HOW your driller communicates with Mach3 as to HOW you will need to go about it. Bascially what you describe is not a Gcode process but more of a PLC ( programable logic controller) process .

(;-) TP
Title: Re: code for a repeat single axis driller
Post by: Jim G on January 08, 2016, 04:45:56 PM
I am using a Mach 3 program and a controller from CNC router parts that has 3 outputs and 3 inputs. The out puts will trigger a 24v AC valve that will actuate the driller. The signal needs to be momentary so the drillers can cycle and return to the rest position. The drillers will then send a signal via a proximity switch to the controller to move the puller to the next position - where it will signal the driller and repeat the signal .


Title: Re: code for a repeat single axis driller
Post by: BR549 on January 08, 2016, 05:16:01 PM
OK Can you define Momentary ? Would that be a 1 sec signal or longer and what defines how long it needs to be OR can it simply wait on the driller to reach teh bottom of stroke ??

THIS would be very simple IF you made the driller into the Z axis and drove it all from Gcode. As is you will need both Gcode and Macros to do what is needed.  

(;-) TP
Title: Re: code for a repeat single axis driller
Post by: Jim G on January 08, 2016, 05:25:03 PM
The signal can be as short as 1/10  of a second. The drillers are Desoutter units and are the standard air over eclectric models.
They drill at angles so I am just setting this up with a puller for positioning the wood under the drills.
If using the z axis the drillers would have to be moved with steppers as well?  I am pretty sure I need Macros.


Thanks for the help.
Title: Re: code for a repeat single axis driller
Post by: BR549 on January 08, 2016, 06:03:11 PM
OK  few more questions. Will this be a continous feed type of thing or do you load a part complete the process then unload and  Load another part to be processed?

(;-) TP
Title: Re: code for a repeat single axis driller
Post by: Jim G on January 08, 2016, 06:39:23 PM
load a part - complete the process and unload and repeat..... thousands of times .......
Title: Re: code for a repeat single axis driller
Post by: BR549 on January 08, 2016, 07:33:11 PM
It is doable from Mach3 You use Gcode to do the motion and a macro to control the stop start . A macro(Mcode) in the Gcode would control the Driller process.

The macro would simply turn on outputs and watch for inputs to signal things were done then the Gcode side starts motion again and repeat.

IF there is any way I can help just let me know. I can walk you through the Macro code side and the Gcode side is very easy to do

(;-) TP
Title: Re: code for a repeat single axis driller
Post by: Jim G on January 09, 2016, 09:25:15 AM
I have some macros loaded from the guys at CNC router parts.. how do I add stuff to these replys so you see what I am working with..
Title: Re: code for a repeat single axis driller
Post by: BR549 on January 09, 2016, 09:41:45 AM
Hit the reply button THEN the addition options button.

(;-) TP
Title: Re: code for a repeat single axis driller
Post by: Jim G on January 09, 2016, 10:14:50 AM
here is the xml file and the m1s stuff
tell me what else you need -
Have these loaded in program but I can get the diagnostic tool to do anything..
Suppose to issue a m90x command to test these???
Title: Re: code for a repeat single axis driller
Post by: BR549 on January 09, 2016, 10:37:54 AM
Each of those macros simply turns on and off a specific Output signal. What they do not have is a safety excape to be able to break out of the loop they create.  IF the switch does not trip then you are forever stuck in that loop with no easy way out.

You will only need one Macro to drive teh process but it is a complex macro with safeties included. You would make the motion moves in Gcode to get into position then make a macro(say M100) That macro would then control the activate and WAIT until teh driller signals it has finished . But at the same time there has to be an excape route in the code to allow you to break out of an endless loop in teh event that Mach3 does NOT see teh signal. Most times that would be a simple timer. You would time teh process then add a fudge factor to that. THEN IF the macro failed to see teh inout signal it would auto stop the process and cancel the program and post a message teeling you what happend "Hey dude I am busted please fix me" It can even call you on your cell phone and leave you a text message.
(;-) TP
Title: Re: code for a repeat single axis driller
Post by: BR549 on January 09, 2016, 10:44:21 AM
Also you may want to contact Artsoft and have them transfer that license into your company name.  Someone may mistake that fact that it is not in your name to mean it could be a pirated license. Not saying it is but there are many thousands of pirated license out there now.  Normally a company selling OEM licenses use a serial Number to identify it as an individual license and are not just using 1 specif lincense to run 100 machines that they sell. There are many OEM out it the world that have done just that. I for one will not help anyone that I think has one as it would not be fair to the ones that bought a legit license.

(;-) TP
Title: Re: code for a repeat single axis driller
Post by: Tweakie.CNC on January 09, 2016, 11:15:27 AM
Please correct me if I am wrong but I suspect that the .xml file posted has been taken from the CNC Router Parts installation disk rather than from Jim's Mach3 folder ??

Tweakie.
Title: Re: code for a repeat single axis driller
Post by: BR549 on January 09, 2016, 11:25:11 AM
Yes I believe that to be true But it is a good idea and I believe an artsoft suggestion to have it trnasferred into your name to calrify ownership of the license. IF the Oem shipped the same license file to everyone that would violate teh license agreement ???

The license file here on the plasma came from teh OEM as a serial number and it can be traced back to artsoft through that serial number that was assigned to that license when THEY bought it from Artsoft.

Just a thought, (;-)TP
Title: Re: code for a repeat single axis driller
Post by: BR549 on January 09, 2016, 11:47:13 AM
This would be an example of a macro(m100) that could drive your function.

' M100 Driller macro
Lcnt = 0                  ' Set Loop Counter to Zero
   ActivateSignal(Output10)                          ' Create a Momentary signal of 1 sec to start driller function
   Sleep(1000)
   DeactivateSignal(Output10)

While Not Isactive(Input10)  OR  Lcnt <10000   ' Wait for the Driller to signal DONE or time out

                  IF Lcnt > 10000 then      ' IF timeout occurs then cancel Program
   Message" Driller did not respond"
   DoButton(3)
   End
   End if

   Lcnt = (Lcnt +1)                                         'Increase count by 1 each loop
Wend

While Ismoving()
Wend

End
Title: Re: code for a repeat single axis driller
Post by: BR549 on January 09, 2016, 01:18:20 PM
HOW that would be used in a part program would be like

(Program #10001 )
G40 G80 G90 G54
G0 X0 Y0   (Move to a ref point)
G0 X10      ( Move to first drilling location)
M100        ( call Driller cycle)
G0 X20
M100
G0 X30
M100
G0 X0 Y0  ( Return to Ref point )
M30

etc,etc
Title: Re: code for a repeat single axis driller
Post by: Jim G on January 09, 2016, 01:34:23 PM
Ok - I will load that and see what how my outputs react...

thanks
Title: Re: code for a repeat single axis driller
Post by: Jim G on January 13, 2016, 05:43:43 PM
That code didn't work real well when I loaded in my macro for the outputs.
But I have a cycle that works as long as I manually interrupt the end of drilling cycle -
the end of drilling cycle is a limit switch on the drills that is normally closed - When the driller drills it opens and when it finishes it trips the switch to a closed position it signals the Macro to go to the next Gcode cycle. The problem is that the computer reads the signal as sustained and I can't get out of the Gcode loop and into the macro to activate the driller. I  need to insert something in the macro code to turn the input signal from the drill from a sustained signal into a momentary signal . When I do this manually all runs well.

I have attached the macro language - Help.

ActivateSignal(OUTPUT1)
While IsActive(INPUT1)= False
Sleep(50)
Wend
DeactivateSignal(OUTPUT1)
Title: Re: code for a repeat single axis driller
Post by: BR549 on January 13, 2016, 05:54:22 PM
You need to add a small wait period so that the Driller has time to move off of the switch before it starts monitoring the DONE switch


ActivateSignal(OUTPUT1)
While Ismoving()
Sleep(1000)        ' Wait 1 sec  This can be adjusted as needed
Wend
While IsActive(INPUT1)= False
Sleep(50)
Wend
DeactivateSignal(OUTPUT1)
Title: Re: code for a repeat single axis driller
Post by: Jim G on January 13, 2016, 06:22:39 PM
The switch closes when the driller is done drilling and remains closed until the next cycle when it opens when the drill descends.
I will put this in my program and see if it works.

Thanks so much - will let you know.


Title: Re: code for a repeat single axis driller
Post by: Jim G on January 13, 2016, 06:42:48 PM
It worked - thanks so much!!!!