PDA

View Full Version : Question


Unregistered
March 30th, 2005, 03:38 PM
PLC programming how is it different from linear
programming in languanges such as C, C++, Matlab and Java?

PhilipW
March 30th, 2005, 03:55 PM
Please feel free to register..it's free and the regulars in here a usually respond better to an ID rather than just "guest".

Questions posed that reveal the context of the query, get a better answer. We usually find that "one-liner", "left-field" questions like this are from students looking for some quick homework help.

Nothing wrong with this per se, but the way to present yourself in here is something like:

"I am a student....I've got this lamea** question posed by my tutor who couldn't program a PLC to save him/herself...this is what I think it means....and this is what I know "linear programming is"....and this is what I think the answer might be.....so how does this line up with what you guys know?"

At this point you will get a flood of helpful replies.

Regards

Unregistered
March 30th, 2005, 04:01 PM
Thank you for your response. I am student and I am looking for an answer for to this question:

How is PLC programming different from linear programming in languanges such as C, C++, Matlab and Java?

PhilipW
March 30th, 2005, 04:05 PM
OK. I am a dumba** PLC jock. What is "linear programming"?

davidg68124
March 30th, 2005, 04:21 PM
If I may interject here, maybe he is referring to 'linear programming' as a console application that is not multitasking or multi threaded. Something like a program that executes one task and one task only. Something that has no branches in the logic, maybe.

But needless to say, in order to understand PLC Logic, he must understand that PLC's have progressed from being a simple man's tool as many PC programmers probably feel about them. They do not realize they support not only Ladder, but Sequential Fuction Charts, Structured Text, and Function Blocks. The thing to remember for the average PC programmer is this, Ladder, Function Blocks, and SFC are graphical in nature. Structured Text is the only thing like he may be accustomed to.

This is the biggest difference, and oh yeah, we do not rely on Windows for an operating system!! We have a more stable platform, and with well thought out logical operations, we can perform tasks that will run for years.

David

rsdoran
March 30th, 2005, 04:52 PM
It is a unique question, what is linear programming? From what I gather it involves algebra.
Matlab is a high end technical languange and environment for algorithm development and more.
Java technology is an object-oriented, platform-independent, multithreaded programming environment.
C is a computer programming language. That means that you can use C to create lists of instructions for a computer to follow.
C++ is an "object oriented" programming language

Technically when it comes to machines they all use machine language which is unreadable by humans therefore assembly and/or a high level language is used. The high level programs like C, Fortran, etc use a compiler to translate the program into machine language. Assembly uses an assembler to convert to machine language.

Ladder programming is just a graphic oriented process that humans can read and write, the actual program is still converted to machine language for the plc to use. In some cases C or C++ can be used to program plcs.

What it boils down to in general is that the PLC uses machine language, people use high level languages like C/C++ etc to create programming software that will automatically compile the code for use.

Tom Jenkins
March 30th, 2005, 05:14 PM
What you refer to as linear programming is usually related to ether data manipulation, like calculations, or data management like a data base program. It's intent is usually to take input from a person and provide the output on a screen or printout for a person to use.

PLC programming is essentially for machine control. It takes inputs from the "real world", such as switches and sensors. Based on the program's logic the PLC uses the data to manipulate the real world, such as by operating valves or motors.

PLCs don't have the blue screen of death. A bug in the program logic can result in destroying a very expensive machine, or lost production in a factory, or even the death of a real person.

Unlike a PC program for database manipulation, for example, working with PLCs requires knowledge of the real world devices, the process and machine being controlled, and an understanding of basic electrical principles.

Rick Densing
March 30th, 2005, 05:38 PM
PLC programming unlike "step1 then step2" form of those languages, has every element executed continuously as the scan repeats. Special care must be made to create a sequence instead just what order you put your statements.

I remember that taking a little getting used to as I went from higher level programming like BASIC and Pascal to ladder.

bernie_carlton
March 30th, 2005, 06:03 PM
Let's compare a ladder program with a 'C' program.

1. The program is the only one the system will run.
2. The system generally starts running the program on startup.
3. Imagine the program as wrapped by the following processes

While (1) do
a. Read physical inputs and copy them to an array "Inputs"
b. Execute the program
c. Copy array "Outputs" to physical outputs
d. Perform system and communication functions
Loop

4. One of the 'system functions' is checking total time executing the ladder (watchdog timer). If that exceeds a certain amount the process faults (usually turning off outputs). Thus the code should not contain any internal loops or, if it does, they should take very little time.

The whole purpose of the ladder is, using "inputs" modify internal memory (numbers, states, counters, timers etc) and eventually modify the "outputs" array to cause a change in the external controlled device. Each execution of the Do-While-Loop takes a very short amount of time (typically 1/100th of a second). Memory of the previous loop is held in the numbers, states etc. There is typically no 'end' to the execution except when the PLC system faults or power is removed.

Lancie1
March 30th, 2005, 06:10 PM
Rick,

I think you hit upon a significance difference between linear programming languages and PLC logic: namely, from a PC program language perspective, a PLC program has a built-in automatic INFINITE LOOP, where as in normal programming, great pains are taken to avoid infinite loops. An infinite loop in the PC world is considered a big no-no and a sign of poor technique. In a PLC, the infinite loop is necessary and in fact if the loop is broken it is usually because of a fault or error condition.

Peter Nachtwey
March 30th, 2005, 09:59 PM
Rick,

I think you hit upon a significance difference between linear programming languages and PLC logic: namely, from a PC program language perspective, a PLC program has a built-in automatic INFINITE LOOP, where as in normal programming, great pains are taken to avoid infinite loops. An infinite loop in the PC world is considered a big no-no and a sign of poor technique. In a PLC, the infinite loop is necessary and in fact if the loop is broken it is usually because of a fault or error condition.

I guess I am guilty of p$ss poor programming and so are other people that write control firmware in C. Look at the while loop that Bernie posted. That is an infinite loop. Don't you want your PLC to run in an infinite loop? You do realize that this infinite loop is probably written in C or C++?

Infinite loops are just another tool or technique. You must use them correctly.

akreel
March 30th, 2005, 10:46 PM
My interpretation of "linear programming" would be that the program executes from start to finish and ends (unless you program a loop). This would be the old QBasic type stuff.

Of course, with Visual This and Visual That, everything is event driven now.

SimonGoldsworthy
March 31st, 2005, 04:31 AM
Re-wording the question, viz:

"How is programming a PLC different from programming in C etc."

make me think the question doesn't make sense. Please re-state the question in some other way.

rdrast
March 31st, 2005, 04:48 AM
Rick,

I think you hit upon a significance difference between linear programming languages and PLC logic: namely, from a PC program language perspective, a PLC program has a built-in automatic INFINITE LOOP, where as in normal programming, great pains are taken to avoid infinite loops. An infinite loop in the PC world is considered a big no-no and a sign of poor technique. In a PLC, the infinite loop is necessary and in fact if the loop is broken it is usually because of a fault or error condition.

Except, of course, for every single piece of windows software out there, which sits in an infinite message loop waiting to be event-activated by the operating systems :).

Actually, just about every program that requires the user to manually 'Exit' when they are finished is sitting in a "while (1) { wait for stuff, process it } infinite loop.

In the most strict terms, 'Linear Programming' refers only to creating a one-pass through program to find a specific solution to a problem; very much like following a recipe when cooking. One starts at step one, and at step x ends up with a result, whether it be the answer to a mathematical problem or a chocolate cake!

davidg68124
March 31st, 2005, 08:48 AM
Bernie's explanation makes the most sense to me. I was not as elegant in my answer.


The rest of you speaking of infinite loops, it is funny, that idea never even occurred to me. I am just so used to it, that I forget that is a difference.

Pointing out this as well, are not our control programs 'event driven'? I would think that many are.

I think this is a good question. It makes us all think about what we do.

David

SimonGoldsworthy
March 31st, 2005, 08:57 AM
Is the unregistered guest any the wiser ?

RMA
April 4th, 2005, 05:00 AM
PLC programming unlike "step1 then step2" form of those languages, has every element executed continuously as the scan repeats. Special care must be made to create a sequence instead just what order you put your statements.

I remember that taking a little getting used to as I went from higher level programming like BASIC and Pascal to ladder.



That's the biggest understatement of all time. After getting on for four years working with PLCs, I'm still not comfortable with it!

diony_com
April 4th, 2005, 05:54 AM
HELLO!

Im just concern person from Philippines! Absolutely PLC PROGRAMMING is DIFFERENT from LINEAR PROGRAMMING- they have contained a unique specific field of applications, unique registers, and unique form of handling reference.

Tnx..

DIONY
PLC programming how is it different from linear
programming in languanges such as C, C++, Matlab and Java?