ArCOM

Developed by Sanworks

ArCOM is a set of classes to simplify 2 types of data transaction:

  • Arduino <--USB--> MATLAB/GNU Octave

  • Arduino <--UART-->Arduino.

It provides single-line commands on both ends to transmit and receive scalars or arrays of different data types.

ArCOM is a contraction of Arduino Communication.

Currently, ArCOM transmits scalar integers and arrays of integers:

    • 8-bit types

      • uint8, int8, char

    • 16-bit types

      • uint16, int16

    • 32-bit types

      • uint32, int32

On the MATLAB side, ArCOM wraps three serial interfaces so your code can be used with any of:

ArCOM configures serial port communication settings for you on both sides automatically (byte order, RTS/request to send, etc, to match the default configurations for MATLAB and Arduino).

Here's how you'd use ArCOM to send an unsigned 16-bit integer array from Arduino to MATLAB:

Arduino code:

#include "ArCOM.h" // Import the ArCOM library

ArCOM myUSB(SerialUSB); // Create an ArCOM wrapper for the SerialUSB interface

unsigned short myDataArray[10] = {0}; // Create a 1x10 uint16 array

void setup() {

SerialUSB.begin(115200); // Initialize the USB serial port

myUSB.writeUint16Array(myDataArray,10); // Send the array to MATLAB's buffer

}

void loop() {}

MATLAB code (with ArCOM.m in the MATLAB path):

SerialPort1 = ArCOM('open', 'COM3', 115200); % Create and open the serial port

MyData = ArCOM('read', SerialPort1, 10, 'uint16'); % Read the array from the buffer

Another example, sending an array of 100 signed 32-bit ints from MATLAB to Arduino,

MATLAB code:

MyData = -151340:-151241;

ArCOM('write', SerialPort1, MyData, 'int16');

Arduino code:

long myDataArray[100] = {0}; // Create a 1x100 int16 array

...

myUSB.readint16Array(myDataArray,10);

ArCOM is under development, and may contain bugs. Please submit any bugs you encounter to:

admin@sanworks.io

Thank you!