Who can crack the code?

More
13 years 3 months ago - 13 years 3 months ago #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
Code:
;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
Last edit: 13 years 3 months ago 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
13 years 3 months ago #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
13 years 3 months ago #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
13 years 3 months ago #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.

More
13 years 3 months ago #36362 by ArcEye
Replied by ArcEye on topic Who can crack the code?

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


Quite simple, they keep track of the number of holes for the second punch, both the base-holes and the main-holes.

The top punch can be run in a repeat loop as you had previously, but the bottom punch is conditional on the distance the X axis has moved.
Therefore you need to know when all the holes have been punched by a different method.

I never actually use repeat in G Code, using while loops or if logic, so I am using indexes all the time.
But that is probably because there is no repeat in C and I just use the constructs I am used to.

regards

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

Time to create page: 0.065 seconds
Powered by Kunena Forum