Hello Guest it is May 09, 2021, 08:45:16 AM

Author Topic: enable output  (Read 1118 times)

0 Members and 1 Guest are viewing this topic.

enable output
« on: February 02, 2019, 05:35:50 AM »
Hi All ,

I am pretty new for mach4 but I started playing a bit with it i notice that the enable outputs to come all on at the same time mach3 use to be with some delay between enable1 enabe2 and so on
is it possible to have some delay between enable 0 enable 1 enable 3 like 1sec intervals 
Re: enable output
« Reply #1 on: February 02, 2019, 07:25:00 AM »
yes it is possible to do that. Mach4 has the following behavior when being enabled.

When the machine is first switched on the machine is disabled. That means that OGIG_MACHINE_ENABLE is low.
Machs core will ensure that the output signals OSIG_ENABLE0, OSIG_ENABLE1, OSIG_ENABLE2 etc are likewise set low.

When you hit the <Enable> button it causes an internal Mach action (Up Action) 'Enable On' as is seen in screen edit mode looking
at the event properties of the <Enable> button.

Looking at the <Enable> button properties, again in edit screen mode you can see that the 'Machine Enabled' signal is affected
by the <Enable> button.

Machs internal actions 'Enable ON' and 'Enable Off' are not available for us to see or edit. It is plain though that if the
function 'Enable On' is called (as signaled by OSIG_MACHINE_ENABLE) then OSIG_ENABLE0, OSIG_ENABLE1 etc are all
turned on pretty much simultaneously.

In order to have the axes enable in delayed fashion it is necessary to disconnect the 'Enable On' and 'Enable Off' actions.
That is possible, in effect the Up Action and Down Action events must be left blank. Note however that there is allowed
an Up Script and a Down Script. Thus you can write your own scripts which could turn on (enable) axes in a delayed
fashion. In essence your scripts run INSTEAD of Machs built in functions.

Given that you are new to Mach4 I'm wondering if you think its a good idea to delve into writing scripts this early?
I can imagine that if you had really big servo drives or something then staggering the enable signals might reduce
the in-rush currents but they would have to be huge servos to warrant such behavior.

If you think you absolutely need to do so then have at it. Otherwise just box on with Mach......the vast majority of
machining operations can be done WITHOUT having to write any special scripts and I suggest that's what you do.

There will come a time when you need something a bit different to the standard Mach offering and then by all means
write your own code, Mach4 is generously provided with the means to customize your installation. Customizing your
machine when it doesn't really need it however is a great way to waste a lot of time and make few if any chips.

My wife left with my best friend...
     and I miss him!
Re: enable output
« Reply #2 on: February 02, 2019, 09:00:03 AM »
If i'm not mistaken you can also go into: Configure Tab; Control; Motors Tab; and select your Motor0, Motor1...etc. And at the bottom right -"Enable Delay (ms)" you can enter a delay time there for each Motor Enable.
Re: enable output
« Reply #3 on: February 02, 2019, 09:22:29 AM »
Hi Craig,

Thanks allot for your detailed answer but i find and other way to do it i install a small timer and it is working ok
Re: enable output
« Reply #4 on: February 03, 2019, 02:02:17 PM »
Hi I received this script from cslabs and as I mentioned before I am pretty new for  mach4 I cannot figure out what is wrong with it it's a script for a signal tower light but mach4 doesn't like it . I am copying and pasting in the screen editor PLC scripting I hope doing it the right way
Re: enable output
« Reply #5 on: February 04, 2019, 01:16:14 AM »
that's a pretty ambitious script for a Mach4 newbie. Are you convinced you require such a feature/machine behavior?

What's more important.....making chips or having flashing lights?

My wife left with my best friend...
     and I miss him!
Re: enable output
« Reply #6 on: February 04, 2019, 01:41:17 AM »
Hi Graig,

of course i need to generate chips but this is a big industrial bed mill and i want to do it step by step the right way (it is 28t of steel ) any way I manage to make x y z axis moving correctly and the homing  and hard limits  also soft limits is automatically on after homing which is something i wanted too the only things left is spindle which I am waiting for a 22kw vfd from delta and also I need to set up the spindle high and low gear

i was trying to make the lights because i want to start understanding how the lua works I am reading a lot and seeing video but i still finding it a bit difficult for me VisualBasic c++ is better  because whatever i needed in mach3 i do .I need a lot of cnc retrofit toolchangers and so on

maybe i need to hire someone to come over to my factory to get me started

Re: enable output
« Reply #7 on: February 04, 2019, 01:51:48 AM »
OK that is a big mill and yes I can see that you need to be thorough.

When you say 'Mach doesn't like the script' what do you mean?
Does it compile?
Have you put it in a quarantined folder and single stepped through it?

Just pasting a complex script into Mach is not likely to give you a good result and you'll be left with absolutely
no way to diagnose any of it.

My wife left with my best friend...
     and I miss him!
Re: enable output
« Reply #8 on: February 04, 2019, 02:02:33 AM »
Hi ,

This Script is provided by professionals from CsLabs but at the moment who is helping me is busy and can help me at the end of febuary  so that script should work that is why i am confused normaly i never had issue with these guys so i am thinking i am making somthing stupid wrong  but as far as i know i am just copy and paste and when i try to compile i get this

Program starting as '"C:\Mach4Hobby\ZeroBraneStudio\bin\lua52.exe" -e "io.stdout:setvbuf('no')" "C:\Users\Public\Documents\Wondershare\CreatorTemp\.190B.tmp"'.
Program 'lua52.exe' started in 'C:\Mach4Hobby' (pid: 21848).
Debugging session started in 'C:\Mach4Hobby\'.
SignalTowerTest.mcs:41: attempt to perform arithmetic on global 'testcount' (a nil value)
stack traceback:
   SignalTowerTest.mcs:41: in main chunk
Debugging session completed (traced 0 instructions).
Program completed in 2.17 seconds (pid: 21848).
Re: enable output
« Reply #9 on: February 04, 2019, 02:25:34 AM »
well the idea is nice but just pasting in code tends to be problematic no matter who wrote it.

The first encounter (in your script) with the variable testcount is this:

local tick_1 = testcount % (Fast_flash_rate * 2)
local Fast_flash = false      
if (tick_1 >= Fast_flash_rate) then
   Fast_flash = true

But testcount has not been declared within your script so Mach treats it a global variable. It looks for it and finds it is
a 'nil'. Consequently any arithmetic performed using testcount as a variable will fail. Hence the error report.

Note that in the PLC script testcount is declared and without the 'local' prefix therefore testcount should be global, or at least
with the PLC scope anyway. The declaration is right at the top of the PLC script.

local inst = mc.mcGetInstance()
local rc = 0;
testcount = testcount + 1

I am somewhat bemused as to why testcount which has been declared AND initialized in the PLC is generating an error
when used within the scope of your script.

Further it looks as if testcount is being used to set a blink rate. Why the extra complication?

Additionally the PLC script is run every few milliseconds. Do you really want the PC to churn through this code
tens or hundreds of times a second?


My wife left with my best friend...
     and I miss him!