The Commander series of controllers supports standalone programming (AScript), which allows the controller to execute a user-defined program stored in internal memory. The standalone program can run independently of USB and serial communication, or while communication is active.

On this page

Conditional loop control

A-Script supports a number of conditional statements that perform different actions for different conditions. A-Script supports the following conditional statements: IF/ELSEIF/ELSE loop and WHILE loop.  Table Conditions below shows the available conditions.

Symbol

Meaning

=

Equals

!=

Not Equal

>

Greater than

<

Less than

>=

Greater than or Equals

<=

Less than or Equals

Conditions

Examples of using conditional loop control in a program are found in sections Standalone Example Program 3 – Single Thread, through Standalone Example Program 10 – Multi-thread with subroutine.

Return to Top

Standalone Variables

Commander controllers have 100 32-bit signed standalone variables available for general purpose use. They can be used to perform basic calculations and support integer operations. The V[0-99] command can be used to access the specified variables. The syntax for all available operations are seen in the table below. 

Note: These operations can only be performed in standalone programming.

Operator

Description

Example

+

Integer Addition

V1=V2+V3

-

Integer Subtraction

V1=V2-V3

*

Integer Multiplication

V1=V2*V3

/

Integer Division (round down)

V1=V2/V3

%

Modulus

V1=V2%5

>>

Bit Shift Right

V1=V2>>2

<<

Bit Shift Left

V1=V2<<2

&

Bitwise AND

V1=V2&7

|

Bitwise OR

V1=V2|8

~

Bitwise NOT

V1=~V2

Operations

All variables can be accessed and written with the ASCII V[0-99] command. Variables V0-V49 are initialized to zero on power up, and variables V50 through V99 can be stored to flash memory using the STORE command.

Return to Top

Standalone Control

The Commander series of controllers supports the simultaneous execution of four standalone programs. All programs can be controlled by the SACTRL[0-3]=[control] ASCII command and the SR[0-3]=[control] standalone command. Program 0 uses command SACTRL0, Program 1 uses command SACTRL1, and so on.  The following [control] assignments can be used for the standalone control command.

Value

Description

0

Stop standalone program

1

Start standalone program

2

Pause standalone program

3

Continue standalone program

SACTRL command

Return to Top

Standalone Status

The SASTAT[0-3] command can be used to determine the current status of the specified standalone program. The table below details the returned values of this command.

Value

Description

0

Idle

1

Running

2

Paused

3

N/A

4

Error

SASTAT command

The SPC[0-3] command can also be used to find the current assembled line that the specified standalone program is executing. Note that the return value of the SPC[0-3] command is referencing the assembly language line of code and does not directly transfer to the pre-compiled user generated code. The return value ranges from [0-1799].

Return to Top

Standalone Run on Boot-Up

Standalone can be configured to run on boot-up using the SLOAD command.  Once this command has been issued, the STORE command is needed to save the setting to flash memory. It will take effect on the following power cycle. See description in the table below for the bit assignment of the SLOAD setting.

Bit

Description

0

Standalone Program 0 

1

Standalone Program 1 

2

Standalone Program 2

3

Standalone Program 3

SLOAD  command

ASCII

SACTRL[0-3]

SASTAT[0-3]

SPC[0-3]

GS[0-31]

V[0-99]

SLOAD

Standalone

SR[0-3]

-

-

GOSUB[0-31]

V[0-99]

-


ASCII

SAP

STORE

Standalone

-

STORE

Return to Top