Host Engineering Forum
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 21, 2012, 07:19:34 pm


Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Program critique...  (Read 1077 times)
Al A
Newbie
*
Posts: 3


« on: October 30, 2008, 06:25:20 pm »

Hi all,
 Firstly, I realize this forum seems to focus on the DS software and what follows is more "general PLC" stuff. If this is inappropriate here, feel free to direct me to a more appropriate forum. (Thanks!)

 Anyhow, I am just getting into the whole PLC thing. I am doing a project at work that involves some automation, and this seems to be the best way to go about it. I have some time that I am using to get up to speed on all of this. I have some programming experitnce, but that was some time ago and mostly machine language on microcontrollers. I have some long-ago familarity with ladder logic, but that was with very simple (and old) systems, and was implemented using real relays, timers, etc.

 I will be using an AD DL06, which is a bit of overkill for the application, but not much and it will allow for future upgrades and the feature expansion that tends to happen on these sorts of projects. I have the PLC at my desk and have been fooling with it and the DS5 software for a bit. I am planning to use the stage programming approach and have been reading and studying a bit about that. In the AD manual for the DL06, there is a good tutorial on the subject. The example they use is a garage door opener (page 7-8 of volume 2 in the DL06 manual). I thought it might be a good mental exercise to try to work out a program to implement the same garage door functions using "regular" ladder logic  before delving into the whole Stage programming concept. Mostly to see if I could.

 I have exported the program and it is pasted below. It works as it should, which was pretty satisfying once I got that far. What I would appreciate is if any of you pros, gurus, and mavens could critique my program a bit. Maybe point out what could have been done better, easier, simpler, faster. What about my program might indicate that it was written by a beginner? Am I overlooking anything?
Comments or criticisms, please? Thanks for any insight!

-Al

*******************Program follows************************************************
PLC 06

// Rung 1
// Address 0
#BEGIN COMMENT
"Rung opens the door when the button is pushed, "
"assuming the door starts from a fully closed position."
"if the door is neither fully opened or closed, it opens"
"X3 is a photocell safety switch"
#END
STR X0
AND X2
STR X0
ANDN X2
ANDN X1
ORSTR
OR C0
ANDN X1
ANDN C1
STR X3
AND C1
ORSTR
OUT C0

// Rung 2
// Address 13
STR C0
OUT Y0

// Rung 3
// Address 15
#BEGIN COMMENT
"Rung lowers the door when the button is pushed, "
"assuming the door starts from a fully open position."
#END
STR X0
AND X1
OR C1
ANDN X2
ANDN C0
OUT C1

// Rung 4
// Address 21
#BEGIN COMMENT
"This rung keeps the light on for 15 seconds after the door opens or closes."
#END
STR C1
OUT Y1

// Rung 5
// Address 23
STRND C0
ORND C1
OR C2
ANDN T0
OUT C2
TMR T0 K150

// Rung 6
// Address 31
#BEGIN COMMENT
"rung turns on lamp when door is opening or closing, and To keeps it on for 15 seconds "
"after the door stops moving."
#END
STR C2
OR Y0
OR Y1
OUT Y7

// Rung 7
// Address 35
END

// Rung 8
// Address 36
NOP


#BEGIN ELEMENT_DOC
"UB0","x0","",""
"UB1","to","",""
"X0","Operator button","",""
"X1","Up limit sw","",""
"X2","Down limit sw","",""
"X3","Safety switch","",""
"Y0","RAISE DOOR","",""
"Y1","LOWER DOOR","",""
"Y7","LAMP","",""
"TA0","light","",""

#END


 

 
Logged
franji1
Bit Weenie
Host Moderator
*****
Posts: 1034



WWW
« Reply #1 on: October 31, 2008, 09:20:30 am »

You'll get some feedback here, but you should also post it on AutomationDirect's forum http://forum.automationdirect.com/, probably under General Applications category.

There is more traffic there, so more eyes, and more comments, will be had.
Logged

Al A
Newbie
*
Posts: 3


« Reply #2 on: October 31, 2008, 02:51:45 pm »

Thanks, I appreciate the suggestion. I'll try that.
I appreciate your taking the time to reply.
Al
Logged
milldrone
Full Member
***
Posts: 38


I'm changing my attitude to thumbs up


« Reply #3 on: November 01, 2008, 09:05:47 am »

Al,

I did not see a post over at the AD forum so I'll reply here.

I had a little trouble importing your program monics because of the
"UB0","x0","",""
"UB1","to","",""
in the documentation area.

I only saw two/three things that could be construed as a possible programming style vs correctness thing.
1. You could replace every instance of "C0" with "Y0", and delete rung #2
2. You could replace every instance of "C1" with "Y1", and delete rung #4
3. Most of the control people I have been in contact with would wire the door limits so they were on when the door was midway, and off when the door was at it's limits. The reason for this is: if there was a wire break the door would not go beyond it's limit. 

Other than these nit pickey things your program passed the most important test of all, it worked. 
Logged

Vaughn
Al A
Newbie
*
Posts: 3


« Reply #4 on: November 01, 2008, 12:29:02 pm »

 Thanks for the reply. I had not gotten time to try posting this at the other forum yet, but will shortly.

 I'm not sure what is up with the monics, I am pretty sure they were just as DS5 exported them.

Thanks for those observations, not nitpicks at all.  That is precisely the sort of input I am looking for.
Wiring the limit switches to open at the limits is an excellent suggestion. Not that I am REALLY building a garage door opener,
you know, but that is a handy bit of design philosophy.

 I'll take a look at renaming the C0's and C1's and thus saving a couple of rungs. I "Might" have to look at what I was thinking
when I took that approach. I seemed to be over complicating things for some reason.

 Thanks again for taking tthe time to look this over and offer your suggestions. Most appreciated!

-Al
Logged
BobO
Host Moderator
*****
Posts: 1149


Yes Pinky, we *are* going to control the world!


« Reply #5 on: November 02, 2008, 12:41:11 am »

The strange entries are unassigned nicknames. Most troublesome is that X0 is defined as a nickname....which probably wasn't what you intended. Those will need to be assigned to actual image register locations.
Logged

BobO

The Constitution does not guarantee us freedom from being offended...but we can choose not to be, and life gets so much easier.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM