I am using the EZWire-1616.
I am using the edge triggered interrupts to terminate a stepper motion on the edge of a limit switch. I am running the stepper at a very low step rate with no acceleration. This way the StepStop command will stop the motion as close to the edge event as possible w/o the stepper losing position.
If I do this without using the interrupt system the the stepper can be 50 steps past the edge event as I am limited by the ladder logic scan rate. Without using interrupts, I have to issue a one-step motion command to detect the edge event. These steps are limited by the ladder logic scan rate. I can get 20..50 pps out of ladder logic. My stepper hardware can run at 1000 pps and be stopped with StepStop without losing position. ISR edge detection saves about 8 sections for each stepper based positioner.
If I had 4 additional INPUTS, I could wire 2 PLC inputs in parallel for each limit switch input. This would get me both ISR and ladder logic visibility to the limit switches. I will still have to disable the ISRs either by disabling them or substituting a non functional CF for those times when I don’t want the stepper system to be stopped on edge events on the limit switches.
What how I think that the PLC handles INPUTs and INPUT interrupts:
- Physical INPUT states are scanned and registered once per scan of the ladder logic. If an INPUT is acting as an interrupt source it’s valve when viewed by ladder logic is always 0, independent of the voltage on the INPUT pin.
- INPUT interrupts are handled synchronously to the ladder logic scans. I believe that these are handled directly by the PLC’s CPU. My ISR sets a RELAY to indicate that the edge condition was detected. My ISR, also turns off the INTERRUPT system for the the INPUT before exiting.
- Ladder logic contacts, INPUTS included, can be differentiated or edge sensitive. To detect an edge requires 2 successive scans of the ladder logic.
- I suspect that it takes 2 full ladder scans to get the INPUT state correct after an INPUT interrupt is turned off. But because of the asynchronous behavior of the ISR, it may take a 3rd scan of the ladder logic to get the INPUT working. My test code counts the number of scans from when a rising edge ISR runs until ladder logic detects the the INPUT is non-zero. This code sees 2 full scans for about 9 out of 10 tests and 3 scans about 1 out of 10.
I don’t think that I am observing contact or switch bounce. I disable the ISR in the ISR routine. I would like to believe that your system level code would disable the CPU ISR before the PLC ISR code exits. Even if the ISR executed 2x, the PLC code will see only a single event from the ISRs.
I believe that waiting 3 scan times following the ISR detected edge event will allow the PLC INPUT logic to return to "normal" (digital filtering is working), differentiated INPUTs working, …
As you know, I am just guessing how the PLC operates. I am just picking your brains to see if I am missing something. I appreciate anything that you can think of.
Regards,
Gary Dickinson