BITS N BYTES Posted July 8, 2014 Report Posted July 8, 2014 Am working hard to learn and get proficient with this great new platform. Any suggestions how best to implement a state machine in the NJ controller that would function in a similar fashion to the STEP/SNXT instruction set in the CJ series PLC's. Any ideas most welcome. 1
Eradicated Posted July 9, 2014 Report Posted July 9, 2014 (edited) In general I really love the STEP/SNXT functionality in Omron controllers, I just don't understand why other manufacturers do not support something similar, i.e. ladder representation of SFC. That just significantly reduces code responsible for the state machine mechanics. Anyway, I believe that the most popular pattern for implementation of state machines it to program two dependent layers: one layer responsible for the state machine mechanics (i.e. you map the step number to corresponding coil that executes some actions, while also managing transitions from step to step) and the other responsible for the above mentioned actions - i.e. when step coil is active make some movement, turn on the pump etc. Once you get the picture it is quite efficient. On the other hand I've seen some state machines programmed in structured-text FB's (e.g. using case statement), but I'm not really a fan of such solution. Though, maybe somebody else knows something about more efficient ways of programming state machines in PLC-s, also taking into account the new capabilities of NJ-series. Edited July 9, 2014 by Eradicated
Andy_P Posted July 9, 2014 Report Posted July 9, 2014 I've used the Case method in ST for simple state machines and sequences, but once it starts to become large or complex it becomes hard to follow in my opinion. For larger sequences I have used ladder and used a simple step counter variable, comparing the value to determine which output to drive, transitions to check for etc.
PMCR Posted July 12, 2014 Report Posted July 12, 2014 I have a method that I have settled into after 20+ years of programming. I use the same method regardless of what type of Omron PLC (CP1L, CJ2M, CS1, NJ, etc) I am using. I define a register (or Tag in the case of the NJ) as a 'sequencer'. On startup, I move a value of &100 into the sequencer. That indicates that I am in a power up state, but nothing has happened yet. From there, I use comparison (=) instructions to check the current state, and MOV instructions to command the next state. I always start out incrementing my sequencer values by 20, so I can easily add steps in between. This makes debug very simple. If your machine gets 'stuck', you can look at the sequencer and see where it is stuck. It also makes jumping back to previous steps for 'retry' operations very simple. If I have subprocesses (robotic interface, etc), I spawn a subsequencer (different register) and use comparisons to determine when the subsequencer is finished.
BITS N BYTES Posted July 13, 2014 Author Report Posted July 13, 2014 PMCR thnx for feedback. Yes I am very familiar with this sequencer method and seen it used in many applications. Its BIG drawback as far as I am concerned is that all you see when programming/debugging is a change in the state number. SO, you have to have an external document referencing each state number to what each state actually does. With the STEP/SNXT method since each state is Boolean a unique name can be assigned to every state. See my post : http://forums.mrplc.com/index.php?showtopic=26261&st=0&p=125846&fromsearch=1entry125846 Now maybe there is a method in the NJ using a Structure, Union, Enumerations OR a combination of one or more of them that allows a unique name to be assigned to each numeric state!! Will take a look and see. If you can come up with one so much the better.
PMCR Posted July 13, 2014 Report Posted July 13, 2014 Agreed. Using individual bits has documentation advantages. You can use an enumerated data type to help shed light. I typically just use rung comments. Enumerations seem like extra work to me. I may try enumerated sequencers on my next NJ project, which will be mid August.
Michael Walsh Posted July 14, 2014 Report Posted July 14, 2014 This came up in another discussion as well, so I thought that I would post this here. Let's say that we are trying to sequence a very simple tray sealing application for the food industry and this is the simple process: Process: 1) Close tool with tray inside. 2) Vacuum out air inside tray to a setpoint. 3) Inject Gas. 4) Vent 5) Open tool You might build an enumeration that looks something like this: You might then have ladder that looks like this: The trickiest part of the whole thing is to remember that the variable Current_Step needs to be created with type "Sequence" (same name as the enumeration) to work.
SysmacUser Posted July 26, 2014 Report Posted July 26, 2014 CJ is very oriented to Ladder In NJ Ladder and ST are at same level, I assume you are taking advantage of InLineST function?... ST language has a very nice instruction ... CASE that is ideal for implementing STATE MACHINES... Please, check all the possibilities of CASE instruction... , and if you are Ladder fan... I suggest you to combine The CASE with InlineST instead of making 100% ST prog Additional tip... You can use ENUMERATION datatype in your CASE starement to define fhe state... So will make your prog easy to understand 1
PLCSteam Posted May 9, 2017 Report Posted May 9, 2017 Old thread but here's some samples I've come up with. http://forums.mrplc.com/index.php?/topic/32627-out-of-curiosity-is-there-a-way-to-make-ladder-execute-in-steps-linearly/#comment-153237
Gotyaa444 Posted December 22, 2017 Report Posted December 22, 2017 On 14-7-2014 at 9:37 PM, Michael Walsh said: This came up in another discussion as well, so I thought that I would post this here. Let's say that we are trying to sequence a very simple tray sealing application for the food industry and this is the simple process: Process: 1) Close tool with tray inside. 2) Vacuum out air inside tray to a setpoint. 3) Inject Gas. 4) Vent 5) Open tool You might build an enumeration that looks something like this: You might then have ladder that looks like this: The trickiest part of the whole thing is to remember that the variable Current_Step needs to be created with type "Sequence" (same name as the enumeration) to work. Hello, I cant see the sample of this comment. Where can i find them ?
Michael Walsh Posted January 2, 2018 Report Posted January 2, 2018 On 12/22/2017 at 7:54 AM, Gotyaa444 said: Hello, I cant see the sample of this comment. Where can i find them ? @Gotyaa444: The website was updated a while back and some of the attachments were removed. They need to be repaired one by one as they are found. I have repaired the post. 1
BITS N BYTES Posted September 3, 2020 Author Report Posted September 3, 2020 On 7/14/2014 at 3:37 PM, Michael Walsh said: This came up in another discussion as well, so I thought that I would post this here. Let's say that we are trying to sequence a very simple tray sealing application for the food industry and this is the simple process: Process: 1) Close tool with tray inside. 2) Vacuum out air inside tray to a setpoint. 3) Inject Gas. 4) Vent 5) Open tool You might build an enumeration that looks something like this: You might then have ladder that looks like this: The trickiest part of the whole thing is to remember that the variable Current_Step needs to be created with type "Sequence" (same name as the enumeration) to work. I have been using this technique using enumerations to more easily identify each state during troubleshooting. My next challenge is how to show the string associated with each state on the NA HMI. Can and How do I reference the controller variable in the NA and display the string for each enumeration value? Can it be achieved using the enumerated variable directly from the controller OR must I create a brand new copy of the enumeration from the controller to the NA and use the integer value of the enumeration of the controller variable to control the enumerated text in the NA variable. Putting out this challenge!! ANY IDEAS FOLKS?
Michael Walsh Posted September 6, 2020 Report Posted September 6, 2020 You can reference the variable directly from the HMI. See below: Enumeration setup: Variable in NJ: Mapping in NA: Setup of data display: Simulation:
BITS N BYTES Posted September 7, 2020 Author Report Posted September 7, 2020 Many thanks Michael ! All good. Learning NA as fast as possible!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now