Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: soruud on September 21, 2018, 02:53:30 PM

Title: Mach4 Coolant Toogle Problems
Post by: soruud on September 21, 2018, 02:53:30 PM
Hi. I got a big problem when setting up panel button to toggle coolant on/off.
I tried to do it in PMC Ladder, but every time Mach4 starts my water pump starts as well :(
Then I tried to to it in screen load script, and the same thing happen.

This is my script:

[mc.ISIG_INPUT38] = function (state)
if (state == 1) then
     local inst = mc.mcGetInstance();
     local sigh = mc.mcSignalGetHandle(inst, mc.OSIG_COOLANTON);
     local sigState = mc.mcSignalGetState(sigh);
     if (sigState == 0) then
         local OSigCool = mc.mcSignalGetHandle (inst,mc.OSIG_COOLANTON)
         mc.mcSignalSetState(OSigCool,1)
         mc.mcCntlSetLastError(inst, "Coolant On")
     else
         local OSigCool = mc.mcSignalGetHandle (inst,mc.OSIG_COOLANTON)
         mc.mcSignalSetState(OSigCool,0)
         mc.mcCntlSetLastError(inst, "Coolant Off")
     end
end
   
end,


Please help me. What is wrong with my script? And why is my functions in PMC running without me pushing my button?
Title: Re: Mach4 Coolant Toogle Problems
Post by: TOTALLYRC on September 21, 2018, 05:56:07 PM
Hi Soruud,
PMC works great for me here. I have  used it to setup all of my panel switches.
You could attach you PMC code and I will take a look at it.

Mike
Title: Re: Mach4 Coolant Toogle Problems
Post by: soruud on September 22, 2018, 02:32:12 AM
Hi. I attached 2 of my attempts in an RAR file. I would very much like to try your PMC files. I guess it will be easy to adjust them for my setup.
Are you using Pokeys for buttons?

Title: Re: Mach4 Coolant Toogle Problems
Post by: TOTALLYRC on September 22, 2018, 07:01:23 AM
I will grab the files later tonight or tomorrow and post them.

Looking at your logic you are you using a closed contact (l\l )instead of an open contact (l l). If that doesn't match the wiring then it will start in the on position.

Mike
Title: Re: Mach4 Coolant Toogle Problems
Post by: thosj on September 22, 2018, 10:56:47 AM
Here are mine, M8 and M7, working from the screen start script Signal Library. You'd need to change the inputs, of course. I didn't compare to yours, but YOU can!


----------Mach4 Input 17 PoKeys Pin 17-----
----------Toggle Coolant M8----------------
[mc.ISIG_INPUT17] = function (state)
if (state == 1) then
     local inst = mc.mcGetInstance();
     local sigh = mc.mcSignalGetHandle(inst, mc.OSIG_COOLANTON);
     local sigState = mc.mcSignalGetState(sigh);
     if (sigState == 0) then
         local OSigCool = mc.mcSignalGetHandle (inst,mc.OSIG_COOLANTON)
         mc.mcSignalSetState(OSigCool,1)
         mc.mcCntlSetLastError(inst, "Coolant On")
     else
         local OSigCool = mc.mcSignalGetHandle (inst,mc.OSIG_COOLANTON)
         mc.mcSignalSetState(OSigCool,0)
         mc.mcCntlSetLastError(inst, "Coolant Off")
     end
end
   
end,

----------Mach4 Input 14 PoKeys Pin 14--
----------Toggle Mist M7----------------
[mc.ISIG_INPUT14] = function (state)
if (state == 1) then
     local inst = mc.mcGetInstance();
     local sigh = mc.mcSignalGetHandle(inst, mc.OSIG_MISTON);
     local sigState = mc.mcSignalGetState(sigh);
     if (sigState == 0) then
         local OSigMist = mc.mcSignalGetHandle (inst,mc.OSIG_MISTON)
         mc.mcSignalSetState(OSigMist,1)
         mc.mcCntlSetLastError(inst, "Mist On")
     else
         local OSigMist = mc.mcSignalGetHandle (inst,mc.OSIG_MISTON)
         mc.mcSignalSetState(OSigMist,0)
         mc.mcCntlSetLastError(inst, "Mist Off")
     end
end
   
end,


Tom
Title: Re: Mach4 Coolant Toogle Problems
Post by: soruud on September 22, 2018, 03:20:21 PM
Thank you very much. By the way it helped me to invert my contacts in PMC :)
Title: Re: Mach4 Coolant Toogle Problems
Post by: TOTALLYRC on September 25, 2018, 06:15:43 AM
As promised, here is my PMC file.

Let me know if it helps.
"NOTE: I renamed the file .pcm because it doesn't accept .pmc files ???

Mike
Title: Re: Mach4 Coolant Toogle Problems
Post by: daniba73 on January 03, 2019, 02:17:26 AM
Hi,
I'm also interested in this feature!
How can I reverse the status at startup in Mach4?
because it lights up with M8 in the ON state.
The E-STOP button has no effect on the status.
Can the functions be deactivated when the E-STOP button is pressed?
Title: Re: Mach4 Coolant Toogle Problems
Post by: TOTALLYRC on January 03, 2019, 06:23:30 AM
Hi Daniba,
Are you asking about this in the PMC or the signal library?
In the PMC, if you want it to be turned off by the E-stop, then you have to make sure that there is an e-stop contact in the rung of logic that controls your M8 device.
To reverse it's starting status, use the opposite contact, open versus closed. Post your PMC file and I will take a look.

If it is the signal library, then someone else will have to chime in.

HTH

Mike
Title: Re: Mach4 Coolant Toogle Problems
Post by: daniba73 on January 03, 2019, 11:54:45 AM
Hi,
I simply copied and pasted (modified only the pin) and inserted into the Mach4 script.
I tried to reverse the state, it has no effect.
It works, but starts with the ON state.
I am not able to use the PMC.
Title: Re: Mach4 Coolant Toogle Problems
Post by: thosj on January 03, 2019, 02:25:45 PM
Daniba,

Do you mean you copied and pasted MY code from above? Into the Signal Library of the Screen Start script? If so, I don't know why it works for me and not for you. The only thing I can think of, is that's a TOGGLE script. I have a MOMENTARY switch wired to the Mach4/PoKeys input. Each press of the button TOGGLES the coolant. If you have a regular switch in there you might need different code that doesn't toggle but simply switches the coolant ON in one state of the switch and OFF in the other.

I could, of course, completely misunderstand what you're trying to do/doing. If so, disregard.

Tom
Title: Re: Mach4 Coolant Toogle Problems
Post by: daniba73 on January 03, 2019, 03:08:09 PM
I have a CSMIO / IP-S.
the button works!
only drawback is that it starts in ON state when I start Mach4.
E-STOP also has no effect on the status.
Title: Re: Mach4 Coolant Toogle Problems
Post by: thosj on January 03, 2019, 04:34:41 PM
Do you have a momentary switch or an on/off switch? It's not some sort of normally closed momentary switch by any chance, is it? Most are normally open. If it is, you might have to change the code state to "if (state == 0) then", but I'm not sure if that would work.

Mine starts in the OFF state. Pressing the button turns in on, pressing it again turns it off. My switch is a normally OPEN momentary switch.

Disconnect your switch, does it still startup in the ON position? Did it startup in the ON position before you put the code in the screen start script? IF NO, then it's the switch somehow, isn't it?

Tom
Title: Re: Mach4 Coolant Toogle Problems
Post by: thosj on January 03, 2019, 04:48:57 PM
Also, on Mach4's diagnostic tab, is the input of your switch lit up on startup? If so, then the switch is closed or maybe you could change Active HIGH/LOW on your input to reverse it?? Grasping at straws here!!!

Tom
Title: Re: Mach4 Coolant Toogle Problems
Post by: Cbyrdtopper on January 03, 2019, 06:28:53 PM
Daniba73,
You have to make your e stop shut off outputs.
Put the input in your Signal Library just like an input. 
Then put the conditions, if E Stop = true or 1 then Turn stuff off.
Title: Re: Mach4 Coolant Toogle Problems
Post by: daniba73 on January 04, 2019, 06:06:35 AM
Hi,
even reversing the high / low status in Mach4 is not good.
the pump starts up until Mach4 is not active, then goes off.
this is the code.



----------Toggle Coolant M8----------------
[mc.ISIG_INPUT7] = function (state)
if (state == 0) then
     local inst = mc.mcGetInstance();
     local sigh = mc.mcSignalGetHandle(inst, mc.OSIG_COOLANTON);
     local sigState = mc.mcSignalGetState(sigh);
     if (sigState == 0) then
         local OSigCool = mc.mcSignalGetHandle (inst,mc.OSIG_COOLANTON)
         mc.mcSignalSetState(OSigCool,1)
         mc.mcCntlSetLastError(inst, "Coolant On")
     else
         local OSigCool = mc.mcSignalGetHandle (inst,mc.OSIG_COOLANTON)
         mc.mcSignalSetState(OSigCool,0)
         mc.mcCntlSetLastError(inst, "Coolant Off")
     end
end
   
end,
Title: Re: Mach4 Coolant Toogle Problems
Post by: Cbyrdtopper on January 04, 2019, 08:28:06 AM
Hang on,
If you close Mach4 does the coolant turn on?   
And when you open Mach4, does the coolant stay on until the program has fully loaded?
Title: Re: Mach4 Coolant Toogle Problems
Post by: daniba73 on January 04, 2019, 10:06:31 AM
when I open Mach4, M8 activates itself.
if I close Mach4, M8 goes off.
Title: Re: Mach4 Coolant Toogle Problems
Post by: Cbyrdtopper on January 04, 2019, 10:45:27 AM
Change this...

[mc.ISIG_INPUT7] = function (state)
if (state == 0) then

to this   Change the condition:  State == 1

[mc.ISIG_INPUT7] = function (state)
if (state == 1) then
Title: Re: Mach4 Coolant Toogle Problems
Post by: daniba73 on January 04, 2019, 11:01:48 AM

It was the first change I made, but without success.
Title: Re: Mach4 Coolant Toogle Problems
Post by: daniba73 on January 05, 2019, 12:16:59 PM
I tried to compare the code in the computer where I have the pantograph.
in that computer I have a Smooth Stepper Ethernet.
result:
the code works.
when Mach4 is fully loaded, M8 is deactivated.
the only drawback is that it gives an ignition pulse to the relay while Mach4 is charging, and this is not good.
so I assume it's a question of plugins.
are there any other alternative methods?
How can I connect the OFF status when I press E-STOP?
Can you give me an example, please?
Title: Re: Mach4 Coolant Toogle Problems
Post by: Cbyrdtopper on January 07, 2019, 09:10:17 AM
As far as the ESS goes.  I've got several here in the shop and anytime Mach is not opened all of my outputs are turned on; I don't know why, but it happens and I deal with it.  I added a toggle switch to turn my relays off.
As far as the EStop signals.
Like I mentioned earlier, put it in the signal library.  Instead of it being an input# for the signal, find the E Stop Signal ID and put it there.

[mc.ISIG_EMERGENCY] = function (state)
    if (state == 1) then
              --Conditions
    end
 end, 
Title: Re: Mach4 Coolant Toogle Problems
Post by: Stuart on January 07, 2019, 11:10:58 AM
Chad

I had the output on do dah but only on the spindle a couple of relays sorted that out by cutting the power to the spindle until the ESS powered .

Thinking about it now I am thinking that’s its down to how the system is powered up

Mine has the ESS powered from a 5vdc in the mill therefore the come on together and that will be before the pc has the ESS under its wing

Theory

Mill off
Power ESS
Power pc and start mach4

Then turn on the mill

That way the mach4/ESS will be in a stable running condition before the mill on

Just a 2 cents of thinks
Title: Re: Mach4 Coolant Toogle Problems
Post by: Cbyrdtopper on January 07, 2019, 11:21:38 AM
Stuart.  Not a bad way to do it, only I have all my power coming on at once from a button on the front of the machine.
This turns everything on at the same time.  Because of this, the relay switch I have works well.
Another way you could do it, and it sounds like something you have implemented, would be to use a charge pump.  That way until mach and the ESS are communicating the charge pump relay is open, then the relay could power the rest of the machine.

Title: Re: Mach4 Coolant Toogle Problems
Post by: Stuart on January 07, 2019, 11:33:05 AM
Chad

You can give the pencils out tomorrow for that deduction