User Manual

MCP Series
Brushed DC Motor Controllers
MCP Series User Manual
106
3.1.5 Variable Names
Variable names must start with a letter but can be any combination of letters and numbers
including some symbols that are not in the reserved word list. You can name your variables
almost anything. However, its a good idea to name them something useful that you will
remember and understand for debugging your program. Variable names can be up to 1,024
characters long. The only names you can not use for your variables are reserved words. These
are words used by Studio for commands or other syntax based names (see the manual appendix
for a complete reserved word list).
Example:
MotorSensor VAR Word
3.1.6 Aliases
Variables can be aliased. Using an alias allows you to rename a variable in various places in your
code. This helps your program be human readable without wasting additional memory space.
Aliasing can also be used to access just a proportion of the variable such as the low or high byte
for a word sized variable.
Example:
MotorDirection VAR Word
MaxCCSpeed VAR MotorDirection
MaxCCWSpeed VAR MotorDirection.byte0
3.1.7 Variable Modiers
Variable modiers can be used when only part of a variables value is needed. Most
communication formats such as serial or I2C are byte driven. If you have a word sized variable
and you are sending data to such a device, you will need to send one byte at a time of the word
variable. The word value can be split using an alias with a modier as shown below.
Example
MyData VAR Word
FirstByte VAR MyData.HighByte
SecondByte VAR MyData.LowByte
Variable modiers can also be used inline with the variable in an expression.
Example
MyData VAR Word
MyByteSum var word
MyData = 0x1234
MyByteSum = MyData.byte1 + MyData.byte0 ;MyByteSum will equal 0x12 + 0x34
end