Suggestions on writing a generic peice of code

plcnovel

Member
Join Date
Feb 2006
Location
LHR
Posts
215
Hi there
I am trying to write a generic peice of code for some compressor applications. I would like write a code which involves less repetition. For example here are some of my thoughts......

I want to take a basic I/O list probablly in the form of excel sheet
Create the tags from this excel sheet of type lets say generic data type (a user defined datatype which will have all the members i need to execute)


Problem i am facing in my head is as follows: Lets say i create two tags called "Oil Pressure" and "Speed" of type generic datatype. Although they both will have access to all the members of datatype generic but when it comes on shutdown logic then i have to write shutdown for each point or tag indivdually which involves a lot of repitition. I want to avoid this by writing say a generic shutdown logic and somehow mapped this points to that logic......Is there any other way of doing it.....your help will highly be appreciated....thanks in advance
 
How "generic" you can make PLC code depends on the brand and model of the processor and the capabilities of the programming software. Some newer PLC software, such as Rockwell Contrologix and Processlogix, make it easier to reuse pieces of code routine. For most of the older packages, you are limited to using indirect addressing and indexed addressing.

All of these code-reusing routines can save programming time and make the program smaller, but in many cases when problems occur they cause the machine maintenance personnel many headaches and lost time trying to figure out how the program works.

How generic the code can be depends also on your goals and the goals of the person who is paying for the work.
 
Lancie1 said:
How "generic" you can make PLC code depends on the brand and model of the processor and the capabilities of the programming software. Some newer PLC software, such as Rockwell Contrologix and Processlogix, make it easier to reuse pieces of code routine. For most of the older packages, you are limited to using indirect addressing and indexed addressing.

All of these code-reusing routines can save programming time and make the program smaller, but in many cases when problems occur they cause the machine maintenance personnel many headaches and lost time trying to figure out how the program works.

How generic the code can be depends also on your goals and the goals of the person who is paying for the work.


If its Siemens it is, Control Logix can give you a headache in the scantime overhead if you use a routine as a sub routine.
 
PeterW said:
If its Siemens it is, Control Logix can give you a headache in the scantime overhead if you use a routine as a sub routine.

I've replaced all of my older (Pre-Vers. 16) subroutines with AOI's in Logix, and have noticed a slight decrease in scan time, but nothing worth really worrying about. Even with one or two hundred parameterized JSR's, going to AOI's has cut a few milliseconds off of the scan.

But... I LOVE the AOI's in Logix over standard subs for the simple fact that you can acutally open up the logic online for a particular instance of the AOI call, and see the data only as it pertains to that instance... woot... now THAT is sweet.
 
"AOI" = "Add On Instruction".

Rockwell finally put in some very good support in Release 16 of Logix 5000 to create your very own instructions, built up on parameters (data passed in/out), local (hidden) tags, and whatever logic you care to write.

AOI's are similar to subroutines, but not exactly, and can be versioned, have help associated with them (F1 type help), incorporate into the language toolbar, and can be source-protected (so end users cannot see the underlying code).
 
It sounds like you need reflection in your PLC program ;) Be careful with how "generic" you're going for. Don't overcomplicate simple tasks by generalizing when it's not necessary. As Lancie pointed out, this will cause more headache than it's worth. Your well written program will be at least partially reusable. Don't over-engineer it before you know what you're going for. If you have to ask it may be too complicated. Remember KISS! To quote my own footer - "Design Simplicity cures engineered complexity".
 

Similar Topics

I know this topic has been brought up a few times, but i had some specific questions. I have installed several 1783-NATR devices and they have...
Replies
3
Views
172
I'd like people's opinions on which manufacturer of hardware they prefer. We are an aerospace manufacturing facility that does little to no SCADA...
Replies
10
Views
528
I am setting up control for Hypochlorite dosing. The easy part is the dosing calculation for flow pacing but I would also like to setup trimming...
Replies
8
Views
944
I'm working on an application and have hit a bit of a snag. I need to find an industrial touchscreen display that can: - Tolerate down to -40C...
Replies
7
Views
755
Hello Everyone, I am reaching out to this knowledgeable community with a peculiar problem I've been experiencing with a PLC 5/40E. This issue has...
Replies
16
Views
2,273
Back
Top Bottom