Matrix MIAC AIICode Series Manuel utilisateur


Page 2
Copyright © 2017 Matrix Technology Soluons Limited www.matrixtsl.com
Contents
Introducon - Geng Started 3
Take the Tour - Features of the MIAC AllCode 4
Language Neutral - Applicaon Programming Interface 5
Pseudo Code - A Simple Programming Aid 7
Bluetooth Setup - Windows PC 8
Bluetooth Setup - Android Tablet / Phone 10
Bluetooth Setup - Raspberry Pi and Linux 12
WIFI Setup - Connecng to the IP Address 14
Controlling The MIAC - Using Flowcode 15
Controlling The MIAC - Using App Inventor 17
Controlling The MIAC - Using C++ / C# / VB 20
Controlling The MIAC - Using Python 22
Controlling The MIAC - Using Labview 24
Transistor Outputs - Using PWM 25
API Documentaon - Input and Output 26
API Documentaon - Display and Relay 27
API Documentaon - Peripheral 28
MIAC AllCode
Instruconal Guide

Page 3
Copyright © 2017 Matrix Technology Soluons Limited www.matrixtsl.com
Introducon
Geng Started
Where do you start?
Congratulaons. You now have a state-of-the-art MIAC AllCode industrial controller.
This instruconal guide has been prepared to help you get up the learning curve as quickly as
possible so you can enjoy making the MIAC do the things you want it to do.
Powering up the MIAC
To Power up the MIAC simply connect a 12V to 24V DC supply to
the 2.1mm DC jack or to the 0V / V+ screw terminals. The green
LED at the top le hand side of the MIAC will light when the unit
is powered.
API UART
The MIAC AllCode has two serial UART peripherals which can be used to connect to the AllCode
API. By default UART 1 is selected which allows access to the internal Bluetooth / WIFI module (if
ed). The API UART can be controlled using the conguraon menu when powering up the MIAC.
The MIAC datasheet shows the UART connecons and the internal conguraon jumpers to select
between RS232 and RS485 communicaons modes.
Pairing your Bluetooth enabled device to the MIAC
The Bluetooth enabled MIAC AllCode must be paired to your Bluetooth enabled device to allow
API communicaons to work correctly. Pages 8 through 13 show how to pair the MIAC AllCode to
various dierent devices.
Connecng the MIAC AllCode to your WIFI network
The WIFI enabled MIAC AllCode can be connected to your WIFI network by using the conguraon
menu when powering up the MIAC. The Network Cong seng must be set to Join Network. The
Network SSID seng can then be used to scan for WIFI networks in range. The Password seng
can be used to enter the password for the network.
Hosng a WIFI network from the MIAC
The WIFI enabled MIAC AllCode can be used to host a WIFI network by using the conguraon
menu when powering up the MIAC. The Network Cong seng must be set to Host Network. The
Network SSID seng can then be used to enter the WIFI network name. The Password seng can
be used to enter the password for the network. The Encrypon and Channel sengs can be used
to alter the sengs of the network.
The Pre-Programmed Firmware
The original API rmware can be found on the AllCode secon of the Matrix Website and can be
re-programmed using the mLoader programming tool.
MIAC AllCode
Instruconal Guide

Page 4
Copyright © 2017 Matrix Technology Soluons Limited www.matrixtsl.com
Take the Tour
Features of the MIAC AllCode
This secon explores the various parts of the MIAC AllCode and explains the basic operaon.
MIAC AllCode
Instruconal Guide
Analog / Digital Inputs x 8
Relay Outputs x 4
(Normally Open)
(Mains Rated)
Transistor Outputs x 4
(High Speed)
(2 x DC motor Full H-Bridge)
Graphical Display
with Backlight
9 Button Keypad
Reset Switch and USB Socket
Bluetooth / WIFI communications module
(Internally Fitted)
DIN Rail Mounting
Screw Hole Mounting
CAN Bus Communications Serial RS232/RS485 Communications

Page 5
Copyright © 2017 Matrix Technology Soluons Limited www.matrixtsl.com
Language independent, agnosc, language neutral,
plaorm independent - what do these terms mean?
Basically it means you are not forced to use a certain
programming language or plaorm to control the MIAC.
This is because the MIAC AllCode oers an Applicaon
Program Interface (API) that enables you to interact with the
MIAC using a set of simple rounes or protocols.
If you have not heard of APIs then this secon will help
you understand how to make use of it with the MIAC.
One way to explain this is to think about how a TV remote controller works. Although
modern televisions have touch buons or so-touch areas along the edges of the screen,
most people nd it more convenient to use a remote controller to turn the TV On/O,
change a channel, adjust the volume or brightness sengs, etc.
A TV remote is a very simple device consisng of a keypad
and an infrared light beam. When a buon is pressed its
value is encoded and used to send a binary paern, via the
infrared beam, to the TV. The TV decodes the received
paern and carries out the required funcon.
If for some reason the TV remote failed it would be an easy
task to replace it with a new one, or even purchase a
universal remote (if you had a number of devices to control).
There are Apps that can be used to turn smart phones into a TV remote controller and other hardware is
available that can send out TV remote codes. The only crical part is to
send the correct paern (i.e. command) when it is required.
So you could say the TV has an API that allows a remote controller (whatever form it might
take) to control the intelligence or electronic control systems within the television.
The API, as used on the MIAC AllCode, oers the same plaorm and language independence as the TV
example described above. The dierence is the transmission medium for the MIAC is Bluetooth or Wi
rather than an infrared beam. This means providing you have a Bluetooth or Wi facility on your system,
you have the freedom to use your favourite plaorm and programming language to interact with the
MIAC.
As an example, you might choose to use a Bluetooth enabled mobile phone to control the
MIAC. Alternavely, a Wi enabled PC/Mac/Raspberry Pi® or a Matrix E-block upstream board would do
the same to create a simple controller.
Language Neutral
Applicaon Program Interface
MIAC AllCode
Instruconal Guide

Page 6
Copyright © 2017 Matrix Technology Soluons Limited www.matrixtsl.com
Language Neutral
Applicaon Program Interface
MIAC AllCode
Instruconal 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-direconal. 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 eecvely 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 o with a text string that idenes 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 parcular language might have some subtle
dierences. 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 dene which transistor
output to control. The parameter labelled <value> can take a value between 0 to 1 to dene 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 dene the binary state of the transistor
outputs.

Page 7
Copyright © 2017 Matrix Technology Soluons Limited www.matrixtsl.com
Pseudo-code
A Simple Programming Aid
MIAC AllCode
Instruconal Guide
Most of the examples that appear in this Instruconal Guide are wrien with pseudo-code.
This pseudo-code can be used with the many programming languages that can be used with the
MIAC AllCode.
One of the reasons for this is that this Guide would be huge if all the examples were wrien in
every language the MIAC AllCode supported, and only certain parts would be applicable to you.
API calls allow you to interact with the MIAC AllCode. The name of these calls will map across to
the set of macros available in Flowcode, AppInventor, Python and other languages supported by
the MIAC AllCode. A full list of available API calls is available at the end of this document.
Using pseudo-code allows you to take the rst step of pung your ideas into pracce in a
structured way without geng tripped up by the syntax of a formal programming language.
Once you have expressed your ideas, using pseudo-code, you can move on and write the
actual program using your chosen programming language, which should hopefully be a fairly
simple coding task.
Open COM Port
WriteRelays ( 15 )
Close COM Port
Open the communicaons port
Close the communicaons port
Switch On Relays 1-4

Page 8
Copyright © 2017 Matrix Technology Soluons Limited www.matrixtsl.com
Bluetooth setup
Windows PC
MIAC AllCode
Instruconal Guide
A lot of Windows devices, especially laptops and
tablets, have inbuilt Bluetooth funconality. If your PC
does not, you will need to use a Bluetooth 2 USB
dongle.
Dierent versions of the Windows operang system
use slightly dierent ways of connecng Bluetooth
devices, but they all follow the same steps.
You will need to perform this process just once as
Windows will remember which devices are paired.
1) Turn on Bluetooth
Oen, Bluetooth is enabled by default and you can usually ignore this step. However if it is
not, it can be enabled in the Windows sengs and/or control panel. Very occasionally,
Bluetooth needs to be switched on using a special switch or funcon-key. Please consult
your PC or Windows help for more informaon.
2) Pair the MIAC
First switch on the MIAC - the Bluetooth device name, pair key and visibility can be checked and
edited using the Congure menu and then selecng Bluetooth Sengs when powering up the
MIAC.
Again, pairing works slightly dierently on the various Windows versions and so it is dicult to
give specic instrucons here. The Windows help and website will have guides explain how.
When pairing, you will be presented with a screen or list of available Bluetooth devices.
Select the device with the name of your MIAC and click Next or Pair.
You will be asked to enter the pairing code. The MIAC AllCode uses the default
code of 1234, although this can be changed to another code if you want to ensure no-one
else can pair with your MIAC.
Once the code has been entered, Windows will conrm that it has paired with the MIAC.

Page 9
Copyright © 2017 Matrix Technology Soluons Limited www.matrixtsl.com
Bluetooth setup
Windows PC
3) Determine the COM port number
You should get a popup balloon on the task bar saying device is ready to use. If you click
this before it fades away then you can nd out the COM port assigned to the MIAC.
You use this COM port number when
communicang with the MIAC AllCode and this
COM port number will stay the same as long as
you do not remove or unpair the MIAC from
Windows.
If you did not see the COM port when the MIAC
was paired, you can nd it in the Bluetooth
Sengs window, as shown on the right.
There are two COM ports listed for each MIAC.
Make sure you always use the “outgoing” port
number.
This window can be a bit hard to nd on some
versions of Windows. For example, on Windows 10
you can nd this via the “More Bluetooth opons”
link on the Bluetooth sengs screen.
Luckily, there is a guaranteed way of opening this
window in all versions of Windows from version 7. Open the “Run…” window by holding the
Windows key and pressing R, then
type (or copy and paste) the following command into the box and press “OK”:
rundll32.exe shell32.dll,Control_RunDLL bthprops.cpl,,2
Now you have paired the MIAC and determined the COM port number, you can use any of
the many programming languages available on Windows to control the MIAC AllCode.
MIAC AllCode
Instruconal Guide

Page 10
Copyright © 2017 Matrix Technology Soluons Limited www.matrixtsl.com
MIAC AllCode
Instruconal Guide
Android phones and tablets, when used with intuive
programming soware such as App Inventor, provide a
movang plaorm for controlling the MIAC AllCode.
These devices almost always include Bluetooth and Wi
built-in.
As with other devices, the MIAC AllCode must be paired
with the phone or tablet before it can be used.
If your Phone or Tablet already has Bluetooth funconality built in then you may rst have
to enable it by clicking on Sengs -> Connecons.
Once Bluetooth is enabled you need to pair the MIAC AllCode to your phone to allow Apps to see
the device.
Begin by clicking the Bluetooth opon in Sengs -> Connecons
Next make sure your MIAC is switched on and click the Scan buon on your Android device to
check for new Bluetooth devices. Note you may have to scroll down to see the results from the
scan.
The name of the MIAC AllCode can be found by using the MIAC keypad and navigang to the
Congure menu followed by the Bluetooth Sengs menu when powering up the MIAC.
Bluetooth Switched O
Bluetooth Switched On
Bluetooth setup
Android Tablet / Phone
Ce manuel convient aux modèles suivants
3
Table des matières
Autres manuels Matrix Contrôleurs

Matrix
Matrix COSEC Panel Manuel utilisateur

Matrix
Matrix COSEC PATH DCFE Manuel utilisateur

Matrix
Matrix COSEC PATH DCFE Manuel utilisateur

Matrix
Matrix COSEC ARGO Manuel utilisateur

Matrix
Matrix Cosec Argo F0I212 Manuel utilisateur

Matrix
Matrix COSEC PATH DCFE Manuel utilisateur

Matrix
Matrix COSEC PANEL200 Manuel utilisateur

















