Control Solutions is your source for LonWorks I/O.
i.CanDoIt® Guided Tour (p.13)
PL/i Programming
This set of pages will provide a brief overview of i.CanDoIt® features and functions. Cruise through using the Next and Previous buttons, or skip around using the links at the bottom of the pages.

The PL/i programming language is a descendant of PL/1 at the source code level. At the execution level, AddMe III runs on byte code similar to Java. The goal of PI/i was to create a compact compiler with a reasonably safe execution environment and a syntax with some of the power of C while being simpler than C.

The AddMe III architecture is register based. Therefore a carefully written program will be portable to systems running on Modbus, LonWorks or BACnet networks with equivalent results.

A complete discussion of PL/i syntax and grammer can be found in the help pages in the device's internal web site under the Advanced->PL/i Programming tabs.

What does PL/i look like?

Most of any given program will look a lot like Basic. Referring to subroutines as "procedures" is borrowed from older languages like Pascal. The block structure is common to many languages, and setting the blocks apart with "begin..end" instead of {} is also borrowed from Pascal. In fact, if you are a Pascal programmer, you may recognize several similarities. We hope you won't miss ":=".

The simple test program shown here will ramp an analog output on AddMe III up and down from zero to near full scale. It got named "dimmer" because if we connect an LED across the output, we have an LED dimmer. This makes a good "my first program" exercise.

program dimmer

declare
myVar: int;

procedure turnon (setting: int)
declare
level: int;
begin
level = setting * 10;
seti (19, level);
delay (5);
end;

begin
while TRUE do
begin
for myVar = 0 to 20 turnon(myVar);
for myVar = 20 down to 0 turnon(myVar);
end;
end