Data Sheet
Script Structure and Possibilities
Advanced Digital Motor Controller User Manual 189
The SetCommand function is used to send motor commands or to activate the Digital
Outputs. Practically all controller parameters can be access using these 4 commands,
typically by adding the command name as defined in the Serial (RS232/USB) Operation on
page 141 preceded with the “_” character. For example, reading the Amps limit configura-
tion for channel 1 is done using getvalue(_ALIM, 1).
See the MicroBasic Language Reference on page 143 for details on these functions and
how to use them.
Timers and Wait
The language supports four 32-bit Timer registers. Timers are counters that can be loaded
with a value using a script command. The timers are then counting down every millisec-
ond independently of the script execution status. Functions are included in the language
to load a timer, read its current count value, pause/resume count, and check if it has
reached 0. Timers are very useful for implementing time-based motion sequences.
A wait function is implemented for suspending script execution for a set amount of time.
When such an instruction is encountered, script execution immediately stops and no
more time is allocated to script execution until the specified amounts of milliseconds have
elapsed. Script execution resumes at the instruction that follows the wait.
Execution Time Slot and Execution Speed
MicroBasic scripts are executed in the free time that is available every 1ms, after the con-
troller has completed all its motion control processing. The available time can therefore
vary depending on the functions that are enabled or disabled in the controller configura-
tion. For example more time is available for scripting if the controller is handling a single
motor in open loop than if two motors are operated in closed loop with encoders. At the
end of the allocated time, the script execution is suspended, motor control functions are
performed, and scripts resumed. An execution speed averaging 50,000 lines of MicroBa-
sic code, or higher, per second can be expected in most cases.
Protections
No protection against user error is performed at execution time. For example, writing or
reading in an array variable with an index value that is beyond the 1024 or 4096 variables
available in the controller may cause malfunction or system crash. Nesting more than 64
levels of subroutines (i.e. subroutines called from subroutines, …) will also cause potential
problems. It is up to the programmer to carefully check the script’s behavior in all conditions.
Print Command Restrictions
A print function is available in the language for outputting script results onto the serial or
USB port. Since script execution is very fast, it is easy to send more data to the serial
or USB port than can actually be output physically by these ports. The print command is
therefore limited to 32 characters per 1ms time slot. Printing longer strings will force a
1ms pause to be inserted in the program execution every 32 characters and/or loss of
characters.