Git Product home page Git Product logo

testarduino's Introduction

TestArduino

A C++ application to interface with an Arduino.

TargetPlatform: Windows. (Highly OS-specific COM Port API)

Design in progress on low-latency Arduino-PC communication software.

Communication is available in three flavors:

  • MatLab's Java-Based Serial package
  • Native C++/WinAPI serial communicaiton
  • C++/WinAPI DLL to import into MatLab

Purpose

The ultimate intended purpose is scientific data acquisition (at a 2% the cost, with comparable effort).

The Arduino connects to the PC via USB cable. The design has been tested successfully, so far, with an Arduino Uno (R3), and Arduino Due.

The original usecase is an interactive psychology experiment (explaining some of the quirks of the naming conventions in the Arduino sketch).

Install

The C++ software was developed on a Windows 8.1 machine with Visual Studio 2013. Outside of this platform, your mileage may vary. No special API needed, as far as I am aware, outside of the default installs. Probably WinAPI or something of the sort.

The Arduino sketches can be flashed to any Arduino-compatible device with the Arduino IDE.

Any MatLab scripts can be run with MatLab. Modifications would be required to be compatible with Octave. MatLab scripts developed on R2014a, but it should not be specifically required.

What do I need?

Windows

Well, for starters you will probably need a recent release of Visual Studio. If free is in your price range, and you're developing in a Windows environment, you might want to check out Microsoft Visual Studio - Community 2013. If you're not developing in Windows, you better know what you're doing, because the libraries are currently heavily dependent on the Windows API.

I'm going to try to keep reasonably recent builds of the library files uploaded in the BuiltLibs folder, so it won't be strictly necessary to have the IDE installed.

You will also need any version of the Arduino IDE that works with your Arduino. The Arduino IDE is available from The Official Arduino Website. Speaking of which, you will probably need an Arduino.

If you wish to utilize the MatLab scripts, you'll need a version of MatLab that supports the loading of external libraries. I doubt that is a new feature, any distro of MatLab released in the last 5 years is probably sufficient. I am going to investigate getting the libraries to build and link with Octave (an opensource MatLab alternative), but that's on the To Do list for now.

For very low latency, I recommend getting:

Unix

(Not Complete)

If you are developing in Unix, you will need:

  • g++ version 4.8+
  • g++ multilib
  • libc6-dev-i386
  • Code::Blocks or familiarity with compiling source code
  • ARM, x86, or x64 processor

There may be a better way, but you should create a link to the compiled librarys in your /usr/lib directory, so that you always use the latest version.

sudo ln -sf libArduinoCommDLLx86.so /usr/lib/libArduinoCommDLLx86.so
sudo ln -sf libArduinoCommDLLx64.so /usr/lib/libArduinoCommDLLx64.so
sudo ln -sf libArduinoCommDLLARM.so /usr/lib/libArduinoCommDLLARM.so

Latency Details

When paired with the collection of Neural data, it is important to get latency as low and consistent as possible. Unfortunately, in this respect, MatLab fairs poorly. It appears that for comparable tasks, the MatLab Serial functionality (derived from Java) is noticeably more variable.

A simple Serial Reflection task for profiling:

Send a character, have the Arduino send that character back, but embed this logic in the middle of its experiment monitoring routines to create a realistic profile of response time. Repeat 10,000 times.

For this task, using an Arduino Uno R3, the C++ program had a response with these characteristics:

  • Average Response Time: 4.093 ms
  • Standard Deviation of Response Time: 0.294 ms
  • Max Response Time: 5.048 ms

The same hardware and software communicating with MatLab, however saw these characteristics:

  • Average Response Time: 9.497 ms
  • Standard Deviation of Response Time: 1.852 ms
  • Max Response Time: 66.540 ms

Communicating with MatLab through the C++ Shared Library:

  • Average Response Time: 4.093 ms
  • Standard Deviation of Response Time: 0.295 ms
  • Max Response Time: 5.049 ms

Communicating with MatLab through the C++ Shared Library and a PCIe RS232 Card to the RS232 Arduino Shield:

  • Average Response Time: 0.7139 ms
  • Standard Deviation of Response Time: 0.0055 ms
  • Max Response Time: 0.7923 ms

Known Issues

To Do

  • Complete Unix port.
  • Explore portability to Octave. Will require changes to project build.

testarduino's People

Contributors

tstavropoulos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.