Hello,
I am new to I/O settings and I am trying to use Labjack to send triggers to an EEG system (Biosemi), using the following code.
First the pins are set to high (according to the decimal trigger I need to sent, then the pins are all reset to zero. Between the two calls it was suggested to wait 0.002 sec (I guess to allow the system to read the channel). However, even though I get all my triggers, I also get random triggers (random value and random time).
I was wondering if this random triggers might have something to do with the WaitSec I am using. Is this WaitSec necessary?
Thanks
Mijs
% set n PINS to high
L.ljudObj.AddRequest (L.ljhandle, LabJack.LabJackUD.IO.PUT_DIGITAL_PORT, startChan, ecode, nbits, 0);
L.ljudObj.GoOne (L.ljhandle);
WaitSecs(.002);
% RESET PINS TO ZERO
L.ljudObj.AddRequest (L.ljhandle, LabJack.LabJackUD.IO.PUT_DIGITAL_PORT, startChan, ecode, nbits, 0);
L.ljudObj.GoOne (L.ljhandle);
With the current information I am unsure what would cause the random triggers. The U3 updates its digital I/O pins when sent the command/request to do so. The code you provided sets your pins to the "ecode" value twice with a 0.002 delay, and doesn't look like you are actually resetting the pins to zero which I assume is output-low on the U3 digital I/O. Try changing your second call like so and see if that helps:
L.ljudObj.AddRequest (L.ljhandle, LabJack.LabJackUD.IO.PUT_DIGITAL_PORT, startChan, 0, nbits, 0);
Regarding WaitSecs, the U3 doesn't need a software delay to update its digital I/O, and I assume the 0.002 second delay was suggested for the EEG system and the speed it can detect triggers. You can try without the delay and see that happens, but it is probably safer to keep the delay in.
Here are some additional things to consider and try:
1. Make sure your connections are secure in the U3's screw terminals and your EEG system.
2. There are delays on the U3 end when performing command-response communications (AddRequest sets up the command and GoOne performs the command-response USB communications). In the case of only updating digital I/O most of that delay is due to USB communications, and we document command-response times here:
https://labjack.com/support/datasheets/u3/operation/command-response
3. What is calling the code you provided? It performs one trigger, so check what is calling the code, if that timing is causing the random triggering and check how ecode is being set to ensure it is not being set "randomly" by mistake.
Thank you for your reply.
In the code above I do actually reset ecode = 0 before the second call (I forgot to paste that line), so it should do what I expect it to do.
In the EEG system I see my triggers set, e.g. to 34 and then I see a zero when the trigger channel resets to zero. So I though I had no problems with the coding.
I also fear it is something to do with the labjack screw terminal. We will test this with a standard parallel port (using the same code and a different labjack. THis would hopefully clarify whether the problem is at the labjack level or the EEG system level.
I was wondering if you could clarify one thing for me: the ghost triggers I received are always different from the last one sent and most of the time between one trigger and the following zero. To my understanding this can't be a timing issue, since in this case the ghost trigger should be an OR of the last trigger (e.g. 32 ) and the next which is always 0, therefore the OR result should again be 32, which is never the case. Is that correct?
Looking at the link provided, if my USB connection is not high-high, setting all the pins would take 4ms. I am sampling at 2048 HZ so again there should be plenty of time for the labjack to end the triggers.
Thanks
Mijs
What exactly is a "trigger" here? Is the EEG looking for a falling edge on one of its digital inputs, and whenever it sees that falling edge it does something? What exactly does the EEG do when it detects a trigger?
How many signals do you have connected to the EEG? If just one, consider using the simply eDO function to set the state to output-high or output-low. If more than one, why do you need more than one signal from the U3 to the EEG?