
Page 6
Copyright © 2017 Matrix Technology Solutions Limited
www.matrixtsl.com
Language Neutral
Application Program Interface
MIAC AllCode
Instructional Guide
As the API reacts to a simple text-based protocol (as shown below) it means you have the
freedom to use formal programming languages like C, C#, C++ or Python, or graphical or
icon-based languages like Flowcode, App Inventor or LabView.
The other thing to note about the API is that some commands are bi-directional. This
means that a command sent to the MIAC could result in a value being returned. A good
example of this is the command to read the input terminals of the MIAC. An API command
could be sent to sample the input (that effectively interrogates it) causing it to return a
numerical value of the voltage present on the input terminal.
Shown below is the general format for the MIAC’s API.
API command
...Parameters...
Text string
Numeric values and/or text string
Every command starts off with a text string that identifies what the MIAC should do. This
may be followed by one or more parameters. Depending on what you are trying to do with
the MIAC these parameters can be numerical or textual or a mixture of both.
For example to send a value to the four relays on the MIAC you would use:
WriteRelays <value>
As the relays are grouped together and form an 4-bit row, they can be driven by sending a
binary number to them. So the parameter <value> can take a value between 0 and 15.
It should be noted that the API commands for a particular language might have some subtle
differences. For example, Python will use something like
"ma.WriteRelays(2)"
whereas C#
would look like
"MA_DLL.MA_WriteRelays(2);"
and for App Inventor, Flowcode and
LabView the appropriate icon would be selected.
Here’s another example that shows how to control a transistor on the MIAC.
WriteTran <channel> <value>
The parameter labelled <channel> can take a value between 1 and 4 to define which transistor
output to control. The parameter labelled <value> can take a value between 0 to 1 to define the
state of the output.
If you wanted to control all transistor outputs at once you could use this command.
WriteTrans <value>
The parameters <value> can take a value from 0 to 15 to define the binary state of the transistor
outputs.
Содержание MI3932 MIAC AllCode
Страница 1: ......