Can someone take a look at this code for me?

Pooty

Member
Join Date
Feb 2020
Location
Reading
Posts
4
I recently made up some code to practice indexing and was told there was no way it would work. The code is as follows.

731582583901a953.png



Oil_Complete is a latched pushbutton from the panelview that unlatches in the code so we can skip over unused steps. I just wanted to know if this could work or if someone can put me in the correction direction in making this work. I have no access to a PLC to test this on at the moment. The broken-down, longhand version of this code looks like this.


731582583099cb80.png



Any help would be hugely appreciated! Thank you in advance!
 
Last edited:
It part of an overall step counter in a process. Once we get to step 10, oil gets added into the product and step 11 is when product gets mixed in for a set amount of time. Up to 10 oils get added and I didn't want to have to add each identical step in the code so I made an index to cover all 10 oils. Is there a better way to do this?
 
Are you asking if your abbreviated version will be equivalent to your 'long form' version? Or if the overall step system will work?

Your abbreviated version looks different to the long version. Think of what happens to that timer when you're in step 10. As soon as your in step 10 the timer starts. I am guessing for step 10 you have 0 in the sp array and then some time in the 11th member of the array. The timer however will have already been DONE during step 10, so even if you load something higher than accum into pre in step 11 it won't start again. You need to actually reset the timer to get it to time again.

Either way, if it works or not the second example is still MUCH more readable and sensible. I don't like the idea of having anything other than an equal operator on the each rung for a state machine like this.
 
I know that the second way is much more readable, but I wanted to experiment because I'm relatively new. I know that the way I did it in the short-hand version is unnecessary for the project I'm doing now but I just wanted help with learning how to effeciently index for future projects. The values in for the arrays and timers would be entered by operators so they would not be 0 unless they were skipping that step, in which case the code would skip past the timer and setpoint all together until it gets to a step that has a value for the setpoint or it reaches step 30. I'm just making sure this is what the code would be doing and I'm not way off the mark with my logic
 
When you have an array of timers like that things can get confusing. I just tested it here and switched an array of timers and you can kind of end up with no way to reset the timer without manually doing it. It also might work the first run but not any run after that. I would avoid using indexes with arrays of timers
 

Similar Topics

So i made this thread yesterday. http://www.plctalk.net/qanda/showthread.php?t=111208 and i decided to give it a shot and work little by little...
Replies
5
Views
2,148
ok... was wondering if anyone might help me by taking a look at my program and telling me what they think. I attached the .prj file from...
Replies
9
Views
2,163
Hi all, I'm struggling to understand a bit of code at the very start of an FB. OPN DB 100 AN M215.5 L DBW 452 L 1 +I T DBW 452 = M 215.6...
Replies
12
Views
2,729
OPN #base L DBW [#state_bits] L 1 AW L 1 <>I JC stat I don't get a ar1 ar2 movements and else. Tnx Marek...
Replies
11
Views
2,282
Hello, Can someone please convert a .RSS program file to a PDF? See attached. It's from a MicroLogix 1200 system. Thank you! Michael
Replies
2
Views
3,889
Back
Top Bottom