User Manual
MCP Series
Brushed DC Motor Controllers
MCP Series User Manual
107
3.1.8 Variable Modier Types
Modier Description
LowBit Returns the low bit of a variable (least signicant bit).
HighBit Returns the high bit of a variable (most signicant bit).
Bitn Returns the Nth bit of a variable. From 0 to 31 depending on variable size.
LowNib Returns the low nibble (4 bits) of a variable (least signicant nib).
HighNib Returns the high nibble (4 bits) of a variable (most signicant nib).
Nibn Returns the Nth nib (4 bits) of a variable. From 0 to 7 depending on variable size.
LowByte Returns the low byte (8 bits) of a variable (least signicant byte).
HighByte Returns the high byte (8 bits) of a variable (most signicant byte).
Byten Returns the Nth byte of a variable. From 0 to 3 depending on variable size.
SByten Returns the Nth signed byte of a variable. From 0 to 3 depending on variable size.
LowWord Returns the low word (8 bits) of a variable (least signicant word).
HighWord Returns the high word (8 bits) of a variable (most signicant word)
Wordn Returns the Nth word of a variable. 0 to 1 depending on variable size.
SWordn Returns the Nth signed word of a variable. 0 to 1 depending on variable size.
3.1.9 Variable Arrays
Variable arrays can be used to store several values using one variable name. A good use of
variable arrays would be taking multiple readings from a temperature sensor and storing the
samples in a variable named Temperature. The reads can later be averaged for a more accurate
temperature. MCL only supports one dimensional arrays.
Example:
Temperature VAR Byte(5)
The example above creates 5 byte sized RAM locations for the variable temperature. Each
location is indexed and referenced by using a numerical value. The range is based on the array
size that was dened. In this case the array size is 5. So an index value of 0 to 4 can be used.
Example:
Temperature(0) = 255 ;loads rst position
Temperature(1) = 255 ;loads second position
Temperature(2) = 255 ;loads third position
Temperature(3) = 255 ;loads fourth position
Temperature(4) = 255 ;loads fth position
Temp = Temperature(0) ;Loads value from rst position in the array
A common use of variable arrays is to store strings of ASCII based characters. This can be used
to send an entire sentence of text to a byte driven device such as a computer terminal window
using the STR command modier shown later.
3.1.10 Out of Range
When declaring variables, careful consideration should be given to the maximum value it will
store. If a byte sized variable is declared but the result of some function is word sized then data
will be lost. MCL has no way of knowing these possible conditions existing within your program.