Skip to content

peterpolidoro/modular_client_matlab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

86 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

modular_client_matlab

Repository Information

Author
Peter Polidoro
License
BSD

This is the Matlab modular device client library for communicating with and calling remote methods on modular device servers. Based on some code by Will Dickson.

Requires Matlab R2016b or newer.

Example Usage

For help type “help ModularClient” from the Matlab command line.

See example m files in:

./modular_client/examples/

% Linux and Mac OS X
ls /dev/tty*
serial_port = '/dev/ttyACM0'            % example Linux serial port
serial_port = '/dev/tty.usbmodem262471' % example Mac OS X serial port
                                        % Windows
getAvailableComPorts()
ans =
'COM1'
'COM4'
serial_port = 'COM4'                    % example Windows serial port
                                        %
dev = ModularClient(serial_port)        % creates a client object
dev.open()                              % opens a serial connection to the device
device_id = dev.getDeviceId()           % get device id
dev.getMethods()                        % get device methods
dev.serialNumber()                      % get device serial number
dev.serialNumber('getValue')            % get device serial number alternative
dev.serialNumber('setValue',1)          % integers are automatically cast to int32
dev.close()                             % close serial connection
delete(dev)                             % deletes the client

debug = true
dev = ModularClient(serial_port,debug)  % creates a client object with debugging

More Detailed Modular Device Information:

https://github.com/janelia-modular-devices/modular-devices

Installation

Install Arduino and Teensyduino on your Host Machine

Setup Arduino

Download this repository from github

Using git

Install git if necessary:

https://github.com/janelia-experimental-technology/git_setup

Clone this repository:

(e.g. PATH = c:\Users\User\Documents\MATLAB).

cd PATH
git clone https://github.com/janelia-matlab/modular_client_matlab.git

Setup Matlab

Add this path and all its subdirectories to the Matlab path:

PATH\modular_client_matlab\modular_client\

Setup Hardware

Connect modular device to computer with a USB cable.

Find serial port of connected device.

When modular device is Arduino-based, you can use Modular environment to help find port. Read more details here:

http://arduino.cc/en/Guide/HomePage

Windows:

Typically ‘COM3’ or higher. Use Matlab command getAvailableComPorts() or use ‘Device Manager’ and look under ‘Ports’.

Mac OS X:

List directory contents of /dev:

ls /dev

Typically something like ‘/dev/tty.usbmodem’

Linux:

List directory contents of /dev:

ls /dev

Typically something like ‘/dev/ttyACM0’

If you see this error:

Error using serial/fopen (line 72)
Open failed: Port: /dev/ttyACM0 is not available. Available ports: /dev/ttyS0.
Use INSTRFIND to determine if other instrument objects are connected to the requested device.

You can use /dev/ttyACM0 but you need to let the library know that you will be using it. To specify the ports on your system, copy the java.opts file from this repository into the directory you start MATLAB.

Restart Matlab and type:

pwd

This will tell you the directory where you need to place the java.opts file.

Save this file into that directory:

java.opts

About

Modular device client Matlab interface.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages