Who can crack the code?

More
03 Jul 2013 04:52 #36253 by jd896
I'm automating a machine we already have I've now got the drives and such working on a desk and while I wait for my Mesa cards to come wanted to nail this

Here's what I have now this will be in an ngcgui panel when done

#<base-holes> = 3
#<base-centres> = 50
#<first-hole> = 53
#<distance-to-main> = 509
#<main-centres> = 150
#<number-main-holes> = 26


G0 X#<first-hole>
#<current-x> = #<first-hole>
o103 repeat [#<base-holes>]
G4 p1
#<current-x> = #<current-x> + #<base-centres>
G0 X#<current-x>
o103 endrepeat

#<current-x> = #<distance-to-main> + #<current-x>
G0 x#<current-x>
o104 repeat [#<number-main-centres>]
G4 p1
#<current-x> = #<current-x> + #<main-centres>
G0 X#<current-x>
o104 endrepeat
Go xo
M2

( the g4 is in place of the punch command as I'm trying to get this code worked out in a sim )

Main issue is that this only takes into account for the one punch head on this machine and there's two at a 600mm offset so the program needs to start on that and then when the math works out ( and the machine is at x600 plus ) the second head needs to join the race

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

More
03 Jul 2013 06:01 #36257 by BigJohnT
Replied by BigJohnT on topic Who can crack the code?
What works for me is to write out in pseudo code first for complex things like this.

What is the rule for the second head to punch?

JT

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

More
03 Jul 2013 13:30 #36261 by jd896
Replied by jd896 on topic Who can crack the code?
The second punch basically needs to copy what the first has done only 600mm later down the job

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

More
03 Jul 2013 20:38 #36272 by BigJohnT
Replied by BigJohnT on topic Who can crack the code?
It takes both punches to complete a hole? It's not clear to me what the second punch does.

JT

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

More
03 Jul 2013 20:58 #36273 by jd896
Replied by jd896 on topic Who can crack the code?
No they work on different sides of the same job one mirrors the other 600mm later

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

More
04 Jul 2013 00:13 #36284 by BigJohnT
Replied by BigJohnT on topic Who can crack the code?
Sounds interesting... so what ever pattern you have on the first punch you repeat that 600 mm later. That sounds like it will take a few logic loops to see what hole is next to move to. I assume that there could be an instance where neither punch punches at the same time and times when both punches punch at the same time. So I'm back to my earlier statement about writing it out in pseudo code first...

Something like this comes to mind:
punch1 first hole = some distance
punch2 first hole = punch1 first hole + 600
then move to first hole and punch
check to see what is the next hole
move to next hole
if punch1and punch2 then punch both
if punch1 not punch2 then punch1
if not punch 1 and punch2 then punch2
move to next hole

JT

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

More
04 Jul 2013 23:59 - 05 Jul 2013 21:49 #36308 by ArcEye
Replied by ArcEye on topic Who can crack the code?
Hi

No-one seems to be rising to the challenge

I have had to scale down the distances involved to get them to fit into a sim

The first punch is represented by the negative Z moves, the second punch is represented by the positive Z moves

Since there is only one tool origin on a sim, the moves are in the same plane but shown #<_between-punch-heads> apart
(ie offset from each other when in reality they would be operating on the same point on the workpiece)

This is not a polished piece, just an example of using a sub to activate the second head when the first is #<_between-punch-heads> ahead of a hole
There are many ways to do the same thing
;punch.ngc
;ArcEye 2013

o200 sub
    o201 IF[#<_bottom-base-index> LT #<_base-holes>]
            G0 X#<_bottom-x> 
            G1 Z10 F1000
            G0 Z0
            #<_bottom-x> = [#<_bottom-x> + #<_base-centres>]
            #<_bottom-base-index> = [#<_bottom-base-index> + 1]
            o203 IF[#<_bottom-base-index> GE #<_base-holes>]
                #<_bottom-x> = [[#<_bottom-x> - #<_base-centres>] + #<_distance-to-main> ]
            o203 ENDIF
    o201 ELSE
        o202 IF[#<_bottom-main-index> LT #<_main-holes>]
            G0 X#<_bottom-x>
            G1 Z10 F1000
            G0 Z0
            #<_bottom-x> = [#<_bottom-x> + #<_main-centres> ] 
            #<_bottom-main-index> = [#<_bottom-main-index> + 1]
        o202 ENDIF
    o201 ENDIF
o200 endsub



g17 g21 g40 g49 g54 g80 g90 g94

#<_base-holes> = 3
#<_base-centres> = 10
#<_first-hole> = 20
#<_distance-to-main> = 100
#<_main-centres> = 15
#<_main-holes> = 6

#<_between-punch-heads> = 30

#<_bottom-base-index> = 0
#<_bottom-main-index> = 0

G0 X0 Y0 Z0

G0 X#<_first-hole>
#<_top-x> = #<_first-hole>
#<_bottom-x> = [#<_first-hole> + #<_between-punch-heads>]

o103 repeat[#<_base-holes>]
    G0 X#<_top-x>
    G1 Z-10 F1000
    G0 Z0
    o105 IF[#<_top-x> GE #<_bottom-x> ]
        o200 call
    o105 ENDIF
    #<_top-x> = [#<_top-x> + #<_base-centres>]
o103 endrepeat

#<_top-x> = [[#<_distance-to-main> - #<_base-centres>] + #<_top-x>]
    o108 WHILE[#<_top-x> GT #<_bottom-x> ]
        o200 call
    o108 ENDWHILE
    
o104 repeat [#<_main-holes>]
    G0 X#<_top-x>
    G1 Z-10 F1000
    G0 Z0
    o106 IF[#<_top-x> GE #<_bottom-x> ]
        o200 call
    o106 ENDIF    
    #<_top-x> = [#<_top-x> + #<_main-centres>]
o104 endrepeat

o107 WHILE[#<_bottom-main-index> LT #<_main-holes>]
        o200 call
o107 ENDWHILE

G0 X0 Y0 

M2

Plot looks like this





regards
Attachments:
Last edit: 05 Jul 2013 21:49 by ArcEye. Reason: left in some code not used in final version
The following user(s) said Thank You: jd896

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

More
05 Jul 2013 18:18 #36329 by BigJohnT
Replied by BigJohnT on topic Who can crack the code?
That's pretty slick ArcEye!

JT

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

More
05 Jul 2013 21:00 #36339 by ArcEye
Replied by ArcEye on topic Who can crack the code?
Thank you.

The trick was figuring a flow which would prevent the bottom punch advancing beyond the next hole and then having to go back to it.

As you said, a bit of planning and scrap paper is always worth while.

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

More
06 Jul 2013 02:52 #36346 by jd896
Replied by jd896 on topic Who can crack the code?
this is brilliant i have a hard enough time finding the gcode docs

one thing i havent worked out what the base index variables are for

ill have to study the code some more still havent got it followed fully yet

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

Time to create page: 0.103 seconds
Powered by Kunena Forum