c/c++ useful skill for Controls guys?

KingPresident

Member
Join Date
Aug 2015
Location
Michigan
Posts
138
Seeing a lot of job ads that have that as a line item of desired/required skills. I have never had to touch c/c++ to be an effective controls guy. What would I use it for, and should I know it?

I may go into business for myself at some point in the future, but I'm at a company where IT would have an aneurysm if I tried to put a IDE on my gear.

For the end-game though, is it worth knowing?
 
In my opinion, anyone who programs anything for a living should have a working knowledge of ordinary C.

I still remember being told "stick with BASIC, this is too hard for you". I was twelve. It was another three decades before I picked up a used copy of "The C Programming Language".

The reason I think this is that C is sort of a benchmark. You can compare other languages to it, in syntax and data representation and execution. Learning C as an adult and being able to compare it to other languages was very helpful in understanding *those* languages and why they are different.

I ended up learning ordinary ANSI C so I could program in the C-like internal language of the Red Lion DataStations, and so I could program simple applications in Arduino microcontrollers.

I don't use it every day in my controls work; I use the IEC 61131 languages, and VBScript, and Python.

But I understand all of those better because I know the basics of C.
 
It takes a long time to learn C, C++ or C#. Plus you might want to decide which track you want to pursue. C/C++ for embedded applications or C#, Java, Python etc for the enterprise environment. I recommend the enterprise environment because it goes well with factory automation. You will need some DB skills as well. I started in UNIX C programming around 1990. I recommend starting with C. I get a lot of debate on that though.

I get a lot of debate on this also:

Is ANSI C an object oriented language?
 
Recommend learn C if you want to write embedded code for PLCs, motion controller, temperature controllers etc.
I would learn C# for writing HMIs but I am not a fan of C# because it is MUCH slower than C. C++ is good for writing compilers and other big projects that will run on a PC but C++ uses a lot of dynamic memory management that isn't suitable for embedded control in most cases.
For prototyping I recommend python.
 
If you are really serious about C programming you can check out some of these resources and advice.

1. Having a compiler that is easy to use and preferably free is key to making good progress. For most general C, C++, Objective C etc, the Apple Mac with XCode is great. Its a really nice IDE and compiles darn near anything. Mac minis are cheap.

2. Learn the data types first, then the instruction set. C is actually pretty small.

3. Next are pointers. The "address of" operator, de-referencing pointers, plus the concept of function pointers.

4. Move on to data structures and algorithms. At this point you are about 2 to 3 months in. So not bad so far. You already know what an array is. You will learn about arrays, linked lists, doubly linked lists, circularly linked lists, stacks, and queues, etc. You will use pointers extensively here.

5. Two of the most important concepts in programming are, function pointers and dynamic memory allocation. These are the real building blocks that the modern languages leveraged.

6. At this point I would recommend learning Posix threads and the concept of "inter-process communications". Also maybe purchase a micro controller and learn about taskers and OSes. Some keywords would be superloop, foregroud/background task, ISR(interrupt service routine), critical section. state machines, RTOS, etc. Other stuff: Berkeley Sockets, TCP/IP stack, etc.

7. Finally, check out the archives for Dr Dobbs Journal and the CC++ users Journal for tons of resources. They go back to the early 90s or before. Also Circuit Cellar is cool. these sites will point you to some of the best C programmers ever.

At this point you can decide if you want to stay in C or move to something like .NET or whatever. You will always have your C programming base though.

It's not easy, maybe a year or two of study.
Cheers
 
Last edited:
Seeing a lot of job ads that have that as a line item of desired/required skills. I have never had to touch c/c++ to be an effective controls guy. What would I use it for, and should I know it?

I may go into business for myself at some point in the future, but I'm at a company where IT would have an aneurysm if I tried to put a IDE on my gear.

For the end-game though, is it worth knowing?

I've noticed that WinCC has both VB and C scripting on the HMI's... knowing C (even the basic is helpful in understanding something like that if you ever come across it).
Also, C is in the sweet spot between high level and low level languages, it isn't Assembly, but it isn't VB or C# where a lot of stuff is hidden from you and developing in it exercises certain brain "muscles" that you otherwise wouldn't.

C also has pointers, which is the hardest part to understand, but once you do, it helps to think differently.

I think C should be the initiation language for anyone serious about taking electronics or computer science as it introduces you to the middle of the road where you can choose to go up or go further down whilst teaching you a lot of the basics. But I may be biased as it was the first language I learned.
 
IIOT of the future will definitely include programming with some type of a high level language!

I personally would recommend C and or a variations of C.

"This is just my opinoin"!
 
Is ANSI C an object oriented language?

My vote on this is no. A long time ago, I had a book titled something like Object Oriented Programming In ANSI C. It laid out a method for creating objects in C but everything was dependent on keeping all of the programmer made constructs in line and there were land mines everywhere.

I would say you can do OOP in ANSI C, but ANSI C is not an OOP language. For me, to be an OOP language, you better have built in classes.

I’m not a language guru but Swift looks to be a very nice OOP language. There is a wonderful free online class from Stanford about programming iOS in Swift taught by Paul Hagarty. I learned a ton about OOP concepts watching it even without doing any of the excercises or spending much time programming in Swift.
 
Last edited:
For the end-game though, is it worth knowing?

Yes (kind of) learn as much as you can it will only benefit you, I have never thought to myself 'I know way too much and should never learned that'.... I do not know how to program C but I can read it and make edits when needed, you will also come across many microprocessors and many programmed devices that you will need to work on, so get familiar with as much as you can same with PLC languages learn Statement, Function Block and Ladder and STL if using Siemens, I have also had to learn VB.
 
VB/VBA may be useful in my experience, if you have to work on RSView32 or FactoryTalk View SE HMI's. I did take a C class in school but I've never had to use it.
 
I've used VBA when creating a data collection program from PLC to Excel over DDE (resources were limited for that project, or I would have used an OPC solution). I've used python for scripting to help with things that indirectly relate to PLCs such as creating barcodes for labels that the machine reads. I have not used C in programming other than a derivative of C++ when programming an arduino. If you can learn the basics of it, you'll be okay. Also, for programming in SCL (Siemens) and ST (AB), then you'll be familiar and then you can start playing with arrays more efficiently and creating lookup tables and such in your PLC
 
Yes and no. C is a good language to learn. It used to be the language I used, but now I use Python. But even so, if you know C, you can easily pick up other languages such as Fortran, Pascal, Bash, visual basic, and Python. Python is a more useful language as it has a plethora of libraries and functions available. But learn C first. Get the K & R book, the C Programming Language. It is very small, but it covers the language completely. It is small because it tell you all the details, but it only explains them once, but clearly and concisely.

C++ is on my list of things good to learn, but not a need to learn, and not very useful for controls.

Here is my list of programming tools that are worth learning and are extemely useful.

1) C programming
2) Bash
3) Python
4) Regular expressions.
5) grep
6) sed
7) vi
8) Awk
9) DOS command shell.
10) Visual Basic

You probably won't see many employers asking for competence with regular expressions, but they are extremely useful. Grep is very useful for quickly searching for data in files. Regular expressions are the basis for the searches. Sed uses regular expressions to make short work of substitute and replace in files from a shell. Vi is an editor that uses regular expressions with the same syntax as sed to substitute/replace text. Awk is an obtuse language, but extremely powerful and very useful for extracting data from files or reformatting the format of data files. Unfortunately, Windows doesn't include bash, grep, sed, and awk. But you can install Cygwin to get them.


Here's a list of nice to know, but not normally needed for controls.
1) C++
2) Lisp - Useful if you use Emacs. Used to be very useful with AutoCAD for writing new functions and macros. Now, most of those type of functions are part of AutoCAD.
3) HTML - Not super useful, but handy for making basic help screens with links that you can use with a browser.
4) Perl - Some people like use perl instead of awk.
5) Java
6) C#
 
I've become a big fan of Python, you can do a lot with it relatively quickly and with minimal fuss. I spent quite a bit of time with Visual Studio and VB.NET. It's a fairly no fuss language that is great for making windows GUI applications.

And since proof mentioned regular expressions, someone recommended me an excellent site for debugging them: https://regex101.com/
 
My vote on this is no. A long time ago, I had a book titled something like Object Oriented Programming In ANSI C. It laid out a method for creating objects in C but everything was dependent on keeping all of the programmer made constructs in line and there were land mines everywhere.

I would say you can do OOP in ANSI C, but ANSI C is not an OOP language. For me, to be an OOP language, you better have built in classes.

I’m not a language guru but Swift looks to be a very nice OOP language. There is a wonderful free online class from Stanford about programming iOS in Swift taught by Paul Hagarty. I learned a ton about OOP concepts watching it even without doing any of the excercises or spending much time programming in Swift.

That book may be the one written by Axel Tobias Schreiner. He was at Bell labs with Dennis Ritchie and Brian Kernighan. I've read the book and it is outstanding and proves that ANSI C is an OOP language, but the actual definition of an OOP language is one that supports 1. encapsilation, 2. Inheritance and/or composition. 3. polymorphism. ANSI C does this.
 

Similar Topics

I am deciding on components for a bayed modular enclosure containing multiple VFDs (480V/350A/321Hp each) for a dynamometer. I am concerned given...
Replies
7
Views
1,672
I've been banging my head for a way to generalize data handling in a meaningful way in Logix. What I've concocted so far is the idea of "visitors"...
Replies
28
Views
5,423
I work for a firm that’s tied down to just a couple of older PLC types. Looking to the future I’m wondering what features particular brands have...
Replies
17
Views
4,706
Hy , so here is my problem. I what to make a program for a S5 100U PLC, the application consist in rejecting, lets say a blue cube, from a...
Replies
4
Views
1,736
Hi all. During a rummage in a dark and dusty corner today, I found an unopened RSLogix500 :) but the version was "one point something" :( (it was...
Replies
6
Views
2,058
Back
Top Bottom