User Tools

Site Tools

한국어

cubloc:using_i_o:index

Using Ladder Logic I/O

Cubloc I/O ports can be used by both BASIC and Ladder Logic. Without defined settings, all I/O ports are controlled in BASIC. The UsePin command must be used to set the I/O ports for use in Ladder Logic.

 UsePin 0,IN
 UsePin 1,OUT

The above code sets P0 as input and P1 as output for use in Ladder Logic. Those ports declared with the UsePin command will be re-flashed during a ladder scan. Re-flashing means that, prior to a ladder scan, those ports declared as IN with the UsePin command will have their input read and copied to the port's corresponding P register.

After the ladder scan, those ports declared as OUT with the UsePin command will have the corresponding P register's value written to the port's output.

In BASIC, the commands In and Out an be used to control I/O ports. This method directly accesses the I/O ports when reading and writing.

In order to avoid collisions between the two, I/O ports should be used in either BASIC or Ladder Logic, but not both. Once a port is declared with the UsePin command, it can only be used in Ladder Logic and cannot be directly accessed in BASIC, except through the ladder registers.

 UsePin 0,IN, START
 UsePin 1,OUT, RELAY

Aliases (such as START or RELAY as shown above) can be assigned using the UsePin command to improve readability.

Use of Aliases

When creating Ladder Logic using “Register numbers” such as P0, P1, and P5, aliases can be used to help programs.

In order to use an alias, they must be declared in BASIC.

Usepin 0,In,STARTKEY
Usepin 1,In,SW1
Usepin 5,Out,MainMOTOR

or

Alias P0 = STARTKEY
Alias P1 = SW1
Alias P5 = MainMOTOR

Aliases can be declared using either the UsePin or the Alias commands

Go CUBLOC Ladder Logic home

cubloc/using_i_o/index.txt · Last modified: 2016/04/14 11:07 (external edit)