timing marks, buffering delays, etc.
Dear all,
I modified OpenBCI_GUI. I tried to recorded trigger data from another Processing sketch.
I send data from my program to OpenBCI_GUI over UDP library in processing (oscP5).
I measured running time after starting OpenBCI_GUI and then saved together with EEG raw data.
I measured running time using Processing function >>> millis().
You can see running time in the first column below.
My question is about yellow lable in saved data. In that time, trigger data was sent from my program to OpenBCI_GUI.
Are there any lost of EEG data during that delayed period ?
Could you give me any suggestion, please ?
20198, 67, -6180.75, -6262.56, -6203.23, -6260.03, -134016.05, -91871.30, -134522.69, -107017.73, 0.00, 0.00, 0.00
20198, 68, -6188.73, -6274.20, -6210.52, -6271.94, -134024.41, -91883.91, -134531.25, -107026.16, 0.00, 0.00, 0.00
20198, 69, -6192.86, -6280.91, -6214.16, -6278.83, -134028.08, -91890.34, -134534.77, -107029.49, 0.00, 0.00, 0.00
20198, 70, -6188.68, -6274.96, -6210.32, -6272.66, -134023.09, -91883.30, -134529.61, -107024.22, 0.00, 0.00, 0.00
20199, 71, -6181.40, -6264.52, -6203.70, -6262.00, -134016.00, -91872.69, -134522.42, -107017.31, 0.00, 0.00, 0.00
20199, 72, -6177.82, -6259.70, -6200.28, -6257.24, -134013.39, -91868.70, -134520.03, -107015.05, 0.00, 0.00, 0.00
20641, 73, -6185.08, -6270.65, -6206.95, -6268.41, -134021.14, -91880.64, -134527.92, -107022.92, 0.00, 0.00, 0.00
20642, 74, -6189.33, -6277.44, -6210.72, -6275.21, -134024.97, -91887.26, -134531.61, -107026.43, 0.00, 0.00, 0.00
20642, 75, -6187.50, -6273.93, -6209.23, -6271.43, -134022.33, -91882.54, -134528.81, -107023.59, 0.00, 0.00, 0.00
20642, 76, -6180.95, -6264.30, -6203.28, -6261.66, -134015.98, -91872.57, -134522.38, -107017.35, 0.00, 0.00, 0.00
Comments
It's unclear to me at the moment if your delay issues are because of the UDP you mention, or because of the latency adjustment explained below.
From your other screen snapshots it looks like you are running Windows (Windows 7?) The VCP, Virtual COM Port driver from FTDI has a Latency Timer that can be manually adjusted. Using the default settings supplied with the driver may result in larger buffering delays. Try adjusting it as follows:
In Control Panel / Device Manager / Ports / USB Serial Port (your COM port for the dongle) / Port Settings / Advanced -- (whew), is a setting called "Latency Timer" in milliseconds. This is an FTDI specific item that controls how responsive the link is. At the default of 16ms, you may see longer buffering pauses. After changing this to 1ms, the buffering pauses should improve. We don't believe there is any noticeable CPU penalty for this change, since the amount of data is small.
Can you try that and post some similar debug output as you did before? I'd like to see how the millisecond values are advancing.
William
PS the approximately half second delay shown between your yellow lines above -- I don't believe could be the Latency Timer issue. So perhaps you are right, you may be doing some kind of blocking IO operation with UDP that occasionally locks things up for longer periods. Still the Latency Timer adjustment should improve things.
Here, I used the latest version of GUI from openbci website. I added this in to your program. Highlight only.
I think that oscEvent from oscP5 library might interrupt serial event.
BTW, Your suggestion about latency setting was quite useful.
The spikes look like they are happening at 2.5 second intervals. Sounds like a file buffering operation to me.
http://docs.openbci.com/tutorials/04-External_Trigger_32bit_Example
Joel @biomurph may have further comments, but the D18
pin you refer to is on the chipKIT 32 bit boards. I think you can
translate this to the 8 bit boards with some minor changes to use the A
pins.
William
int triggerPin = A0;
byte triggerValue;
void setup(){
...
pinMode(triggerPin, INPUT);
...
}
void setup(){
...
pinMode(triggerPin, INPUT);
...
}
void loop(){
...
triggerValue = digitalRead(triggerPin);
OBCI.sendChannelData(sampleCounter,triggerValue);
...
}
OpenBCI_8.h:
void sendChannelData(byte, byte);
OpenBCI_8.cpp:
void OpenBCI::sendChannelData(byte sampleNumber, byte x){
Serial.write(sampleNumber); // 1 byte
ads.writeADSchannelData(); // 24 bytes
//accel.writeLIS3DHdata(x); // 6 bytes
Serial.write(x);
Serial.write(x);
Serial.write(x);
Serial.write(x);
Serial.write(x);
Serial.write(x);
}