Interfacing Openvibe output with Arduino Uno

About the GUI application to design signal processing pipelines
Post Reply
MOD123
Posts: 7
Joined: Thu Apr 18, 2013 6:52 am

Interfacing Openvibe output with Arduino Uno

Post by MOD123 »

Dear all,

First of all thank you for the great software, it really simplifies the concepts of BCIs. I'm currently working on developing a BCI to control a couple of motors via an arduino uno, i'm using emotiv eeg for acquisition and have successfully managed to discriminate between right vs left hand movements (in a similar fashion to the motor imagery CSP scenario).

At the moment i want to get the outputs from the classifier processor and send them to the arduino to control a couple of motors, either by sending them directly if possible or by having an interfacing software/program as a middle man.

Can someone please help me with this matter, I'm not a programmer, but i have basic knowledge in C and C++ so detailed explanations (baby language ) are much appreciated.

jtlindgren
Posts: 775
Joined: Tue Dec 04, 2012 3:53 pm
Location: INRIA Rennes, FRANCE

Re: Interfacing Openvibe output with Arduino Uno

Post by jtlindgren »

Hi MOD123, the solution suggested in this post might work for you as well:

viewtopic.php?f=10&t=4888&p=8426&hilit=vrpn#p8426

Happy hacking,
Jussi

MOD123
Posts: 7
Joined: Thu Apr 18, 2013 6:52 am

Re: Interfacing Openvibe output with Arduino Uno

Post by MOD123 »

Thanks alot jussi, that really narrows it down for me. The only major difference that i can see between my project and the link that you shared, is that i basically want to connect the arduino to my pc via a serial port and not WIFI.

I have taken a look at the VRPN boxes and tutorial, honestly i couldn't figure out how to get the tutorial up and running, from what i understand i need to download the entire VRPN program from their website http://www.cs.unc.edu/Research/vrpn/, in order to get the complete list of headers and librnaries. Is there anything else that i need to do before being able to complete the tutorial.



I'm really quite the noob when it comes to programming, so any help is really appreciated.

MOD123
Posts: 7
Joined: Thu Apr 18, 2013 6:52 am

Re: Interfacing Openvibe output with Arduino Uno

Post by MOD123 »

This just came to mind. Is it possible to send the classifier processor output to matlab via the matlab script box and then use matlab to control the arduino via serial port

jtlindgren
Posts: 775
Joined: Tue Dec 04, 2012 3:53 pm
Location: INRIA Rennes, FRANCE

Re: Interfacing Openvibe output with Arduino Uno

Post by jtlindgren »

That should work. If not, we should definitely fix it. :) Another option is to use the Python scripting box. As the processor output is a stimulation stream, Lua Stimulator box might also work. However, Matlab and Python boxes are more versatile in their inputs and outputs.


Good luck,
Jussi

MOD123
Posts: 7
Joined: Thu Apr 18, 2013 6:52 am

Re: Interfacing Openvibe output with Arduino Uno

Post by MOD123 »

Thanks Jussi for the help, i really appreciate it.

I've started implementing my codes to control the motor, the code at the arduino end works if i tried feeding the inputs manually or through matlab, but if i try to get the inputs from matlab scripting box, i keep receiving this error:

---- MATLAB BUFFER - ERROR ! ----
??? Error using ==> serial.fopen at 72
Port: COM3 is not available. No ports are available.
Use INSTRFIND to determine if other instrument objects are connected to the requested device.

This is weird, because matlab seems to have no problem locating and opening the port when i use it alone with the arduino, and the error only shows up if i try to open the serial port through the matlab scripting box, other parts of the code seemed to work fine with the serial opening codes.

I have attached the matlab code down below, maybe that can help to clarify the problem. I really appreciate any help with this. Thanks alot.
Attachments
classifier_processor_process.txt
(1.13 KiB) Downloaded 400 times

jtlindgren
Posts: 775
Joined: Tue Dec 04, 2012 3:53 pm
Location: INRIA Rennes, FRANCE

Re: Interfacing Openvibe output with Arduino Uno

Post by jtlindgren »

Hi Mod123,

I don't have serial ports on my machine so its a bit difficult to test, but one thing that comes to mind is that your code tries to open the port in the process() function and doesn't seem to be closing it. The process() function is run repeatedly all the time to process data chunks as they arrive to the box. I think the correct way would be to open the port in initialize.m, do the reading in process.m, and finally close the port in uninitialize.m. You can use global variables to store/pass the port handle.

Matlab scripting box should open a command line window (at least on my Win7 it does). As a test, you could try to see if you can access the port by writing commands there.


Good luck,
Jussi

MOD123
Posts: 7
Joined: Thu Apr 18, 2013 6:52 am

Re: Interfacing Openvibe output with Arduino Uno

Post by MOD123 »

Hello Jussi, i apologize for the late reply, thanks for your help, your suggestion seems to be working, i'm having another problem with my arduino code now and the servos,so i will try to solve that first before returning back to the matlab script box.

I'll keep you updated with how things turn out, i hope you don't mind :D

VaibhavKathpalia
Posts: 3
Joined: Tue Feb 18, 2014 2:44 pm

Re: Interfacing Openvibe output with Arduino Uno

Post by VaibhavKathpalia »

Hi MOD123,

I am also working on a similar platform. Just wanted to clarify, whether you are connecting the arduino at an offline stage or an online stage. And to which block in the experiment are you connecting the matlab script box as an output. Is it the voting classifier, since that classifies the detected letter as P300 or non-P300.

Thanks,
Vaibhav

Post Reply