Announcement

Collapse
No announcement yet.

Detecting RISING/FALLING digital input

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Detecting RISING/FALLING digital input

    I have your P1-15CCD1 connected to some momentary devices. Is there a way to detect Rising and Falling input besides polling.

  • #2
    While I don't "know" i'm pretty darn certain polling it the only way for an add-on module.
    An input connected directly to the micro-controller might be able to generate an interrupt, but not one on a module. The first (or one of the first) parts of a conventional PLC scan is polling all the inputs.

    Comment


    • #3
      Rather than polling in program loop, I have moved that part to a timer interrupt. In this way, I can catch rising and falling edges.

      Comment


      • #4
        Originally posted by Tinker View Post
        While I don't "know" i'm pretty darn certain polling it the only way for an add-on module.
        An input connected directly to the micro-controller might be able to generate an interrupt, but not one on a module. The first (or one of the first) parts of a conventional PLC scan is polling all the inputs.
        You are correct. Right now you cannot generate an interrupt from a P1000 IO module.

        If speed is a concern i.e. you have several points you are checking for change on; look into the bitmappedDiscrete and readBlockData examples. These each give faster methods of polling many channels. After you get that data it's fairly fast to compare to the previous read states and see if anything changed.

        Comment


        • #5
          There are many examples of edge detection and I'm sure Google will show you more than you care to look at. Essentially, you need to remember the previous state and compare it with the new state to detect walmart one whether it has changed. Remember to update the previous state afterwards ready for the next iteration.
          Last edited by welskein; 03-06-2020, 05:03 AM. Reason: spelling

          Comment


          • #6
            Almost a month late, but... and I guess if you know the PAC software, you know how to fill out the partial instructions in the drawing - and what correct DIs to use.
            I usually do ascii-art programming for quick one-off examples but this
            I have not tested this, but it passed the moist-gray simulator.
            I'll leave it as an exercise to the reader to decide when/if to trigger the whole thing
            Click image for larger version

Name:	Scan0002.jpg
Views:	118
Size:	150.3 KB
ID:	129067

            Comment


            • #7
              We just posted an example that shows how to detect when a P1AM input module changes from off to on and on to off.

              https://forum.automationdirect.com/f...ection-example

              Often, you don't need to know the state of a digital input all the time, but you just need to know when the input changes from one state to another. For example, you want to know when a button goes from OFF to ON. This is called state change detection, or edge detection.


              Comment


              • #8
                I looked for my arduino code for this.
                Two laptops later, it is still MIA.

                Comment

                Working...
                X