Chapter 16: programming in c, Specifications, About the c language – Sensaphone SCADA 3000 Users manual User Manual
Page 187: Chapter 16: programming in c -1, Specifications -1, About the c language -1
16-1
Chapter 16: Programming in C
Chapter 16: PROGRAmmING IN C
C is a computer programming language that has become increasingly popular in industrial
automation for writing sophisticated control programs. Integrated within SCADA 3000 is a C
language interpreter. This interpreter allows you to write and compile a program written in
the C language to perform intelligent input/output control and mathematical functions. Note
that the C interpreter in the SCADA 3000 is a slimmed-down version of C and that all func-
tions normally associated with ANSI C will not be available. Listed within this chapter are
explanations on functions that are available along with examples on how to make use of them.
Specifications
The maximum size of the C program is 32K of text and/or 16K of compiled text. Up to 1024
variables may be defined and each variable name can be up to 15 characters. The SCADA
3000 also has six predefined variables for date and time reference. The C program can be
set to run synchronously or asynchronously with the ladder program. In synchronous mode
the C-program will run continuously or, if the ladder program is running, synchronized with
the ladder program. In asynchronous mode the C program will run on an independent time
schedule.
About the C language
C is a structured programming language that is similar to other structured languages like
Pascal. The structure of C is like asking a question or posing a problem, and then going
through the simple steps of information gathering and action to solve the problem. For
example, if your alarm clock is ringing and you want it to stop ringing, you must hit the OFF
button to turn it off, otherwise nothing will happen. If you want the SCADA 3000 to turn
off the alarm clock, you must first tell it how to recognize that it is ringing, then give it the
command to turn it off when it recognizes that it is ringing, otherwise do nothing.
To give SCADA 3000 this information, you must translate English commands into C com-
mands. SCADA 3000’s built-in compiler then translates the C commands into SCADA 3000’s
language.
The C language structure is fairly simple. Each program must have a beginning and an
end. Each individual statement within the program must open, provide its information,
and then close. Think of it as writing sentences—without the proper sentence structure and
punctuation, you will get syntax errors. The reader (SCADA 3000) will not be able to receive
the message or understand what to do.
The SCADA 3000 C interpreter comprises the following elements:
STRUCTURE: To write a valid C program, regardless of length, you must follow
its simple structural elements.
KEYWORDS: These are short words or symbols that define variables or execute
specific actions within a C program. They include operators, assignment, com-
parators, and comments.
PREDEFINED VARIABLES: These are variables that have specific predefined
values that are automatically updated and cannot be changed by the user.
FUNCTIONS: These are word commands that perform a predefined function
within a C program.