I want to record the behaviour of my animal, and depending on the output of a sensor send a TTL to the reward pump with a certain delay. At the same time I would like to record the values of the sensor (multiple) and the reward pump at high frequencies. I program this all in Matlab.
I splitted it up into two Labjacks, one master that organizes all the events, and one recorder that records at high frequencies all the parameters.
Within matlab I can call the individual functions on there own and this works fine. However I can't get them to work at the same time. My approach was
- Open two matlab programns
- let each matlab program run there own script based on one labjack.
I have defined the labjack as
[ljerror, ljhandle1] = ljudObj.OpenLabJack(LabJack.LabJackUD.DEVICE.U3, LabJack.LabJackUD.CONNECTION.USB, '1', false , 0);
[ljerror, ljhandle2] = ljudObj.OpenLabJack(LabJack.LabJackUD.DEVICE.U3, LabJack.LabJackUD.CONNECTION.USB, '2', false , 0);
in function master and function record respectively.
However although these lines together in a single script work fine, if I start to run to seperate scripts I get the error of Lab Jack already being open. In addition I am not sure if opening two matlab programs is the most elegant way to do this. Should I go to multi-threading (next question how?)
Any suggestion how to improve?
Thanks in advance.