Rockwell Automation 57C610 Enhanced Basic Language, AutoMax User Manual

Page 70

Advertising
background image

6Ć30

Configuring and Using PORT B

For port B, you must use the OPEN statement in a task to allocate

the port before the task can communicate through the port, even if

the default port setup and baud rate are acceptable for your

application.
If the default setup or baud rate are not suitable for your application,

use the following OPEN statement format to temporarily allocate the

port for EXCLUSIVE access to change the default setup or baud

rate. This changes the default characteristics of the port until the

next power cycle or StopĆAllĆClear occurs. Use the CLOSE

statement to deĆallocate the port. The CLOSE statement must follow

the OPEN statement with no intervening INPUT, PRINT, GET or PUT

statements. The CLOSE statement must use the same device

number assigned in the OPEN statement.

OPEN PORTB" AS FILE #logical_device_number,

SETUP=specs, baud_rate \&
CLOSE #logical_device_number

Note: When an OPEN statement has a setup parameter, the port is

opened with EXCLUSIVE access. Therefore, specifying

ACCESS=NON_EXCLUSIVE causes a compile error to be logged. A

second OPEN statement must be added after the port is closed as

shown below.
If the default or configured port setup and baud rate are proper for

your application, use the following OPEN statement format to

allocate the port for NON_EXCLUSIVE access so the task can

communicate through the port. The port must remain open to

execute subsequent INPUT, PRINT, GET, or PUT statements.

OPEN PORTB" AS FILE #logical_device_number,

ACCESS=NON_EXCLUSIVE

The format of the INPUT, PRINT, GET, or PUT statements used to

communicate through the port is INPUT #, PRINT #, GET # or PUT

#, where # is the device number assigned to the port in the OPEN

statement. Whenever you refer to the port in subsequent

statements, always use the device number assigned to the port in

the OPEN statement.
In addition, if you want to make the port accessible to multiple tasks

in the Processor at the same time, you must add an OPEN

statement with the ACCESS parameter specified as

NON_EXCLUSIVE in each task that must communicate through the

port using the same logical_device_number that was used to identify

the port in the first task.
You must add software interlocking to each task attempting to

allocate the port to ensure that the task can determine whether the

port setup and baud rate have been initialized prior to opening the

port for NON_EXCLUSIVE access. Only one task needs to allocate

the port and define the setup and baud rate initially. Software

interlocking is also needed for port error handling. Tasks may need

to close and reĆopen the port on error conditions.

Advertising
This manual is related to the following products: