Custom Add-On Library Concepts
An add-on library is a collection of MATLAB® and C++ code that provides a user easy access to features on the Arduino® hardware or attached shields. Without the need to directly program the Arduino hardware work within the MATLAB environment, the exploration and development of projects can proceed at an accelerated rate.
This schematic shows the construction of a custom Arduino add-on library and its relation to the hardware.
The Custom Arduino Libraries provides the
matlabshared.addon.LibraryBase class in
MATLAB and the C++
librarybase.h library. You create a custom
add-on library by extending the MATLAB class and creating a C++ class that includes
Communication between the Arduino hardware and MATLAB on the host computer operates in a server-client relationship, respectively.
sendCommand function issues a
command, known as a
commandID, from the MATLAB on the host computer, which is acting as the client. A server object
on the Arduino hardware, created by the
receives the command in the Command Handler method in the Create and Configure C++ Header File. A switch statement determines which code segment to
execute on the Arduino device. When complete, the Command Handler uses the
sendResponseMsg() to return
any data and validate that the specified
Communication between MATLAB on the host computer and the Arduino hardware incurs a
20 ms time delay.
To create custom add-on libraries, you should have a working knowledge in the following areas
The functionality of your hardware device, and its associated application programming interfaces (APIs)