Hello Guest it is April 16, 2024, 10:02:30 AM

Author Topic: How to activate & deactivate an output once every 5 seconds in G-code or macro?  (Read 23315 times)

0 Members and 1 Guest are viewing this topic.

Hi

I am fairly new to the world of CNC, i recently built a small milling machine which packs a real punch and have been making parts on it for a few months now.
I use Lazycam on dxf files and then tweak the G-code manually which has been a great learning curve, in fact the whole project has been really.

I have just finished my lubrication and chip removal system and am all set to go apart from activating it in my G code. I recently discovered macros and wonder if these may help here also.
My lube is straight 11 weight cutting oil and is sprayed at the cutter at high pressure through an automotive fuel injector driven by a PWM driver. This works great but I don't need the lube running constantly, even at minimum PWM to open the injector there is still 10 times more oil than I need being delivered to the cutter and it just makes a mess.
I don't want a flood type system, it's an open machine that makes enough mess as it is, and i need bugger all cutting oil on the alloy at a time. Currently I am applying it with a paintbrush prior to each cut and that is plenty.



How do I go about activating a relay output for say 1 second out of every 5 seconds, while my code is running? Is this even possible in the Mach3/Windows XP environment?
I can easily use an arduino to turn on/off every 5 seconds but i feel the computer is smart enough to do that itself, if only I knew how!!
Can we use code similar to the arduino "blink without delay" example in a macro? (ie use the system clock and count milliseconds til on/off)


Thanks in advance for any help, please bear in mind my programming knowledge is fairly limited so try to keep it simple if possible!!
oh heres a little video of my machine in action :)

http://www.youtube.com/watch?v=-lSF12hWVFM

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Welcome to the forum Andrew, That will be easy enough but I'll let some of the macro gurus chime in on this.


Disclaimer!!!  Please realize ethanol is flameable!!!!
The injector is a good idea for a mister.  If all your machining is Alum., check into to using ethanol for coolant.  A good friend runs a lot of alum. sheets on his router and is loving it so far.

Brett
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!

Offline Tweakie.CNC

*
  • *
  •  9,197 9,197
  • Super Kitty
    • View Profile
Hi Andrew,

Welcome to the forum.

Something you may wish to consider, as an alternative approach…

A couple of years back I needed an oil-mist solution for my little mill so I purchased a small compressor (intended for a domestic refrigeration unit) which is piped to a (1.5mm internal diameter) nozzle aimed at the base of the cutter. In the air line I use an adjustable ‘air tool oiler’ and this provides the necessary oil mist spray as well as a reasonable amount of chip removal and it runs continuously during the job.

It may depend on your ambient air temperature but I was initially concerned about running the compressor for extended periods but as it is not working hard  (it is being used more as an air pump rather than a compressor) it has not overheated or shown any signs of distress after many, many hours of use now.
The oiler has to be checked and refilled, if necessary, before each job but I am sure that larger units are available should you need to use a greater volume of oil mist than I do.

Just a suggestion.

Tweakie.
PEACE

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Hi Andrew

Here's one I made earlier - season to taste.

Cheers

Ian
Hi guys thanks for the warm welcome and help. The "brains" feature is great and exactly what i was after. looks like ill be able to do much more with it too.
I modified the file slightly, so it can be enabled/disabled in G-code by calling the standard M7 and M8 coolant commands. Flood coolant gives a pulse every 3 seconds and Mist coolant every 7 seconds (for now). This should enable me to easily vary the amount of oil used based on how hard the machine is working.
I tried to make it automatically activate when Z<0 (cutting) but i found it crashed Mach3 whenever i enabled it, so i will turn it on and off in code like normal coolant.

Nice setup tweakie, I'm sure it works well but I will persevere with this for now and see how it goes..... as for ethanol, that's a bit flammable for me thanks! We use that for fuel in race engines! I actually have the oil mixed 50/50 with diesel at the moment to thin it down and make the pumping a bit easier. It's a bit smelly though so I think ill go back to straight oil.

The fuel injector works well, but doesn't give the mist I was expecting. Instead I get a powerful stream about 0.5mm wide which is just nice when its spraying directly on the cutter at high pressure.

Here is a couple of photos of the whole system, just have to wire it all into the control box tomorrow, i have about 60 hours work lined up for the machine in the next week or so which will be made much easier if I'm not vacuuming chips away and applying lube by hand. Looking forward to testing it out!
The 3 green hoses go back to a collector which is connected to the shop-vac, hopefully this will pick up most of the chips. I can feel the vacuum with my hand about 1" down from the collet holder, all the way around, so i hold high hopes for the system.
You can just see the injector in the back, I have blocked off one of the nozzles and angled it to get the oil where I want out of the remaining one. There is a drum of oil underneath with an EFI fuel pump inside and a basic return system to give adjustable "rail pressure"
As you can see in the last shot the whole lot slides up to give access to the collet holder for changing tools, there is only just enough clearance for this!







Wow, late update. The vac system was no good so I ditched it, but the lube system is just great.

Here is a short video of it in action.
https://www.youtube.com/watch?v=NxcoQN0Yayo&feature=youtube_gdata_player

I cooked the first fuel pump by running the oil too low, the new one runs through a large oil cooler. Overall the system works great and is very reliable. Highly recommended.

This cnc stuff is addictive and i just bought a huge knee mill i am converting, will duplicate this lube setup for sure.
Re: How to activate & deactivate an output
« Reply #7 on: June 01, 2016, 05:35:20 AM »
Can sombodey help me. I wrote simple macro M200 to activate and deactivate output. But....nothing happens. Mach3 ignores this in test g code.
Here bellow is macro and g-code-

I put macro in c\mach3\macros\mach3mill

‘  macro


ActivateSignal (OUTPUT9) ‘ Turn on pump
G4 M10 ‘ Give it time to charge fully
DeactivateSignal (OUTPUT9)


....test g - code

g1 x 200 y 200
M200

g1 x 100 y 100

----

Offline Graham Waterworth

*
  • *
  •  2,671 2,671
  • Yorkshire Dales, England
    • View Profile
A delay is normally written as G4 P1000 for a 1 second delay if the config is set to ms or G4 P1 if its in seconds
Without engineers the world stops