On Saturday 29 July 2017 12:10:31 Tomaz T. wrote: > I have air pressure switch to control if there is enough air pressure. > Now I would like that this is also condition for enabling machine to > run. > > I would need a little help how to correctly add this to hal.
This is not your problem of coarse, but you may be able to borrow the idea from this code snippet, which I did to cause a shutdown if I had left the spindle backgear in neutral. It works fast enough I don't have to stand there listening to the motor unwind before I can fix my screwup and resume the attempt to run my code. Warning long lines may wrap in your email agent! loadrt and2 names=estop_detect loadrt not names=not.load,not.spndl,estop_inv loadrt oneshot names=spndlmoving loadrt timedelay names=spndlcmddelay #======================later in file====================== #sequence the stopped spindle shutdown, maintain order here addf spndlmoving servo-thread addf spndlcmddelay servo-thread addf estop_detect servo-thread # a tristate_bit for backgear in neutral safety shutdown addf estop_inv servo-thread #==============and 375 lines later====================== # lets kill things if spindle on, but no motion # based on a delayed motion.spindle-on for starters setp spndlcmddelay.on-delay .2 # time to detect spindle movement setp spndlcmddelay.off-delay .1 net spindle-on <= motion.spindle-on => spndlcmddelay.in # to be delayed by on-delay # works, gives true when spindle turned on, so feed it to a tristate_bit called # estop_detect to enable it, net estop10 <= spndlcmddelay.out => estop_detect.in1 # next, is spindle moving? Needs turnaround time for g33.1 setp spndlmoving.width 0.4 #seconds it can stop w/o triggering a shutdown setp spndlmoving.retriggerable True setp spndlmoving.rising True setp spndlmoving.falling False net trigger_move <= hm2_5i25.0.encoder.00.input-b => spndlmoving.in # now feed the and2 net shutrdown <= spndlmoving.out-not => estop_detect.in0 net gateholderdown <= estop_detect.out => estop_inv.in net shutitdown <= estop_inv.out => motion.enable # shuts it down Now, I haven't a clue how you've wired your pressure switch, so I can't help there, but there may be an idea you can use in the .hal snippets above. Cheers, Gene Heskett -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) Genes Web page <http://geneslinuxbox.net:6309/gene> ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Emc-users mailing list Emc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-users