Hello Guest it is April 19, 2024, 12:54:57 PM

Author Topic: Complete newb, need help  (Read 2704 times)

0 Members and 1 Guest are viewing this topic.

Complete newb, need help
« on: October 19, 2017, 09:59:54 AM »
Hi!

So, I'm doing a project involving a Mach3 powered CNC with a custom fixture. In essence, we are not doing any tooling, but merely using the CNC head to travel in a regular path while it carries a probe that's performing some surface treatments.

Thanks to an electrical malfunction (without going into too much detail, my experiment involves high voltages which backfired thanks to a miswiring), I've lost all my code (and the USB key that it was backed up on).

Since my background is in a field completely unrelated to engineering (chemistry), I have literally zero experience using gcode.

My experiment basically involves moving the head in repeatable straight lines for N times at a set feed rate. Could anyone help me whip up some basics, at least for the loop function?

Through trial and error and what I remember from my protocol/ cobbled together from what I found online, this is similar what I'm doing. Unfortunately I also forgot the initialisation parameters :(

Code: [Select]
M3
G1 X0 Y0

G1 X15 F0.5
G1 Y0.5 F0.5
G1 X0 F0.5
G1 Y1 F0.5
G1 X15 F0.5

M30

My old version of the code looked something like this, repeating until Y=15. My experiment basically involves changing the step size (Y0.5 to ex Y0.3 or whatever) at a set feedrate.

I know it's asking for a lot, but it would really save my rear, especially as this is the only gcode that I'm likely to ever need in my life.

Thanks in advance!
Re: Complete newb, need help
« Reply #1 on: October 21, 2017, 05:25:46 PM »
Hi,
couple of observations both F and G1 are modal.

So when you specify the feedrate F as you do on the first line, it will stay like that for all subsequent lines until a new Fnnn word is issued.
Likewise G1 which means 'co-ordinated linear interpolated move at current feedrate' is modal. There is no need to write it on each line. It won't matter
if you do and sometimes may make the code easier to read but it can sometimes clutter things up.

Code: [Select]
m3
g1 x0 y0 f0.5
x15
y0.5
x0
y1
x15
y1.5
x0
y2
x15........

Somewhat tedious to code but as simple as it can be and you'll only have to do it once. There are other alternatives such as using loops but
Gcode doesn't have conditionals and so can't be used as a general purpose programming language. Over the years various cheats and workarounds
have been devised some of them very clever but far from intuitive, why complicate this thing?

Just as a matter of interest what sort of high voltage are you talking about? Some years ago a friend and I were working on an electrostatic precipitator
and I was regularly generating 70kV DC from my own design/build inverter. High voltage sure does teach you some important lessons...fortunately our
experiments were all energy limited so we lived long enuf to learn them!

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Complete newb, need help
« Reply #2 on: October 21, 2017, 10:10:40 PM »
Hi,
re-reading your post and you may need a few more preparatory codes.

As you've already noted M3 is a valid m code, its meant to turn your spindle on. You could use one of Machs outputs to turn your device on for instance.
If you use this idea it may take a short while before your device/etcher/gizmo is ready. There is a delay code:
G04 Pnnnn where nnnn is the delay in seconds (milliseconds). Whether the parameter P is interpreted as seconds or milliseconds is determined by the
setting Config/General Config   G04 Dewll in msec check box upper right.

You don't specify what units you wish to use. The numbers you've posted suggest inches. Is this the case? If so it would pay to program a G20 at the beginning
of your code. Likewise you don't specify whether your moves are absolute or incremental. Again from the numbers you've posted absolute looks certain.
Is this the case? If so code G90. You should code G17 to ensure the machine is in XY plane mode. Code a G40 to cancel cutter radius compensation and
G49 to cancel tool length compensation, a G50 to reset all scale factors to 1. Code G54 to make sure you are using the primary work co-ordinate system
and G69 to cancel any rotation. Code a G15 to be sure your in Cartesian co-ords. Code G94 to be sure you are in per minute feed units.

As soon as you code G1 all other canned cycles are effectively cancelled.

Putting them altogether:
Code: [Select]
G15 G17 G20 G40 G49 G50 G54 G69 G90 G94
Would recommend an M5 at the end to turn your spindle/device/gizmo off and then M30 which  stops the program and rewinds the code to do it again.

Code: [Select]
G15 G17 G20 G40 G49 G50 G54 G69 G90 G94
M3
G04 P1
G1 x0 y0 f0.5
x15
y0.5
x0
y1
x15
y1.5
x0
y2
x15
y2.5
x0
y3
x15
M05
M30

This is a tedious but simple way to code. If you wish to have variable step over and or programmable end points then coding this way will become
very tedious indeed. If that is the case then a macro is looking like a solution. Machs scripting language is a subset of Visual Basic called Cypress Enable CE
and it has all the expected looping and conditionals.

Craig

'I enjoy sex at 73.....I live at 71 so its not too far to walk.'