You are not registered yet. Please click here to register!

plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
Try our online PLC Simulator- FREE.  Click here now to try it.

New Here? Please read this important info!!!

Go Back - Interactive Q & A > - Interactive Q & A > LIVE PLC Questions And Answers

Thread Tools Display Modes
Old November 5th, 2011, 09:38 PM   #1
United States

mike64b is offline
Join Date: Oct 2011
Location: richland
Posts: 77
PLC Sequence/Step Program for Motor Control, Is my logic correct?

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.

Attached Files
File Type: zip (13.0 KB, 149 views)
  Reply With Quote
Old November 6th, 2011, 05:32 PM   #2
Lifetime Supporting Member
United States

Lancie1 is offline
Lancie1's Avatar
Join Date: Jul 2003
Location: Alabama
Posts: 9,999
What version of RSLogix is your ZIPped *.RSS program?
  Reply With Quote
Old November 6th, 2011, 05:53 PM   #3
United States

mike64b is offline
Join Date: Oct 2011
Location: richland
Posts: 77
Rslogix Micro Starter Edition 8.40
  Reply With Quote
Old November 6th, 2011, 06:01 PM   #4
Lifetime Supporting Member
United States

bce123 is offline
bce123's Avatar
Join Date: Feb 2011
Location: texas
Posts: 1,177
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 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
"You can teach a dog to sit and lie down but then he justs gets lazy"
  Reply With Quote
Old November 6th, 2011, 08:03 PM   #5
Lifetime Supporting Member
United States

DamianInRochester is offline
DamianInRochester's Avatar
Join Date: Jan 2011
Location: Rochester NY
Posts: 1,282
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.
  Reply With Quote
Old November 6th, 2011, 11:10 PM   #6
Lifetime Supporting Member
United States

OkiePC is offline
OkiePC's Avatar
Join Date: Mar 2005
Location: ENE of Nowhere Oklahoma
Posts: 10,943
Somebody pdf it for us...No RSLogix here...
You've been taken, but you don't know it yet.
  Reply With Quote
Old November 7th, 2011, 12:02 AM   #7
Lifetime Supporting Member
United States

Mickey is offline
Mickey's Avatar
Join Date: May 2003
Location: Palmdale,Ca
Posts: 10,471
Originally Posted by OkiePC View Post
Somebody pdf it for us...No RSLogix here...
Here you go. Hope things didn't shake to much for you.
Attached Files
File Type: pdf MOTORCONTROL.pdf (31.5 KB, 176 views)

If you want happiness for an hour-take a nap. If you want happiness for a day-go fishing. If you want happiness for a month-getmarried. If you want happiness for a year-inherit a fortune. If you want happiness for a lifetime-help someone else.
----- Chinese Proverb
  Reply With Quote
Old November 7th, 2011, 10:52 AM   #8
Lifetime Supporting Member + Moderator
United Kingdom

daba is offline
daba's Avatar
Join Date: Jul 2004
Location: uk
Posts: 5,282
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.
Attached Files
File Type: zip (10.4 KB, 123 views)
ControlLogix & SLC Training
a-b train ltd.
tel: 07506 73 9999
Everything works with smoke. Let it out, and it stops working.

Nil Carborundem Illegitimi

  Reply With Quote
Jump to Live PLC Question and Answer Forum


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
Mitsubishi GX Developer - uploading/downloading program from PLC mkac LIVE PLC Questions And Answers 7 June 17th, 2010 05:31 AM
Need help in writing a PLC program to interface it with SCORBOT robot monahere LIVE PLC Questions And Answers 1 December 3rd, 2009 07:38 PM
Small PLC program needed...HELP.. mkalavitz LIVE PLC Questions And Answers 22 May 29th, 2007 10:28 AM
Simulator, Simulation, Shadow Code Terry Woods LIVE PLC Questions And Answers 1 January 2nd, 2005 02:40 PM
PLC Program Management zmanvortex LIVE PLC Questions And Answers 5 November 1st, 2004 11:03 AM

All times are GMT -4. The time now is 09:10 PM.