Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: daniba73 on November 09, 2018, 04:04:03 AM

Title: Add or edit Mach4 Lathe screen
Post by: daniba73 on November 09, 2018, 04:04:03 AM
Hi everyone

Is it possible to add a sound to the "Change tool" LED?
A simple "beep" at every impulse would be excellent.

Mach4 starts with a 100% slide Rapid Rate
Is it possible to change this condition and start with 25%?
Title: Re: Add or edit Mach4 Lathe screen
Post by: Cbyrdtopper on November 09, 2018, 10:34:25 AM
You can have your Rapid Rate Override set to 25% in the PLC script on start up.
Put this code in the PLC Script from the screen editor.


--Featured added 11-9-18
--Set RRO to 25% on start up
if testcount == 1 then
    mc.mcCntlSetRRO(inst, 25)
end


As far as playing a tone off the computer through speakers, I'm not sure, someone else would need to help you with that.

But, I have Stack Lights that have buzzers integrated in them on our machines here at the shop, you can use the "Tool Change" output in the mach configuration and map it to a relay that runs a buzzer or beeper.  You can get simple buzzers on ebay or places like Automationdirect.com. 
Title: Re: Add or edit Mach4 Lathe screen
Post by: rhtuttle on November 09, 2018, 02:20:42 PM
local snd=wx.wxSound('c:\\Windows\\Media\\chord.wav',0)
snd:Play()

HTH

RT
Title: Re: Add or edit Mach4 Lathe screen
Post by: Cbyrdtopper on November 09, 2018, 02:46:32 PM
RT,
So... snd:Play()   plays the sound.   
Does it play the file once and stop?
Title: Re: Add or edit Mach4 Lathe screen
Post by: daniba73 on November 10, 2018, 03:25:57 PM
Hi,
I report this error.
unexpected symbol near 'if'


acoustic signal instructions where should I enter?
if I put it in PLC it will only sound when I open Mach4.
Title: Re: Add or edit Mach4 Lathe screen
Post by: Cbyrdtopper on November 12, 2018, 11:18:26 AM
Sorry for the delay in response.
Make sure you put custom code towards the end of the PLC script.
That way you don't put it inside another section of code.
Also be sure that the comments have the "--" in front of them.  That makes it a comment in LUA.

I forgot you want this to sound during your tool change. 
You can still put this in your PLC Script.  But now, you will need to get the handle of the Tool Change Output.
When the Tool Change Output is active, play the sound.
I will see if I can get this to work on my computer in the sim and post my findings.
Title: Re: Add or edit Mach4 Lathe screen
Post by: daniba73 on November 12, 2018, 12:32:31 PM
Hi,
It's not a problem, I'm not in a hurry.
the error report was referred to this:

--Featured added 11-9-18
--Set RRO to 25% on start up
if testcount == 1 then
    mc.mcCntlSetRRO(inst, 25)
end
Title: Re: Add or edit Mach4 Lathe screen
Post by: Cbyrdtopper on November 12, 2018, 01:36:50 PM
That's the exact code I've got in my PLC script and it is working fine.
Did you put it at the end to make sure it isn't inside another bit of code?
Title: Re: Add or edit Mach4 Lathe screen
Post by: daniba73 on November 14, 2018, 10:34:20 AM
Hi,
Yes sure
I attach image.
Title: Re: Add or edit Mach4 Lathe screen
Post by: Cbyrdtopper on November 14, 2018, 11:01:27 AM
Hmm..
Try and take the code out of the PLC Script to see if you are still getting the error. 
I moved my code to the top of the PLC script to be sure it was still working; it is.

Title: Re: Add or edit Mach4 Lathe screen
Post by: daniba73 on November 14, 2018, 03:52:44 PM
YESSSS !! It works!!
I inserted script in the wrong page !!
now it's in the right place, it's all OK!
the translator helps a lot, but there is always a bit of difficulty in understanding well.
Thank you so much!!
Title: Re: Add or edit Mach4 Lathe screen
Post by: Cbyrdtopper on November 14, 2018, 04:45:05 PM
Awesome! Glad you got it working!
=)
Title: Re: Add or edit Mach4 Lathe screen
Post by: daniba73 on November 18, 2018, 03:52:19 AM
I noticed that the M8 function is deactivated only with M9 or the corresponding screen button.
Both the RESET and ENAMLE buttons do not affect the status.
Is it normal or BUG of Mach4?
Is it possible to assign an external button?
Title: Re: Add or edit Mach4 Lathe screen
Post by: Cbyrdtopper on November 18, 2018, 03:01:31 PM
No, it is not a bug.  That is how Artsoft set it up in the default system.
I always add stuff to the Reset Button.
I actually add a Reset Function to the Screen Load script called "Reset()"  I have a physical button on a control panel that I use as a Reset Button; then I put everything in this function that I want to happen when I hit the Reset Button.  
Things like Turning off the Coolant, Mist, Stacklights, Etc...
But you can just add some script to the Reset Button.
To turn off the coolant use this script (Check the syntax and the mc call, I'm out of Mach4 right now, but I think this is right.)

local Coolant = mc.mcSignalGetHandle (inst, mc.OSIG_COOLANT)
mc.mcSignalSetState (Coolant, 0)
Title: Re: Add or edit Mach4 Lathe screen
Post by: daniba73 on November 19, 2018, 09:24:05 AM
Hi,
Where should I enter this string?
also I would like to add to the RESET button stop coolant, how do you do it?
Mach4 is too complex to configure for many people.
Title: Re: Add or edit Mach4 Lathe screen
Post by: Cbyrdtopper on November 19, 2018, 09:43:57 AM
You will put it inside the Reset Button.
Same as you enter in the PLC or Screen Load, it is in the second tab in the feature box.
There will be some script already in the button, just add this at the bottom of it.

Mach4, like anything new, requires patience and time to get an understanding of it.
I had no idea how to do anything in Mach4 when it first came out; I took time to learn it and understand what things did and how it all worked, there are still things I don't know how to do, but I will learn them.
Title: Re: Add or edit Mach4 Lathe screen
Post by: daniba73 on November 19, 2018, 10:11:34 AM
surely I'm wrong ... I have a series of errors.
Title: Re: Add or edit Mach4 Lathe screen
Post by: Cbyrdtopper on November 19, 2018, 11:09:26 AM
What are your errors?
Title: Re: Add or edit Mach4 Lathe screen
Post by: daniba73 on November 19, 2018, 11:27:16 AM
I do not understand where you enter your string.


local Coolant = mc.mcSignalGetHandle (inst, mc.OSIG_COOLANT)
mc.mcSignalSetState (Coolant, 0)


in the RESET functions what should I write?
I attach image
Title: Re: Add or edit Mach4 Lathe screen
Post by: Cbyrdtopper on November 19, 2018, 12:01:41 PM
I had the Output handle wrong in the code I gave you.  I didn't think it was right, like I mentioned, needed to check that the signal call was all correct.
Put this code below the Set Last Error.

--Turn coolant off on Reset
local Coolant = mc.mcSignalGetHandle(inst, mc.OSIG_COOLANTON)
mc.mcSignalSetState(Coolant, 0)
Title: Re: Add or edit Mach4 Lathe screen
Post by: daniba73 on November 19, 2018, 12:17:11 PM
OK done.
now? what's next step?
I do not have to enter in the dedicated screen input?
Title: Re: Add or edit Mach4 Lathe screen
Post by: Cbyrdtopper on November 19, 2018, 12:45:42 PM
If all you want is for the reset button to shut the coolant off, then you're finished.  Just save that and test it. 
Turn your coolant on and press the reset button; it will turn the coolant off.
Title: Re: Add or edit Mach4 Lathe screen
Post by: daniba73 on November 19, 2018, 01:04:41 PM
tried on the computer at home and it works!
I try it on the lathe as soon as possible.

Is it possible to switch on or off with an external button?

Thank you for your great patience!
Title: Re: Add or edit Mach4 Lathe screen
Post by: Cbyrdtopper on November 19, 2018, 03:16:59 PM
Yes.   There is a thread on this forum with that information already.   But the searching isn't working right now.   I'll see if I can get some script I have on a machine on the is thread.
Title: Re: Add or edit Mach4 Lathe screen
Post by: daniba73 on December 04, 2018, 02:55:11 AM
Hi,
Can you give me a clue where to look for this thread?
why does the "search" function no longer work?
Title: Re: Add or edit Mach4 Lathe screen
Post by: daniba73 on January 02, 2019, 02:41:42 AM
Hi,
I had to suspend the tests due to work commitments.
Today I managed to turn on the lathe.
I entered the codes to disable M8 as described above.
I noticed that it goes off if I press STOP or RESET only with the muose on the screen of Mach4.
It has no effect if I press its external button on the panel.
How can I combine this function with external keys?
Title: Re: Add or edit Mach4 Lathe screen
Post by: Cbyrdtopper on January 02, 2019, 08:07:07 AM
You have to add that functionality in the signal library for the your external reset button.  
Title: Re: Add or edit Mach4 Lathe screen
Post by: daniba73 on January 02, 2019, 08:18:10 AM
Hi,
could you give me an example, please?
P.S I found a connection discussion.
now I can turn on / off the refrigerant from the external button.
I insert links, as help for other people.


http://forum.machsupport.com/forum/index.php/topic,38386.0.html
Title: Re: Add or edit Mach4 Lathe screen
Post by: Cbyrdtopper on January 02, 2019, 08:28:00 AM
That right there is your example.  
You've figured it out with this example, however, instead of having it toggle coolant on and off, just keep it off.
So in your Reset Button Input, just add this part of code:

         local OSigCool = mc.mcSignalGetHandle (inst,mc.OSIG_COOLANTON)
         mc.mcSignalSetState(OSigCool,0)
         --mc.mcCntlSetLastError(inst, "Coolant Off")  --(this is just a message keep this if you like.)

This will turn it off and not toggle it on and off.
Title: Re: Add or edit Mach4 Lathe screen
Post by: smurph on January 09, 2019, 11:19:30 PM
If just the reset button is all you want to use to turn the coolant off, then just add M9 to the Initialization codes in the configuration dialog.  These two strings of G codes will be sent to the control every time the reset button is pressed.  Or the mcCntlReset() API function is called. 

Steve
Title: Re: Add or edit Mach4 Lathe screen
Post by: daniba73 on January 16, 2019, 04:47:52 AM
OK, as you say it works.
the problem is that until you press ENABLE, the M8 function is active, so the pump works.
I would like Mach4 to start with the pump off.
Title: Re: Add or edit Mach4 Lathe screen
Post by: daniba73 on January 18, 2019, 05:49:49 AM
there is no solution?
how can I assign M9 (to turn off the refrigerant) when I press ESTOP?
Title: Re: Add or edit Mach4 Lathe screen
Post by: Cbyrdtopper on January 18, 2019, 08:21:14 AM
Put your E STop signal in the SigLib in the screen load script.

[mc.ISIG_EMERGENCY] = function (state)
    if (state == 1) then
       local Coolant = mc.mcSignalGetHandle(inst, mc.OSIG_COOLANTON)
       mc.mcSignalSetState(Coolant, 0)
    end
 end,
Title: Re: Add or edit Mach4 Lathe screen
Post by: daniba73 on May 05, 2019, 04:24:05 AM
I'm sorry, I forgot to answer.
IT WORKS!!
Title: Re: Add or edit Mach4 Lathe screen
Post by: MegaMoog on May 06, 2019, 06:51:00 PM
daniba,

(Is it possible to add a sound to the "Change tool" LED?
A simple "beep" at every impulse would be excellent.)

Did you get the sound to work when tool change led is flashing?
If so how... with details please

Thanks
Title: Re: Add or edit Mach4 Lathe screen
Post by: daniba73 on May 07, 2019, 01:55:40 AM
No sorry.
I didn't make any changes, I just left the LED.
I intended to parallelize a buzzer with the LED.
the two objects have different power supplies (led / buzzer) and I didn't know how to do it, so I left it unchanged.