You are here: Home / Projects / Community Projects / 
2024-11-21 - 13:46

Immediate C

C programmers can now develop PLC-like control applications without giving up the computer language they are familiar with. This project was developed by John E. Wulff, who made it available under the GPL v2.

SPDX-License-Identifier: GPL-2.0+ OR Artistic-1.0

The programming language "immediate C" or iC is a declarative, event-driven extension of the procedural language C  – useful for machine control, robotics and for dealing with events generated in a GUI.

iC utilizes the syntax of C to give meaning to statements that have no semantic support in C. In addition to standard variables, which are modified by the flow of instructions, iC provides so-called "immediate" variables, whose values are updated, whenever a change of input calls for an immediate change in output. An efficient Data Flow technique implements this strategy.

iC provides programmers with built-in operators, whose function is closely modeled on integrated circuits. The name iC is a reminder of this fact. Logical AND, OR, EXCLUSIVE-OR and NOT as well as D flip-flops, SR flip-flops, shift registers and many others are implemented in such a way, that their use in iC follows the same design rules, which apply to their hardware counterparts. These rules have led to a well-developed hardware technology, whose effectiveness is demonstrated by the success of today’s complex computer hardware. Particularly the concept of clocked functions plays an important role in the language iC. It gives the same protection against timing races in iC programs, as it provides for hardware IC designs. But iC is not a hardware description language nor a simulation language – it provides the functionality and some of the speed of field-programmable gate arrays with a language, which is pre-compiled into straight C code, which is portable and produces efficient machine code.

An I/O simulation tool called iCbox allows the generation of inputs and the display of outputs while an application is running. The screen hardcopy on the left shows the iCbox window for the sample program demo.ic, which is written in the iC language and which is part of the software distribution. To start the program simply type "iClive Test0/demo.ic" and click "Build", "Run" and "Live". The documentation contains full instructions on how to install and use the software.

iClive is both a text editor and an online debugger, which can display the live state of variables as an iC program is running. This is shown on the right using the same demo.ic program as above.

You can find more detailed information on John Wulff's Blog immediateC.net.

To start with immediate C, have a look at the immediate C Programming Manual in the Books section of the Blog, which starts with a tutorial introduction of the language in the style of the K&R C Programming Language, building up from there discussing all the features added to C. The immediate C Reference Manual describes the iC language and its built-in function blocks in detail.

On a Linux system and particularly on a Raspberry Pi you can clone the whole GIT repository from https://github.com/JohnWulff/immediatec.git or download the ZIP file of the latest release from the same GitHub site and try your own iC code very quickly.

immediate C is built with the usual configure – make – make test – make install commands. The README explains the details and how to make, run and debug iC apps.

immediate C can execute direct Input/Output on a Raspberry Pi computer. Drivers are included for digital I/O on GPIO’s and PiFace cards as well as a driver for PWM analog output on GPIO’s and analog input from an MCP3008 A/D converter. See README.RPi for details.