Problems with PTO Function - Micrologix 1100

So, if I am understanding correctly,
  • I would declare an integer, say N7:0, as "Machine Sequence" or something like that
  • When the system is against the Home limit switch, I would use the MOV command to move a value of 0 into integer N7:0 to signify that the system is homed/idle
  • When the Reset PB is pressed, I would use the MOV command to move a value of 10 into integer N7:0 to signify that the machine is in the process of resetting
Would I then use the value in integer N7:0/0 to essentially "lock out" other steps of the process so that only one can run at a time? e.g. by not allowing the "Start" sequence to begin unless N7:0 is set to 0?
exactly.

Btw, there are many canonical patterns that are used over and over again in ladder logic. The Start/Stop Circuit pattern, which you already know, is one of them. The main ones are listed here. One of those is called the Step pattern, which is another way to handle this. It is basically uses the Start/Stop Circuit pattern, with a seal-in to maintain a bit for a step in a sequence. I would encourage you to try that also.

However, when you think about it, use a MOV instruction behind some True/False logic, to move a step number into a state tag, is similar to a Start/Stop pattern in that it writes the bits for that step's value into the state tag when the value is something else (i.e. another step), and then the PLC does not change the value until the conditions are True for the next transition from that state, so the PLC effectively "latches" or "seals-in" the bits for that state's value into the state tag.

One big difference between the two approaches is this:
  • with the Step pattern using a bit for each step, the code must
    • both write a 1 into the bit for the step being transitioned to,
    • and write a 0 into the bit for the step being transitioned from
  • With the integer state tag, there is only one set of bits (the integer state tag), to hold all step information,
    • so when the code writes the bits for the integer value of the step being transitioned to,
      • that already takes care of overwriting the bits for the integer value of the step being transitioned from.
There are advantages to each, but if we are disciplined in isolating the logic for each transition, then the integer state tag is fairly easy to read, especially if we include process-focused comments. "Isolation" means grouping all the logic for each transition and each step together. For example, with a MicroLogix, we could isoate each step's logic in a different Program File (LAD 3, LAD 4, ..., LAD 255) for each step, and simply call, using the JSR instruction, each Program File from the MAIN LAD 2 Program File. It won't be perfect, but since each step typcially has just a few rung of logic, we are much less likely to get glazed eyes trying to understand what dozens of lines are doing and how they interact.
 
If you are making a state machine it is generally better to use a separate tag for requesting a new state and the current state. You put the logic for changing the state number at the bottom of the logic. You can put additional logic for restricting state changes and it makes sure that the whole program is scanned each time you change the state rather than racing through the transitions.
 
exactly.

Btw, there are many canonical patterns that are used over and over again in ladder logic. The Start/Stop Circuit pattern, which you already know, is one of them. The main ones are listed here. One of those is called the Step pattern, which is another way to handle this. It is basically uses the Start/Stop Circuit pattern, with a seal-in to maintain a bit for a step in a sequence. I would encourage you to try that also.
That list and the explanations are very helpful. I am out of the office today, but I will try restructuring when I am back (I don't have RSLogix 500 on this computer). I had originally tried using a different program file for each of the steps of the process with JSR's, but I kept getting myself into trouble. The main issue I had was that the PLC would jump back to the main routine, and an output within the subroutine would get stuck on, since the PLC was no longer jumping to that subroutine to update the output. I think that was just because of poor program structure on my part.
 
If you are making a state machine it is generally better to use a separate tag for requesting a new state and the current state. You put the logic for changing the state number at the bottom of the logic. You can put additional logic for restricting state changes and it makes sure that the whole program is scanned each time you change the state rather than racing through the transitions.
Would you happen to have a simple example of this? Like in an actual program?
 
That list and the explanations are very helpful. I am out of the office today, but I will try restructuring when I am back (I don't have RSLogix 500 on this computer). I had originally tried using a different program file for each of the steps of the process with JSR's, but I kept getting myself into trouble. The main issue I had was that the PLC would jump back to the main routine, and an output within the subroutine would get stuck on, since the PLC was no longer jumping to that subroutine to update the output. I think that was just because of poor program structure on my part.
you want the code to evaluate every rung in all routines on each scan cycle. the ones that apply to any single step in the sequence should not "do" anything as a result. That is where the Start/Stop Circuit pattern comes in (see the Step pattern):
  • a single event, e.g. a bit changing from 0 to 1, will Start a step,
  • a Seal-In branch will maintain that step as active even after the start even returns to its original state,
  • and another bit, e.g. the next step starting, will Stop that step.
 
Would you happen to have a simple example of this? Like in an actual program?
The only change is that, when it is time to change from step 10 to step 20, the code
  • does not write a literal constant value of 20 into the integer state tag,
    • e.g. a conditional EQU N7:0 10 XIC B3:0/0 MOV 20 N7:0 rung,
      • where N7:0 is the current state, and B3:0/0 is the trigger to transition from state 10 to state 20,
      • which could trigger a rung like this:
        • EQU N7:0 20 XIC B3:0/1 MOV 20 N7:0
      • to move to the next state (30) after state 20,
        • without ever evaluating the business logic of state 20
          • which might be a problem
  • but instead write that literal constant value of 20 into an integer next-state tag,
    • i.e. a conditional EQU N7:0 10 XIC B3:0/0 MOV 20 N7:1 rung,
      • So N7:0 maintains the current state,
        • and N7:1 holds the next state,
      • until ....
  • ... finally, after all sequence logic rungs have been evaluated,
    • i.e. an unconditional MOV N7:1 N7:0 instruction updates the current state with the next state.
So that accomplishes the same thing functionally, but ensures that the model spends at least one scan cycle in, and executes the business logic of, each and every state.
 
Additional benefits of making a state machine controller is that you can build in logic for:
Time in step
Maximum time in step (to fault or force transition)
Inhibit step change

If you have SCL/Structured text languages and are doing your state machine with a CASE you can have generic timers that can be configured at each state rather than specific step logic timers which are a PITA to do in ST.
 
but instead write that literal constant value of 20 into an integer next-state tag,
  • i.e. a conditional EQU N7:0 10 XIC B3:0/0 MOV 20 N7:1rung,
    • So N7:0 maintains the current state,
      • and N7:1 holds the next state,
    • until ....
  • ... finally, after allsequence logic rungs have been evaluated,
    • i.e. an unconditional MOV N7:1 N7:0 instruction updates the current state with the next state.
So that accomplishes the same thing functionally, but ensures that the model spends at least one scan cycle in, and executes the business logic of, each and every state.
I'm having some trouble wrapping my brain around this to get started rewriting the code. If you have an unconditional MOV N7:1 N7:0, how do you keep it from moving the value in the next state tag to the current state tag until the current step is completed? Wouldn't it move the next state tag to the current state tag after one scan cycle since there are no conditions to be met?
 
Wouldn't it move the next state tag to the current state tag after one scan cycle since there are no conditions to be met?
It will do so on every scan cycle. But the next state tag value won't be updated until the next condition is met, so this has no functional effect except on the first scan when a condition is met at the correct step. Moving a value of 10 into a tag that already has the value of 10 doesn't do anything.
 
A two-hand operation typically indicates a safety concern. Is there a light curtain or other safeguarding device in place to separate the safety zone?

Additionally, a reset should never trigger motion.

I won't be providing further advice until you can offer some assurance that proper safety measures are in place.
 
I'm having some trouble wrapping my brain around this to get started rewriting the code. If you have an unconditional MOV N7:1 N7:0, how do you keep it from moving the value in the next state tag to the current state tag until the current step is completed? Wouldn't it move the next state tag to the current state tag after one scan cycle since there are no conditions to be met?
What @plvlce wrote.

The value in N7:1 is not the next state that would be active if and when the current state is over. It is the state that will be active when the next scan cycle starts.

When each scan cycle starts, and also when that unconditional MOV N7:1 N7:0 instruction is evaluated during most, but not all scan cycles, the values of N7:0 (current state) and of N7:1 (state for next scan cycle) will be the same. Only if N7:1 is changed to a new value, because the conditions/events signifying the end of the current state are true/occur, will the unconditional MOV N7:1 N7:0 rung change the current state.
 
A two-hand operation typically indicates a safety concern. Is there a light curtain or other safeguarding device in place to separate the safety zone?

Additionally, a reset should never trigger motion.

I won't be providing further advice until you can offer some assurance that proper safety measures are in place.
These are all very great points! There are no light curtains in place currently, but they will be installed and verified to be working before this machine is released to production. The entire system will be enclosed except for the front side that faces the operator, which is where the light curtains will be. In which case, I guess I don't need the two-hand start. Right now, I have just been focused on getting the machine to cycle properly. I appreciate the advice on the reset as well. I will change this to say "HOME" instead. Thank you for the input and concern.
 
It will do so on every scan cycle. But the next state tag value won't be updated until the next condition is met, so this has no functional effect except on the first scan when a condition is met at the correct step. Moving a value of 10 into a tag that already has the value of 10 doesn't do anything.
Ok, I understand now. Thanks!
 

Similar Topics

I am having a problem with an OPTO22 Mistic 200 controller. The controller has been running flawlessly for 6+ years. Monday before lunch it...
1
Replies
4,582
Views
Hello! Im trying to get online with my Ultra3000 drive to backup the drive program. I haven't connected with one of these drives before. The...
8
Replies
272
Views
Hi all, I am developing a controller in Easy e4 using Structured Text, which reads a temperature, triggers an output then waits for a given number...
4
Replies
354
Views
Hello, I am editing plc code on Mithubishi L-CPU plc. When i compare offline project and online project it showed me mismatch in output of code...
6
Replies
447
Views
Hello everyone, I am an electrical/automation student, and I am currently learning PLC programming and HMI design. I have some experience with...
1
Replies
358
Views
Top