I want ask a programming question.

Hello helloooo;

One suggestion, based on my experience in trying to teach PLC programming to PC programmers:

Start by designing a flowchart and/or pseudo-code for the applicarion you are developping, as if you were actually going to code it in your standard programming environment. Stop just before you actually start coding it in C.
Use the deveopped structure as a template for your PLC program, and start programming in a PLC language you know (ladder, structured text...)in a PLC you have experience with. You will save much time and frustration that way.
Hope this helps,
Daniel Chartier
 
I don't know if there are any tools to convert C to a specific PLC based language, but I'd suggest either:

1. Learn PLC programming techniques. http://www.plcs.net is a good place to start on this.

2. Use a microcontroller based solution and a C compiler built specifically for that microcontroller.
 
Start by designing a flowchart and/or pseudo-code for the applicarion you are developping, as if you were actually going to code it in your standard programming environment.



One of the biggest problems I had when I first started working with PLS was that unless you program in SFC, precisely this approach doesn't work! In your flow-chart, when you've been through a decision point and taken the appropriate action, that's the end of the matter. Not so in a PLC program in ladder STL or FB, next cycle ylong comes the PLC and repeats the whole business over again!

It took me at least three years, if not four to get half-way comfortable with this cyclic characteristic and even now, it occasionally bites me - usually when I'm playing with Timers.
 
Even if you can that doesn't mean you should.

Good advise so far. A translator is beyond the scope of this forum and most people. Also, C will not translate into ladder very well if at all. At best one would also need to put a lot of restrictions on the C that could be translated because ladder is just too crippled to do all the things that C can do. The best chance would be to translate C into structured text. Finally, all the different PLCs use different ladder logic.
 
I started my career as someone who knew C but not ladder. Early on I did a few embedded controllers using C, but learning ladder was inevitable, and for the most part, it was far easier to use for control. I suggest you take the time to expand your skill set so that you can design in both. It will probably take you less time to do that than to first write the program in C, and then attempt to translate it to ladder. Draw on your C experience to implement a sound top down design of the program, but go ahead and write it in ladder first.

Don't forget to check the resources here on this site, Phil has compiled some helpful information, and also here is a downloadable book that I think is very useful
http://forums.mrplc.com/index.php?download=156
 
Thank you all,

So now I know there is no software to convert C to PLC program. Actually, I know PLC program for sometime. Now I am studying C. So I wonder if C can help for PLC programming. I think at least it will help me to understand RSlgx 5000 better. I will read the comments carefully and try to absorb something. Thanks again!
 
Learning C will either cause you to develop some bad habits, or it will help you develop some good habits,

In my case it was both, I learned to swear, and I learned top down program design techniques. 🍺 However, no programming language refined my swearing skills more than VB.
 
Pure C, to do anything significant, relies on the programmer to be intimately familiar with the core system, it's OS, memory management, intelligent use of pointers, (good habits) OR will teach the programmer to rely on non-standard, platform dependant libraries, masses of global's, and functions that are in desperate need of refactoring (bad habits).

C++, with the STL (assuming your compiler supports it) almost forces good habits. Unless you are one of those people that must 'optimize std::string'.

In almost all cases, PLC programming is an entirely different animal. Even with the vast universe of instructions that go beyond the simple boolean algebra that is (ultimately) the foundation of even modern PLC's, the entire construct of PLC's is to execute a sequence of instructions, in (mostly) a linear fashion, to accomplish a specific goal. Inputs are extremely limited, and totally type constrained. The same for outputs.

Memory management really doesn't exist, in a sense, all variables are static. With the current generation, there is a differentiation between local and global scopes, but even that is minor.

Knowing any 'thoughful' programming language will help one to develop and debug a PLC program, but the usual paradigms don't necessarily apply.

The heart and core of even advanced PLC programs is simple boolean algebra. Decisions based on the result of that algebra might cause a call to a much more advanced function, but the advanced function is more like an API call than an actual integral programming construct to PLC logic.

I still find it the best, to do the 'Top Down' approach, with some changes. My first round of creating a PLC program is always to break the overall task (machine) down into discrete units, each of which could theoretically operate independent of the others.

Then, even before writing logic code rung 1, I try to decide the best method of organizing the data that I'll have to deal with for each unit. Ideally, I'll come up with either a User Defined Data Structure (UDT for Logix5000, DB for S5/S7, something else for other PLC's, word-boundry mapping on fixed file systems, etc) first. Even if there are memory locations reserved for a function the unit doesn't have (not every motor has a brake, for example, but every unit's data structure can handle engaging a brake, releasing it, and doing both in an automatic or manual mode).

Once the data structures are defined, the actual program logic seems almost trivial by comparison.

Hrm.

Maybe it's a lot like C after all :)


Alaric said:
Learning C will either cause you to develop some bad habits, or it will help you develop some good habits,
 

Similar Topics

Hi everyone! I've started to learn PLC programming (Simatic manager with plcsim (siemens s7 300). I read an interesting lesson on the internet...
Replies
5
Views
2,977
Dear All, I need help. I am new here & I don't know whether i join the right forum or not for asking this thing. My company...
Replies
14
Views
14,437
I have a program that I've used 100 times. SQO settings: File N7:0, Mask 0FFFFh, Dest B3:1, Control R6:0, Length 8, Pos 2. Length & Position...
Replies
48
Views
952
We are to develop a first application in Codesys. It will contain motion (Softmotion) with drives on Ethercat (CSP mode). Off course there will be...
Replies
2
Views
909
Hi. Rockwell learning curve 132-1b. I was having trouble to change IP address on a EN2TR. Finally found out that I need to change the IP...
Replies
1
Views
747
Back
Top Bottom