User Manual

MCP Series
Brushed DC Motor Controllers
MCP Series User Manual
105
3.1 MCL Language
3.1.1 Variables
Variables are used to store values used in your program. The values stored will typically change
during program run time. What was stored at the start of your program in a given variable can
change by the time your program stops running.
To use a variable it must be dened in your program so the MCP knows to set aside the required
amount of space in RAM. The MCP can handle up to 32 bit variables.
When creating a variable you specify what type of variable you will need in your program.
You can dene as many variables as you want. The only limiting factor is the amount of RAM
available which varies for each MCP model.
3.1.2 Variable Types
Type Bits Value Range
Bit 1 1 or 0
Nib 4 0 to 15
Byte 8 0 to 255
SByte 8 -128 to +127
Word 16 0 to 65,535
SWord 32 -32,768 to +32,767
Long 32 0 to 4,294,967,295
SLong 32 -2,147,483,647 to +2,147,483,648
Float 32 ± 2.0 EXP -126 to ± 2.0 EXP 127
3.1.3 Variable Locations
Where the variable is dened dictates where the variables can be used. Variables must be
dened before they can be used. It is recommended to dene your variables at the begining of
your program.
3.1.4 Dening Variables
Variables are dened using the statement VAR. You can declare your new variable as any type
found in the Variable Types table. To dene a variable use the syntax shown below.
Syntax:
VariableName VAR Type
Examples:
Red VAR Byte
Tick VAR Nib
Switch var Bit
Totals var Sword