PLC Sequence/Step Program for Motor Control, Is my logic correct?

mike64b

Member
Join Date
Oct 2011
Location
richland
Posts
77
I've started writing a program and its a sequence of steps that it will go through. The sequence commands seemed a little complex to me so I opted to go with using counters/timers as well as 2 input bits that is set when a move operation is not being performed.

Basically I've got a motor controller that I pass a command to that will run a motor for a specific speed/number of steps. This is a two axis controller and each axis has a bit that is set whenever a move is not being performed. Whenever a move is commanded this input bit will be cleared and then reset when the move has complete.

Using this info, I created the Main ladder (LAD 2) as a set of rungs that given a certain bit set in a bit data file, it will set required parameters (given from an LCD) and do a JSR to the ladder which will perform the required step.

The JSR will go to LAD 5 in almost all the steps, so its a general sub routine that performs its logic based on the parameters set before the JSR. LAD 5 is the ladder I would like to make sure is valid logic.

The process of LAD 5 is as follows:
First we check to see that the Not Moving bits for Axis 1 AND Axis 2 are cleared and if the C5:0 accumulator value is equal to a preset value, If those are all true, we would do a COP to command the axis to go to home position, and then jump to the end of the ladder (this will eventually also change internal data so that in LAD 2 we would move to the next step rung).

Next, we check if axis1 AND axis 2 Not Moving bits are set, if they are, we would jmp to the end of the ladder, which skips the program until such time the move has completed.

Next, two toggle bits are checked if they are both clear, if they are, we initiate Motor2 move command (using a copy to the output), set the toggle1 bit, set the toggle2 bit, and then jump to the end of the ladder. This causes the axis 2 move to initiate and the axis 2 move bit to be cleared which causes the 0001 rung to skip the entire ladder until the move completes, at which point the axis 2 move bit will be set.

Once the axis 2 move bit is set, because of the toggle bits,rungs 0002 and 0003 are skipped over and we move to rung 0004. Here we again set an output via copy in order to command a move on axis 1. We then unlatch toggle2. If toggle3 is set, we start a counter. toggle 3 is then latched (toggle 3 exists to fix an off by 1 error ).

Now once we have finished rung 0004, the program begins from the beginning again and we skip the ladder until the move has completed. Once it has, because of the toggle bits we would go into rung 0003, this rung performs a similiar operation as rung 0002 except that it will run the axis 2 in an opposite direction. Once rung 0003 finishes, the program repeats and would eventually go back to rung 0004 and then 0002 and then 0004 and 0003 and so on until rung 0000 becomes true and we home the motor and set data such that the next subroutine runs in LAD 2.


The entire point of LAD 5 is to run motor 2 say 180deg CW, then increment 1 step motor 1, then run motor 2 180 deg CCW, then increment 1 step motor1, and repeat until motor 1 has been incremented a specific number of steps.

I hope i've done okay trying to explain this, I'm attaching my ladder program so hopefully if you follow along with the post it should make sense. I am just looking to confirm that my method will work.. it makes sense to me but I am a novice at this.

Thanks.
 
Are you wanting someone to run this on a plc? if so compile the rungs and i will run it on a 1100 or 1400 for you if you don't have a PLC handy.you might want some proxes or limits to ensure the axis is clear to move instead of just waiting on a timer? sorry don't have much time to look it over but I will make some if you get it to compile.
Best Regards, Steve
 
What controller are you interfacing to?

It seems over complicated.
It is also more difficult to follow with all the rung errors you have.
I would recommend taking a much more sequencial approach.

I would recommend coming up with a simple written sequence of operations or flow chart and post that.

Also of great importance is alarming and recovery. What happens when things don't go as planned? It seems as though you will be taking care of that as an afterthought. It is better to figure that out ahead of time, and develop your code accordingly.

Of course this is all just my 2 cents, and subject to all my own biases.
 
mike64b - From the file you posted, it appears to me as though you have a poor understanding of how the processor scans and evaluates logic.

It looks like you will be trying to execute each "step" of your sequence in a separate subroutine file, and while that is a technique that can be valid, it is fraught with potential problems. For instance, consider how you may make the sequence of operations jump or loop backwards, or even diverge into different sequence actions. Also consider that there is a limited number of program files available in the ML1200, and that also your controller may need more than 1 sequence!!

A much more common technique is to use an Integer data-table location as a "Step Number" for each sequence - each "Step" in your "Sequence" is waiting for the conditional reaction to the previous step, and when that is true, the sequence "steps-on" to the next step, or jumps to a specific step number. The logic that handles the sequencer step-on can be common, so a single bit can be used to increment the step number. This approach is more visible to anyone looking at the code, and the sequence can be followed for debugging very easily in one file.

I have attached a very simple example of a sequence that fills a tank to a level probe, inflow is controlled by a valve and a pump. I have kept the example simple so that you can understand the principles, but of course it can be expanded to include additional functionality, I have incorporated a "Step-Timer" that can be used to program delays, and for visualisation on a HMI or SCADA screen.

You will notice that the "Step-On" bit in the sequencer file is always an OTL, do you know, or can you work out why ?

Also the sequencer outputs (in this case the valve and pump), are driven in a separate file, by inspection of the step number. This keeps the sequencer file uncluttered, and allows an output to be on for a range (or multiple ranges) of steps.

Of course the 3 files that make up SEQ1 can be replicated for other sequences, and addresses modified accordingly.
 

Similar Topics

I have searched and most of the threads with this information are very old and none give a good example. basically i have ftview se running on a...
Replies
0
Views
971
I have searched and most of the threads with this information are very old and none give a good example. basically i have ftview se running on a...
Replies
1
Views
1,102
Im using a S7 Siemens PLC and I need to remote start a Fanuc robot in Style. What is the UOP sequence?
Replies
3
Views
2,530
Hi all, I am setting up a PLC for data aggregation from multiple remote sites (35-50). Before I get too far into this here is the equipment and...
Replies
15
Views
4,559
We have GE Plc 90-30 CPU 351, working in an injection machine. recently when we switch off the machine for more than 1 hour the machine stops in...
Replies
6
Views
2,378
Back
Top Bottom