spatricks
Member
I am wanting to debounce an digital input in structured text. I am using connected componets with a MICRO 830 2080-LC30-24-QWB.
So I essentially want to debounce both HIGH->LOW transitions and LOW->HIGH transitions to account for ripple in our digital sensors.
I have the following code that detects transitions like stated above, the problem is the code will react to any momentary ripple. I am wanting to debounce for at least 1 second.
Could someone give me a code example that would debounce this for 1 second.
So I essentially want to debounce both HIGH->LOW transitions and LOW->HIGH transitions to account for ripple in our digital sensors.
I have the following code that detects transitions like stated above, the problem is the code will react to any momentary ripple. I am wanting to debounce for at least 1 second.
Code:
(*Digital Input 0*)
(*Check for 1-to-0 transition*)
UTIL_input0_f(_IO_EM_DI_00);
(*If 1-to-0 transition detected, send out alarm message*)
IF UTIL_input0_f.Q = TRUE THEN
DATA_inputONOFFSMSText := '';
DATA_inputONOFFSMSText := 'Alarm detected: Input 0 is OFF';
UTIL_SEND_SMS_2( TRUE, CONFIG_slotID, CONFIG_receiverList, DATA_inputONOFFSMSText);
END_IF;
(*Check for 0-to-1 transition*)
UTIL_input0_r(_IO_EM_DI_00);
(*If 0-to-1 transition detected, send out alarm message*)
IF UTIL_input0_r.Q = TRUE THEN
DATA_inputONOFFSMSText := '';
DATA_inputONOFFSMSText := 'Alarm detected: Input 0 is ON';
UTIL_SEND_SMS_2( TRUE, CONFIG_slotID, CONFIG_receiverList, DATA_inputONOFFSMSText);
END_IF;
Could someone give me a code example that would debounce this for 1 second.