Hello Guest it is July 12, 2020, 12:06:10 AM

Author Topic: VB or Brains Question  (Read 13905 times)

0 Members and 1 Guest are viewing this topic.

VB or Brains Question
« on: August 11, 2010, 09:34:50 AM »
I don't know if this would be a VB Script or Brains question, but I need to know how to set a flag or something when a canned cycle has started (of a G81 as been started)

The machine I am working on has motion clamps that once the drill cycle starts the clamps are activated and then deactivated once the Z returns to the top. Then the machine positions to the next hole and the clamps are active again.

So I need to add this into mach.

Offline BR549

*
  •  6,932 6,932
    • View Profile
Re: VB or Brains Question
« Reply #1 on: August 12, 2010, 01:24:21 PM »
The only way I know of would be to use a brain to monitor the Z positions and activate IF you went below a certain height and then deactivate above that height. You would also need a safety to ONY active if a condition were true. That way it would only work when you called the function pror to running the Cycle. then deactivate the function after the cycle was cancelled.

COuld you not just activate the clamp before the cycle and deactivate after??
Re: VB or Brains Question
« Reply #2 on: August 12, 2010, 01:54:25 PM »
Right now with the DOS software the clamps activate with a M code before the G81, then it will position with the clamps off, turn on the clamps, the drill the hole, retract the bit, deactivate the clamps, then position to next hole.

Is it posible to make a custom canned G code (like G81 but with clamp code in it)?

Offline BR549

*
  •  6,932 6,932
    • View Profile
Re: VB or Brains Question
« Reply #3 on: August 12, 2010, 02:25:13 PM »
NOT a gcode but it may be possible to do it as a SUB or possibly a Mcode.

Is there a reason for wanting to clamp from inside the Cycle and not from a simple Mcode. Most CNCs that I am aware of do it like your DOS version.
Re: VB or Brains Question
« Reply #4 on: August 12, 2010, 04:35:40 PM »
A Mcode would work good as well, I just don't know how to make a M code that will activate the clamps with the drill cycle. The code would be like

M15 (motion clamps)
G81 Z-1.5 R1. F5.
X10. Y10.
X10. Y9.
X10. Y8.
etc

I am unsure how to make the mcode

Offline Hood

*
  •  25,846 25,846
  • Carnoustie, Scotland
    • View Profile
Re: VB or Brains Question
« Reply #5 on: August 12, 2010, 04:43:42 PM »
To make a m code you just open notepad and type the VB you wish then save as the name of the mcode you want, you save it to the macro folder of your profile. for example open notepad and type

ActivateSignal(OutPut1)

That will activate OutPut 1 of Mach
Save it as m7777.m1s to your profiles macro folder, so if you use the standard Mach3Mill profile you would save it to C:|Mach3\macro\Mach3Mill

Then each time you call m7777 from code it will switch on OutPut 1

To switch it off you will need another macro so the VB fro that would be

DeActivateSignal(OutPut1)

and if you saved as m8888.m1s it would work when your code has m8888 in it.

It is best to leave numbers under 100 for Mach internal and I think it was pointed out to me  that numbers between 1000 and ????( sorry I forget) is best left for OEM macros. However in practice as long as you check that no other macro has that number you should be fine but best to stay over 100.

Hood

Re: VB or Brains Question
« Reply #6 on: August 12, 2010, 06:29:19 PM »
So would I have to write my gcode like

M7777
G81 Z1.5 R1. F5.
M8888
X10. Y10.
X10. Y9.
X10. Y6.

And would it cycle the M codes with each position and drill cycle?

Offline Hood

*
  •  25,846 25,846
  • Carnoustie, Scotland
    • View Profile
Re: VB or Brains Question
« Reply #7 on: August 12, 2010, 06:31:15 PM »
That I am not sure of but will test in a second and see :)
Hood

Offline Hood

*
  •  25,846 25,846
  • Carnoustie, Scotland
    • View Profile
Re: VB or Brains Question
« Reply #8 on: August 12, 2010, 06:41:31 PM »
Looks like its only for the first one it works :(
Will have a think about this, maybe Terry will have an idea as he usually can come up with something.
Hood
Re: VB or Brains Question
« Reply #9 on: August 12, 2010, 06:44:16 PM »
It would be nice if the G81 was just like a macro file, then I could just make it look for a flag that the M code would set and have it turn on and off the output from within the G81 code.