Eye writer 2

Thread Starter

shyckh

Joined Jul 28, 2014
26
i am working on eyewriter 2. i have made the project following the instructions on http://www.instructables.com/id/The-EyeWriter-20/. and also i took help from http://interlab.ycam.jp/projects/labact/eye-tracking-study/how-to-make-eyewriter2 this site. the problem i am facing is called stobing. when i disconnect pin 3 of arduino the leds lights up other wise they remain off. any one can help me on that? the circuit diagram can be found at http://www.instructables.com/id/The-EyeWriter-20/step11/Full-Circuit/.

More information:

the arduino code for the project is:

Code:
/*
StrobeEye


The strobe (also called vertical sync) from a camera is broken out and
drives an interrupt on pin 3 (interrupt 1). The loop() uses the offset
defined by vsync() to determine whether the LEDs on pin 11 or the LEDs
on pin 12 should be on.
*/

/*
This should be set to the same fps you expect the camera to capture at.
*/
const float fps = 30;

/*
If you are using a PS3Eye or other rolling shutter camera, you also
need to set the exposure. An exposure value of 1 means the camera is
exposing half the sensor at any given moment, and an exposure value of
0 means the sensor is exposing only one row at any given moment.
*/
const float exposure = 1;

/*
For nicer cameras with global shutters, define USE_GLOBAL_SHUTTER.
This will disable the use of the exposure variable, and leave the LEDs
on as long as possible.
*/
//#define USE_GLOBAL_SHUTTER

/*
Most cameras have a strobe signal that is tied to HIGH, and brought to
LOW when a frame is captured. If you are buffering the signal with a
transistor, this will invert the behavior and the polarity of the change
will probably be RISING. If you are tapping the strobe directly, the
polarity will probably be FALLING.
*/
const int polarity = RISING;

/*
Feel free to use different LED output pins.
*/
const int glintPin = 11;
const int pupilPin = 12;

/*
The rest of the code shouldn't change between setups.
*/
const int interrupt = 1;
volatile unsigned long offset = 0;
volatile boolean firstFrame = true;
const float microScale = 1000000;
const float totalTime = microScale / fps;
const float cutoff = 1 - (exposure / 2);

float position;

void setup() {
pinMode(pupilPin, OUTPUT);
pinMode(glintPin, OUTPUT);
attachInterrupt(interrupt, vsync, polarity);
}

void loop() {
position = (float) (micros() - offset) / totalTime;
#ifdef USE_GLOBAL_SHUTTER
  if(position < 1) {
   digitalWrite(pupilPin, HIGH);
   digitalWrite(glintPin, LOW);
} else {
   digitalWrite(pupilPin, LOW);
   digitalWrite(glintPin, HIGH);
}
#else
if(position < cutoff) {
   digitalWrite(pupilPin, HIGH);
   digitalWrite(glintPin, LOW);
} else if (position > 1 && position - 1 < cutoff) {
   digitalWrite(pupilPin, LOW);
   digitalWrite(glintPin, HIGH);
} else {
   digitalWrite(pupilPin, LOW);
   digitalWrite(glintPin, LOW);
}
#endif
}

void vsync() {
firstFrame = !firstFrame;
if(firstFrame)
   offset = micros();
}
Circuit Diagram Explanation:


The link provided above shows the diagram which can be operated as:
when the signal from vsyn appeared on the base of npn transistor it will be amplified and fed to pint 3 of arduino as an interrupt. arduino checks for the interrupt and give appropriate signal to pin 11 and 12 of arduino which triggers the two FET's so that leds connected with these FET's will flicker out of phase with respect to central Ring (Led ring)
 
Last edited by a moderator:

wayneh

Joined Sep 9, 2010
17,498
That schematic is not really a schematic - it's a cartoon of a breadboard. That's useful for building a copy but not so much for diagnostic work. Do you have an actual schematic? Sorry if it's there and I missed it, but I didn't see one there.
 

Thread Starter

shyckh

Joined Jul 28, 2014
26
That schematic is not really a schematic - it's a cartoon of a breadboard. That's useful for building a copy but not so much for diagnostic work. Do you have an actual schematic? Sorry if it's there and I missed it, but I didn't see one there.
 

Attachments

Thread Starter

shyckh

Joined Jul 28, 2014
26
i am working on eyewriter 2. i have made the project following the instructions on http://www.instructables.com/id/The-EyeWriter-20/. and also i took help from http://interlab.ycam.jp/projects/labact/eye-tracking-study/how-to-make-eyewriter2 this site. the problem i am facing is called stobing. when i disconnect pin 3 of arduino the leds lights up other wise they remain off. any one can help me on that? the circuit diagram can be found at http://www.instructables.com/id/The-EyeWriter-20/step11/Full-Circuit/.

More information:

the arduino code for the project is:

Code:
/*
StrobeEye


The strobe (also called vertical sync) from a camera is broken out and
drives an interrupt on pin 3 (interrupt 1). The loop() uses the offset
defined by vsync() to determine whether the LEDs on pin 11 or the LEDs
on pin 12 should be on.
*/

/*
This should be set to the same fps you expect the camera to capture at.
*/
const float fps = 30;

/*
If you are using a PS3Eye or other rolling shutter camera, you also
need to set the exposure. An exposure value of 1 means the camera is
exposing half the sensor at any given moment, and an exposure value of
0 means the sensor is exposing only one row at any given moment.
*/
const float exposure = 1;

/*
For nicer cameras with global shutters, define USE_GLOBAL_SHUTTER.
This will disable the use of the exposure variable, and leave the LEDs
on as long as possible.
*/
//#define USE_GLOBAL_SHUTTER

/*
Most cameras have a strobe signal that is tied to HIGH, and brought to
LOW when a frame is captured. If you are buffering the signal with a
transistor, this will invert the behavior and the polarity of the change
will probably be RISING. If you are tapping the strobe directly, the
polarity will probably be FALLING.
*/
const int polarity = RISING;

/*
Feel free to use different LED output pins.
*/
const int glintPin = 11;
const int pupilPin = 12;

/*
The rest of the code shouldn't change between setups.
*/
const int interrupt = 1;
volatile unsigned long offset = 0;
volatile boolean firstFrame = true;
const float microScale = 1000000;
const float totalTime = microScale / fps;
const float cutoff = 1 - (exposure / 2);

float position;

void setup() {
pinMode(pupilPin, OUTPUT);
pinMode(glintPin, OUTPUT);
attachInterrupt(interrupt, vsync, polarity);
}

void loop() {
position = (float) (micros() - offset) / totalTime;
#ifdef USE_GLOBAL_SHUTTER
  if(position < 1) {
   digitalWrite(pupilPin, HIGH);
   digitalWrite(glintPin, LOW);
} else {
   digitalWrite(pupilPin, LOW);
   digitalWrite(glintPin, HIGH);
}
#else
if(position < cutoff) {
   digitalWrite(pupilPin, HIGH);
   digitalWrite(glintPin, LOW);
} else if (position > 1 && position - 1 < cutoff) {
   digitalWrite(pupilPin, LOW);
   digitalWrite(glintPin, HIGH);
} else {
   digitalWrite(pupilPin, LOW);
   digitalWrite(glintPin, LOW);
}
#endif
}

void vsync() {
firstFrame = !firstFrame;
if(firstFrame)
   offset = micros();
}
Circuit Diagram Explanation:


The link provided above shows the diagram which can be operated as:
when the signal from vsyn appeared on the base of npn transistor it will be amplified and fed to pint 3 of arduino as an interrupt. arduino checks for the interrupt and give appropriate signal to pin 11 and 12 of arduino which triggers the two FET's so that leds connected with these FET's will flicker out of phase with respect to central Ring (Led ring)
 

Attachments

wayneh

Joined Sep 9, 2010
17,498
Divide and conquer. If you remove the Arduino and simulate its functions manually, does it all work? In other words, when you take the MOSFET gates high, do the LEDs turn on? Perhaps you already know the problem is with controlling the Arduino?

Those gates should have pull-down resistors on them to ensure they go of if the Arduino signal goes "open". Also, did you draw those MOSFETs? I think the body diodes are backwards since they would conduct all the time as shown, regardless of the gate voltage.
 

Thread Starter

shyckh

Joined Jul 28, 2014
26
thanks for reply... mosfet remain conducting until the gate signal force them to turn off or to flicker. i have sorted the problem.
 

Thread Starter

shyckh

Joined Jul 28, 2014
26
The transistor dose not switching properly. Tried different transistor. Any help how can i perform switching
 

wayneh

Joined Sep 9, 2010
17,498
Perhaps you have the pinout wrong? It's very hard to diagnose without a picture. Is the Arduino ground shared with MOSFET ground?
 

wayneh

Joined Sep 9, 2010
17,498
Are you referring to T1 in the schematic you provided in #4, the 2N2222 ? Have you checked the pinout of your transistor against what the author of that drawing had? Sounds crazy, but they are not always identical.

Do you have an oscilloscope?
 
Top