control applications in c

hyder

Member
Join Date
Jul 2010
Location
india
Posts
1
Dear all,in order to have plc functionality in pc's people go for soft plc's........i have seen companies like areva,and abb going for soft plc's like isagraf and kw-software...my question is why cant we simply write the control application in "C" and run them in pc.
 
Quick and easy and less error prone programming.
Quick and easy troubleshooting.
Online change.
Determinism.

The question should be, why anyone would want to use C, apart from the eventual familiarity what that language.
 
You can, we do, but then there should be some justification for doing so. Our applications we do can't be done with a PLC. In the 1980's I wrote assembly code on 'mini' computers and later wrote PL/M, assembly, and C code on embedded Intel boards.

I would look at PC-104 cards.

Quick and easy and less error prone programming.
Quick yes, less error prone? Not by a long shot. Much depends on the programmer.

Quick and easy troubleshooting.
Show me a PLC with a real time trace or log. Few even have single stepping.

Determinism.
Embedded controls have the edge here. There are concepts that good embedded programmers have know for years that have barely been touched on this forum.
 
Last edited:
Quick yes, less error prone? Not by a long shot. Much depends on the programmer.
It IS easier to screw up in C than in ladder for example.

Show me a PLC with a real time trace or log. Few even have single stepping.
For most applications, I think that the online viewing of Ladder code, makes troubleshooting with traditional PLC programming a factor 10 faster than C language, or even instruction list for that matter.

Embedded controls have the edge here [re determinism]. There are concepts that good embedded programmers have know for years that have barely been touched on this forum.
The comparison was "traditional soft PLC" vs "C language on a PC". Not PLC vs embedded controller.
 
You are going to wind up my integrator tight.

If you are simply going to use a PLC as a relay replacer the definitely go wit the PLC but......

It IS easier to screw up in C than in ladder for example.

For most applications, I think that the online viewing of Ladder code, makes troubleshooting with traditional PLC programming a factor 10 faster than C language, or even instruction list for that matter.
Tell me this again when we go a few months with out S7 question on how to use pointers and arrays. How do you do indirect addressing in LAD again? :)

Even ST or SCL is crippled compared to C or C++.

The comparison was "traditional soft PLC" vs "C language on a PC". Not PLC vs embedded controller.
It makes little difference. We use QNX too which runs on a PC. QNX just isn't windoze. We implemented MySQL as one of the tasks on one project. Do that on a PLC.
 
I think that to the OT the priority is to use a familiar language (C) on a familiar platform (Windows PC), since he suggested that as an alternative to isagraf and kw-software soft PLCs.
I might be wrong of course.
Enough for now.
 
Every language has its strengths and weaknesses.

Lets take something very basic. Testing a single bit and setting a single bit is easy in a PLC.

----] [---------( )---

LD A
ST B

In C its not difficult, but you have to program a mask, bitwise AND the source word with a mask, then test to see if the result is non-zero, then to set the result bit you have to construct another mask and then bitwise OR the destination word with the mask. Its not hard (#define some macros). But ladder does it better.

I've programmed a few embedded controllers in C and while I like programming in C, there are a few things, not many, that ladder kicks C's butt at. Those few limited strengths make up 90% of the kind of programming one does in ladder.

I like being able to bring the right tool to the job - one more reason I'm glad to see modern PLCs implementing more than just LL or IL languages and using structured data typing.
 
In C its not difficult, but you have to program a mask, bitwise AND the source word with a mask, then test to see if the result is non-zero, then to set the result bit you have to construct another mask and then bitwise OR the destination word with the mask. Its not hard (#define some macros). But ladder does it better.
Using masks and shifts are not necessary in C.
Simply define the bits within a word and simply write
bits.x=bits.y;
or
bits.x=bits.y or bits.z;
The C compiler will take care of the mask and shifting for you.

I've programmed a few embedded controllers in C and while I like programming in C, there are a few things, not many, that ladder kicks C's butt at. Those few limited strengths make up 90% of the kind of programming one does in ladder.
Waiting................
 
For me the question would be less of what language to program the application in and more who has to maintain the system. Not many maintenance people have ever worked with a higher level language like C or C++ let alone be able to understand it to the point of being able to troubleshoot a problem. Being able to see real time I/O functioning is something you don't have with the computer controled systems I've seen.
 

Similar Topics

Hello all, I know this is a very niche question, and a long shot. I'm in dire straits and I'm looking for anyone with some experience using Red...
Replies
1
Views
2,897
I am a student in a PLC class at a local community college. I am trying to write a paper on the practical uses of PLC's. Does anyone have some...
Replies
8
Views
2,727
Hi, Am working on my thesis in this above mentioned area. Whats the best place to start looking at programming in Function Block. Does anyone...
Replies
17
Views
8,475
I have to start out by saying I am not a PLC programmer and I have basic programming skills but mainly use software as a troubleshooting tool. I...
Replies
0
Views
49
Back
Top Bottom