Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: hermeticsj on November 10, 2015, 04:17:24 PM

Title: Keyboard M-function?
Post by: hermeticsj on November 10, 2015, 04:17:24 PM
Is there a way to map the spacebar (or any other key) to activate a custom M function that I use? The M function is to activate a laser for spot welding the ends of the work down before the program welds the full profile.

Any suggestions would be appreciated.
Title: Re: Keyboard M-function?
Post by: robertspark on November 10, 2015, 05:52:49 PM
you can .... but it depends upon what codes are mapped within your screenset and what screen is on view at the time you are hitting the key....

The spacebar is not a good key to use as it normally has other functions (look for "space" / key "32" on these std screensets):
http://www.machsupport.com/Mach3Wiki/index.php?title=Standard_Hotkeys

How are you controlling your laser  (how do you toggle it on and off... which output are you using / do you have a button on the screen).

The reason why I ask is because if you were using the "plasma" screenset on that page you can see that if you hit the "F5" key it will toggle the plasma cutter on and off.... hence the button has been mapped to that key...

If you send me your screenset and tell me on what screen you want the button to toggle the laser on and off I'll change the button for you if you have one on the screen.

You can edit the screenset yourself using MachScreen http://www.kd-dietz.com/klausphp/pages/eng/machscreen/description/ms_description.html

Attached is a screenshot of my plasma screen.

Rob
Title: Re: Keyboard M-function?
Post by: BR549 on November 10, 2015, 09:06:28 PM
Anytime you use a hotkey to control a dangerous function you should use a 2 key solution. Set your hotkey to something like {Ctrl  L}   

Just a thought, (;-) TP
Title: Re: Keyboard M-function?
Post by: robertspark on November 11, 2015, 12:51:08 AM
Good point....
Title: Re: Keyboard M-function?
Post by: hermeticsj on November 11, 2015, 08:27:06 AM
The laser I am using has a series of steps that have to happen before it will fire.

There are two logic lines going to a DB37 connected to the laser that have to be closed to a COM line in the laser.

I'm using the K1 (Output 1 in mach3) relay on  PMDX-126 as the laser stop and the K2 (Output 2 in mach3) relay as laser start. The sequence to make the laser fire is :

Activate K1
Pause >50ms
Activate K2
Pause >50ms
(Laser is firing at this time)
Deactivate K2
(Laser still firing)
Deactivate K1
(Laser stops firing)

The way I am controlling K1 and K2 is by having the two relays mapped to the spindle control and mist control respectively.

So to activate/deactivate K1 I call M3/M5
to activate/deactivate K2 I call M7/M9.

I've written an m-function to mirror the laser firing sequence above in the hopes that I could link it to a button on the keyboard so the welder can do his spot welds.

I'm not on the correct computer to copy my screenset, but I am using the standard mill screen currently. The laser is attached to a 4 axis mill that I re-purposed from an old sherline hobby set up.
Title: Re: Keyboard M-function?
Post by: robertspark on November 11, 2015, 09:03:44 AM
OK... The whole tack weld macro... What have you called it?

M??

I'd suggest adding a button to the screen...

Then assign the macro to the button and also a keypress

Two options...

Do it yourself and I'll lead you through it. (In about 6 HRS time)... You will need to download and install machscreen on your machine (or a clone... I run a laptop as a clone and my dedicated machine lives in the garage)

Or send me your screenset, use a snapshot tool and show me where you want the button, what keypress you want and tell me what the tack weld macro is called and I'll do it for you this evening (UK time for me).

Rob
Title: Re: Keyboard M-function?
Post by: hermeticsj on November 11, 2015, 03:24:43 PM
Thank you for the offer Rob, I think I'll take you up on it. Sorry it took so long to reply, been a crazy day here today.

I've attached a snapshot of my screen set. I believe it is just the standard mach3 mill screen set as I haven't changed anything.

As far as where I'd like the button, I think it would go nicely in the box that now has the spindle speed. Our machine does not have a spindle at all so that information is unnecessary anyway.

A button for Laser Fire there would be great, and maybe a light indicating that the laser is currently firing (if possible).

The m function I have written is labeled as m1000 in the  mach directory. I think I'd still like the spacebar to be the keyboard hotkey though. I have wired an external pause button already (although I probably wouldn't have had I read the hotkey list before).

Thanks again!
Title: Re: Keyboard M-function?
Post by: robertspark on November 11, 2015, 08:59:18 PM
The LED won't work yet....

But the spacebar should run M1000

Can you send me your macro please (attached is one I did earlier...)


You will need to save the screenset (1024.set) to the Mach3 folder (c:/Mach3/)   
[I'd suggest renaming your existing screenset 1024.set to 1024-old.set .... that way you can always change it back .... should I have cocked it up!]

You will need to save the BackgroundMain-Laser.jpg to the following folder: C:\Mach3\Bitmaps\MillBitmaps

You will need to save the FeedHold-F.jpg to the following folder: C:\Mach3\Bitmaps\MillBitmaps

I've added my attempt at an M1000 macro for you that should run the LED .... but you will need to check and test it .... (if you have a working one .... send it across and I'll have a look or you can add the SetUserLED function to yours.... the if statement is kind of a safety feature.... dont want to be able to press the spacebar and the laser fires .... despite being in estop... or if the machine is actually moving.... hence you need to be stopped for it to fire (which is what I expected you wanted for a spot weld.

... you will need to add the Macro to the Macros folder ..... but within your profile (whatever you've called it) .... may want to change the name of your current one to M1000-old... just in case mine does not work..... suggest you have a look at it before trying it obviously...

Rob
Title: Re: Keyboard M-function?
Post by: robertspark on November 14, 2015, 04:59:13 AM
Did it work ... sort of what you wanted ... no where near?

If you need to modify the code the vb script manuals are here:
http://www.machsupport.com/wp-content/uploads/2013/02/Mach3_V3.x_Macro_Prog_Ref.pdf
http://www.machsupport.com/wp-content/uploads/2013/02/VBScript_Commands.pdf

machscreen here:

http://www.kd-dietz.com/klausphp/pages/eng/machscreen/tutorials/ms_tutorial.html

Title: Re: Keyboard M-function?
Post by: hermeticsj on November 16, 2015, 08:06:50 AM
Rob,

Sorry for the lack of information. To be honest I have not had a chance to upload the files and give it a try. I've been putting out fires at work for the last several days (the wonderfulness of manufacturing engineering). I'll see if I can get it online this morning barring anything else happening.
Title: Re: Keyboard M-function?
Post by: hermeticsj on November 23, 2015, 11:32:32 AM
Rob,
I was finally able to run the new screen set and spot weld macro. They work great! Thanks for all your help.

I do have another question though. Is there a way to add or rename and move buttons within the screen set? I'm trying to add a gas on/off button.  
Title: Re: Keyboard M-function?
Post by: robertspark on November 23, 2015, 01:34:54 PM
You can edit the screen using the screen editor I posted earlier.... But the background will need to be edited using a jpg (picture editing software...)

If you post what you want I'll see what I can do (screenshot / sketch ... Which output do you want to toggle, do you want a hotkey
Title: Re: Keyboard M-function?
Post by: hermeticsj on November 23, 2015, 03:06:58 PM
A button below the spot weld button would be perfect.

Gas ON is what the button will do. I guess to keep it simple the 'G' button would be a good hotkey for this function. The output that I have the solenoid plugged into is output 5.

Thanks again for your help. I'll have to post a video of the machine running as soon as I clean up the wiring and do a few test parts.
Title: Re: Keyboard M-function?
Post by: robertspark on November 23, 2015, 08:04:31 PM
Updated zip folder attached...

basically I've updated the screenset and I've added another macro (M1050) which will toggle output 5 on and off when you click the screenbutton or "G" key (note you can do this when the machine is running or not, as long as the eStop / Reset is cleared [probably something to watch]).  It does not have to be uppercase or lower case, just tap the "g" / "G" key, no Atl+code.... presume that is what you wanted (I could change this to ATL+G if you wanted a level of "safety" (multikey press) just let me know.

(all the other stuff is unchanged .... you won't need to update your images as they are the same, but included in the file to keep them as a pack).

So....
suggest you rename your current working "1024.set" .... to something like "1024-0ld2.set", that way you can go back to what you know works should I have messed up (think you have a previous working one from when we changed it last time).

Then copy the "1024.set" in the zipped folder into your Mach3 directory.

And add the" M1050.m1s" macro to your profile macros folder (same as you did with the M1000) and everything should work right.


If you're curious (or anyone else) I used the IsOutputActive to check the current state of output 5, and then if it was active used DeactivateSignal or if it was not ActivateSignal commands to toggle Output 5..... I could have just as well used DoOEMButton(236) to turn output 5 off and DoOEMButton(235) to turn output5 on having checked the state of output 5 using GetLED(78) with the same If statement.... same solution.
Title: Re: Keyboard M-function?
Post by: hermeticsj on November 24, 2015, 02:20:53 PM
That did it! There was a slight tweak I had to make because it appears that the space bar was mapped to the gas solenoid as well as the laser, so I just had to change that using the mach screen editing software.

Thank you very much for all of your help.

I have some clean up of the wiring to complete and need to order the argon gas regulator, but have that is all in place, I'll post a video of the final process.
Title: Re: Keyboard M-function?
Post by: robertspark on November 24, 2015, 10:57:58 PM
There was a slight tweak I had to make because it appears that the space bar was mapped to the gas solenoid as well as the laser, so I just had to change that using the mach screen editing software.

Oops... sorry thought I'd done it.... must have gone back in to MachScreen and had a play as I've just checked my file and it didn't work right either ... at least you got it sorted.

Yeah, it would be nice to see it working.

What size / type of laser are you using (argon mentioned so presume argon?) [know little about lasers... but interest me much the same]

Happy cutting.

Title: Re: Keyboard M-function?
Post by: hermeticsj on December 01, 2015, 08:33:44 AM
We are setting up a 70W laser (roughly the size of an American dishwasher) to weld metals together. Mainly stainless steel pieces. Actually this set up is going to be used to take over for some high volume stuff we do for the medical industry.

We also have 3 600W lasers that are riding on re-purposed HAAS machines. As counter-intuitive as it sounds, those machines are used to weld aluminum. Because of the high reflectivity of aluminium, higher power is required.
Title: Re: Keyboard M-function?
Post by: hermeticsj on December 03, 2015, 04:06:52 PM
Realized I probably didn't fully answer the question. The laser itself is an NdYg laser. We use argon to keep the seam weld from oxiding during the welding process.
Title: Re: Keyboard M-function?
Post by: robertspark on December 03, 2015, 04:10:18 PM
Thanks very much for that, very impressive.

Must admit... As I tig weld... I should have realised what you were using the argon for... But then I guess most people (like me ). Think of lasers as a cutting application and forget about the welding side too