Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 558183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:06:18+00:00 2026-05-13T12:06:18+00:00

How do you determine direction of inputs using ladder diagrams with a PLC? Meaning,

  • 0

How do you determine direction of inputs using ladder diagrams with a PLC? Meaning, how do you save the previous state?

Previous state of inputs. I need to determine direction that photobeams were activated.. forward or reverse. If they are activated in reverse, perform one action. If they are activated forwards, perform a different action. Inputs labeled 1 through 6. Normal direction is 1 through 6.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T12:06:18+00:00Added an answer on May 13, 2026 at 12:06 pm

    Here’s a simple implementation of a latch in ladder logic:

    |-----[ ]-----+-----------------( )--------|
    |    input    |                output      |
    |             |                            |
    |-----[ ]-----'                            |
         output
    

    and here’s one where you can reset the output:

    |-----[ ]-------------+---------( )--------|
    |    input            |        output      |
    |                     |                    |
    |-----[ ]-----[/]-----'                    |
        output   reset
    

    These form the fundamental building blocks for memory in ladder logic. I’m not sure but is this what you’re looking for?

    Usually a language implementing ladder logic will have higher level elements that implement memory such as D and T flip-flops. Read the documentation of your ladder logic implementation to see if they’re available.

    OK, from your comments it looks like what you want is:

    // Pseudocode:
    // a = sensor 1
    // b = sensor 2
    
    if (a) {
        a_triggered = true;
    }
    
    if (b) {
        if (!a_triggered) {
            REVERSE_DETECTED();
        }
        else {
            a_triggered = false;
        }
    }
    

    This assumes the sensors are close together such that the transition is 10->11->01 such that you can’t detect the travel direction while the item is triggering both sensors. Writing this declaratively:

    a_triggered = (a || a_triggered) && !(b_triggered && !b);
    b_triggered = (b || b_triggered) && a_triggered;
    reverse_detected = b && !a_triggered;
    

    Which translates to:

    |-----[ ]---------+-----[/]--------( )--------|
    |      a          |      c     a_triggered    |
    |                 |                           |
    |-----[ ]---------'                           |
    |  a_triggered                                |
    |                                             |
    |-----[ ]---------+-----[ ]--------( )--------|
    |      b          | a_triggered  b_triggered  |
    |                 |                           |
    |-----[ ]---------'                           |
    |  b_triggered                                |
    |                                             |
    |-----[ ]----------[/]-------------( )--------|
    |  b_triggered      b               c         |
    |                                             |
    |-----[ ]----------[/]-------------( )--------|
    |      b      a_triggered   reverse_detected  |
    

    Now you can use the reverse detected signal to do what you want. If your ladder language has latches you can do this cleaner:

    |                             _________       |
    |-----[ ]--------------------|set latch|------|
    |      a                     |         |      |
    |-----[ ]--------------------|clear    |      |
    |      c                     |_________|      |
    |                            a_triggered      |
    |                             _________       |
    |-----[ ]--------------------|set latch|------|
    |      b                     |         |      |
    |-----[/]--------------------|clear    |      |
    |  a_triggered               |_________|      |
    |                            b_triggered      |
    |                                             |
    |-----[ ]----------[/]-------------( )--------|
    |  b_triggered      b               c         |
    |                                             |
    |-----[ ]----------[/]-------------( )--------|
    |      b      a_triggered   reverse_detected  |
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to calculate the direction of dragging a touch, to determine if the
How can I determine the direction of resize operation? I tried googling that and
How can I determine using jQuery that a given element is above the top
I am working on a game using Corona sdk. I need to determine a
Possible Duplicate: Is there any way to determine text direction from CultureInfo in asp.net?
How can I determine the space used by a table variable without using DATALENGTH
How do I determine the size of my array in C? That is, the
Does anyone have an algorithm to determine the direction from one lat/lon to another
Possible Duplicate: How can I determine the direction of a jQuery scroll event? I
How can I determine the tilt location in the y direction on my iOS

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.