Thread Tools  
QinXinlan
Junior Member
 
Join Date: Apr 2017
QinXinlan is on a distinguished road Posts: 4
Hello,

I am trying to set-up an experiment where EEG, eye-tracking signals and a high-speed camera all record data simultaneously.
Our lab already has Neuroscan for EEG acquisition, Tobii TX300 for eye-tracking with Stimtracker, and a Phantom M310 for the high-speed camera. We also have the E-prime software with the Extension for Tobii.

I need to setup a master clock that would send event markers to both Neuroscan and Tobii, as well as control the high-speed camera. I (nearly) already solved the problem of linking all the equipments and send the Event Markers as well as the control signal.
My problem is the timing of this master clock. At first, I though I would use the light sensor provided with the Stimtracker, and display a black or white rectangle on the Tobii TX300 screen. However I need to send markers every 4 ms, and the vertical sync frequency of the Tobii TX300 screen unit is between 49 and 75 Hz, so not fast enough.

Thus I thought of using an Arduino as the master clock, which would send a 5V square-wave signal with a 4 ms period to the TTL input on Stimtracker trough an Ethernet cable (RJ45). Does that work in theory? Can Stimtracker receive and process such a "fast" signal?
Also do you have any other suggestion on how to create this master clock? The easier the better.

Thank you very much for your advice.
Best regards,
Reply With Quote
Hisham
Founder
 
Join Date: Aug 2006
Location: San Pedro, CA
Hisham is on a distinguished road Posts: 1,153
Posted April 13th, 2017 #2
StimTracker will have no problem at all processing a 4ms TTL input pulse. As you can see on the Specifications page, the latency is just 0.01ms, or 10Ķs.

I suggest that you verify that your other equipment can handle 4ms. I have no idea what the Phantom and TX300 can do, but Neuroscan has provided us with the following info about pulse durations:

- NuAmps requires a minimum of 5ms

- SynAmpsRT and Neuvo can pick up pulses as narrow as 50microseconds

- Grael minimum pulse duration is 1ms

More broadly, do you really need to send a periodic pulse? One big advantage of StimTracker for Tobii TX300 is that the signals are delivered simultaneously (with zero delay) on both the TX300 port and the EEG port. So event markers are in sync across all devices. Sending a periodic pulse might add clutter to your data, especially on the TX300 because that device has only a single bit of input. So if you also want to detect light sensor onset, it will become more difficult to distinguish on that single line if the pulse is coming from the light sensor or from the Arduino.
Reply With Quote
QinXinlan
Junior Member
 
Join Date: Apr 2017
QinXinlan is on a distinguished road Posts: 4
Posted April 14th, 2017 #3
Dear Hisham,

Yes my other equipment have no problem handling 4ms (or less). I was thinking of using the Stimtracker as a "relay" to instantaneously send the signal to the other devices.

Thus I only need to send a 5V square-wave signal with a 4 ms period to the TTL input on Stimtracker trough an Ethernet cable (RJ45). I have an Arduino MEGA 2560 and an Ethernet Shield W5100 to plug the Ethernet cable.

I am not very familiar with Arduino and sending signal through Ethernet, but can I send this square signal through UDP (User Diagram Protocol)? Or should I send it using TCP/IP?

I have written this code so far:

// Arduino is the client, it will send requests to the Stimtracker (the server)

#include <Ethernet.h> // Load Ethernet library: work with Arduino Ethernet Shield W5100
#include <EthernetUdp.h> // Load UDP (User Datagram Protocol) library: to send and receive packets over UDP
//unlike TCP, it is connectionless, meaning that it doesn't require any waiting for acknowledgement of a successful data transmission
// potential problem: failed transmissions will go undetected --> "fire and forget" protocol
#include <SPI.h> // Load the SPI library: to communicate with Serial Peripheral Interface (synchronous serial data protocol),
// with the Arduino as the master device

// might need to change the mac and the ip address, I'm not even sure we really need it...
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xEE}; // Assign a mac address: physical address of the Arduino
IPAddress ip(10, 1, 15, 243); // Assign an IP address, might need modification

unsigned int localPort = 5000; // Assign a Port to talk over
char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; // array to send data,
// the dimension is the maximum size of odd packet that I can send
String datReq; // easier to work with strings, but don't know how to send string through UDP, so using the array of characters
// string for our data
int packetSize; // Size of the packet

EthernetUDP Udp; // object to interact with the UDP functions


void setup() {
// put your setup code here, to run once:
Serial.begin(9600); // Turn on Serial Port
Ethernet.begin(mac, ip); // Initialize Ethernet
Udp.begin(localPort); // Initialize Udp
delay(1500); //delay to make sure everything has time to get initialized before we move on

}

void loop() {
// put your main code here, to run repeatedly:
int state = 0;
// By default we start at 0V

while(1){
if(state ==0){
// everytime we are at state=0, it means that the PIN sends 0V or is at LOW
// digitalWrite(PIN, LOW); // that was for sending through PIN

Udp.beginPacket(Udp,remoteIP(),Udp.remotePort()); //Initialize packet send
Udp.print("I am sending a string that says 0V, but I want to send a value"); // send string to Stimtracker
Udp.endPacket(); // packet has been sent

// then we change the state to 1
state = 1;
}

else {
// everytime we are at state=1, it means that the PIN sends 5V or is at HIGH
// digitalWrite(PIN, HIGH); // that was for sending through PIN

Udp.beginPacket(Udp, remoteIP(), Udp.remotePort()); //Initialize packet send
Udp.print("I am sending a string that says 5V, but I want to send a value"); // send string to Stimtracker
Udp.endPacket(); // packet has been sent

// then we change back the state to 0
state = 0;
}

memset(packetBuffer, 0, UDP_TX_PACKET_MAX_SIZE); // to clear the array
delay(4);
// The delay corresponds to the period of the square-wave, meaning time at 0v + time at 5V
// For controlling the high-speed camera, this period is 4 ms

}


As I said, I am not very familiar with sending signal as a voltage value through an Ethernet cable. If instead of:
Udp.print("I am sending a string that says 5V, but I want to send a value");

I write:
Udp.print("5");

Will Stimtracker detect it as a valid input?

Thank you for your answer,
If you have any suggestions, please let me know.
Reply With Quote
Hisham
Founder
 
Join Date: Aug 2006
Location: San Pedro, CA
Hisham is on a distinguished road Posts: 1,153
Posted April 14th, 2017 #4
I really canít help with debugging code, but the approach is incorrect. StimTrackerís TTL Input happens to use the same R45 physical connector that is used by Ethernet, but it uses TTL signals and not Ethernet signals.

What you need to do instead is use the TTL / digital output features of the Arduino. This implies that you need to cut one side of the RJ45 cable and somehow connect the wires to the Arduino board. But on the positive side, this should be quite a bit easier to write software for.
Reply With Quote
QinXinlan
Junior Member
 
Join Date: Apr 2017
QinXinlan is on a distinguished road Posts: 4
Posted April 14th, 2017 #5
Aha,

Yes it is much more easy this way then. So let me resume, I only need to send one TTL input with the appropriate period to, for example, Accessory Connector line AC1, send a continuous +5V to Pin 7 and send a continuous 0V to Pin 8. And it should work, correct?

Thanks very much for your help!
Reply With Quote
Hisham
Founder
 
Join Date: Aug 2006
Location: San Pedro, CA
Hisham is on a distinguished road Posts: 1,153
Posted April 15th, 2017 #6
Itís better that you do not connect to pin 7 (+5V). All you need is one of the data lines at least, e.g. AC1, and ground.
Reply With Quote
QinXinlan
Junior Member
 
Join Date: Apr 2017
QinXinlan is on a distinguished road Posts: 4
Posted April 20th, 2017 #7
Thanks a lot, it works!
Reply With Quote
Hisham
Founder
 
Join Date: Aug 2006
Location: San Pedro, CA
Hisham is on a distinguished road Posts: 1,153
Posted April 20th, 2017 #8
Youíre welcome.
Reply With Quote
Brad77
Junior Member
 
Join Date: Aug 2017
Brad77 is on a distinguished road Posts: 1
Here is a little venture I made for a companion of mine. Its a programmable hand-off/clock. All hand-off circumstances are included utilizing the web interface. It just uses 2 segments, 4 Dupont wires, and a 5-volt divider wart. The principal module is from Olimex and has an ESP8266-EVB with 2M, control supply, catch, transfer and gpio pins. The show is an I2C module from Adafruit. The Olimex board has the pullups on GPIO 2 and GPIO 4 as of now for the I2C (how helpful). There are more things that can be included obviously, as diminish the show with a slider or at a specific time, or disposing of the 30-second start up time, and so forth. I am not the best coder, so on the off chance that you see something that can be enhanced, please told me.

When you initially control it up and it hasn't associated with your wifi organize, it will show 192 then 168 then 4 then 1, at that point you would interface with the AP and go to 192.168.4.1 in your program. It will show a straightforward website page to request your wifi information at that point reboot. It will then show the IP address so you can interface with it utilizing a program. It will then simply show the present time and check each second to check whether the hand-off ought to be on or off. It will likewise modify for the light investment funds time. You can likewise flip the hand-off from the site page. The stand is 1/8" acrylic that was twisted utilizing a hotwire drinking spree. Other than assembling the adafruit show, there is no other binding vital.

The on board catch has 2 operations. On the off chance that you squeeze it rapidly, it will flip the transfer. On the off chance that you hold it for over 2 seconds and discharge, it will show its IP address in the event that you overlook it.

I think it would be extremely useful for you!
Reply With Quote
Hisham
Founder
 
Join Date: Aug 2006
Location: San Pedro, CA
Hisham is on a distinguished road Posts: 1,153
Posted August 14th, 2017 #10
Thanks. However, the just announced StimTracker 2G model has this feature built-in and can generate a master clock (or even multiple clocks on different lines) via a software command. This feature is described on the c-pod page:
https://cedrus.com/c-pod/features.htm
Reply With Quote
Thread Tools
Posting Rules
Forum Jump:
© Copyright Cedrus Corporation, 1991-2014.
All times are GMT -7. The time now is 12:01 PM.