Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: KatzYaakov on May 22, 2023, 01:42:34 PM

Title: mcSignalWait
Post by: KatzYaakov on May 22, 2023, 01:42:34 PM
 local dhs= mc.mcSignalWait(0, mc.ISIG_INPUT2, 1, 10);
                           hreg = mc.mcRegGetHandle(0, "iRegs0/break")
                             val = mc.mcRegGetValueString(hreg)
                             val = tonumber(val)                
                             if(val==1) then
                           
                              return 100               
                                    end   
                      if (dhs ~= 0) then--if not rise up in 10 second   

end

atach one sample but there some that the single wait just not work
i cant say when  but in some cases its just run over ,not check the input and act like the input not ok without wait the second ordered
i think ill reaplace this function with simple loop that cheack input each...500 msec... or something like that
any coment?
   
Title: Re: mcSignalWait
Post by: Cbyrdtopper on May 22, 2023, 02:43:36 PM
You don't make the wait signal a variable.

I use the mcSignalWait all the time on tool change macros. 
Here is the example from the LUA Examples in the mach4 folder.


   local inst, hSig, rc
   inst = mc.mcGetInstance()
   
   hSig, rc = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT1) -- Get handle for output 1
   if (rc~= 0) then --Check our return call
      mc.mcCntlSetLastError(inst, "There was an error")
   end
   
   rc = mc.mcSignalSetState(hSig, 1) --turn on output 1
   if (rc~= 0) then --Check our return call
      mc.mcCntlSetLastError(inst, "There was an error")
   end
   
   rc = mc.mcSignalWait(inst, mc.ISIG_INPUT21, 1, 5) --Wait 5 seconds for input 21 to become active
   if (rc~= 0) then --Check our return call
      mc.mcCntlSetLastError(inst, "There was an error")
   end
Title: Re: mcSignalWait
Post by: KatzYaakov on May 22, 2023, 04:09:27 PM
you mean my mistake only because i use"local"?
i have in my m6 more then 5 inputs i need cheak ,and always i must give time out ,its cylinder need wait
and always i had problem
if my mistake is the decleraton "local "ill remove
thanks
Title: Re: mcSignalWait
Post by: Cbyrdtopper on May 22, 2023, 04:10:29 PM
Yeah. That looks like all it is.
Title: Re: mcSignalWait
Post by: KatzYaakov on May 23, 2023, 08:32:43 AM
sory i test also without ,not work
mny function that worked before maybi last version ui not sure
but all wait signal some times work some times m function ignore ...some stack real real disaster
Title: Re: mcSignalWait
Post by: Cbyrdtopper on May 23, 2023, 08:38:36 AM
I would revert to the version that was working then and let NFS know there is an issue with the version you are having issues with.
Title: Re: mcSignalWait
Post by: KatzYaakov on May 23, 2023, 08:43:47 AM
its complex becaus i play so much with all function ,i was so confused about this crazy beheivior until i found its all when  need wait
its not wait but continiue run ...
Title: Re: mcSignalWait
Post by: KatzYaakov on May 23, 2023, 11:46:29 AM
I test again delete all my crazy test ,at the end you totally correct it's only this  "local" declaration ... thanks alot alot
Title: Re: mcSignalWait
Post by: joeaverage on May 23, 2023, 07:32:51 PM
Hi,
there was a time ,some five years ago now, where mcSignalWait did not work for signals with signal number above 64.

I think ISIG_INPUT64 is signal number 64 but ISIG_MOTOR1_HOME is signal number 66. At that time it did not work.
I think I manged to surprise smurph that it did not work.....and do believe that has been rectified, but it would pay to check.

Craig