component mist " "; description """ //Compile : //halcompile --compile mist.comp //sudo halcompile --install mist.comp //Halfile load : //loadrt mist //addf mist.0 servo-thread //setp mist.0.TimerOn 30 //setp mist.0.TimerOff 300 /* 4 way input Modul with Timercontrol output Input 0 = output 1 Input 1 && Input 2 = output 1 Input 2 && Input 3 = Timer On output 1 && Timer Off output 0 */ """; author "Chris@cnc"; license "GPL"; // Input pins pin in bit in0=0; pin in bit in1=0; pin in bit in2=0; pin in bit in3=0; pin in float TimerOn = 30; //this value can be overwrited by setp command. pin in float TimerOff = 300; // Output pins pin out bit on=0; pin out float timer=0; //output for debug // Global variables //variable float timer=0; function _; ;; #include "rtapi_math.h" FUNCTION(_) { if(in0) { on=1; } else if(in1 && in2) { on=1; } else if(in2 && in3){ // Timer timer += fperiod; if(timer <= TimerOn /*calculating on time*/) { on=1; } if(timer > TimerOn && timer <= TimerOff /*calculating off time*/){ on=0; } if(timer >= TimerOn + TimerOff /*Set Timer zero*/){ timer=0; } } else { on=0; } }