Embedded Eye

Give your gizmo the gift of sight

Due to my need to develop some form of eyegaze mouse we have been (wife & I) using ardueye as an embedded first stage.  Here is where we have got so far.

1) Hooked up camera at close to correct focal lenght to eye

2) Established that the eye will track left and right and display in some form that we can use.

3) Worked out the drift in the system focusing on the eyeball (similar to a gyro drift).

We have success in the above three.

By just tracking one axis and not using accumulation we could work out the drift so the next step is to get a mega and repeat for two axis and either use the servo out, in arduino or send serial commands to a teensy board which has usb mouse routines on it.

Views: 2133

Comment by Geoffrey L. Barrows on February 11, 2013 at 9:53am

I was looking at my last reply and realized I gave you the wrong math. I must have had two glasses of wine with dinner that evening. (Sorry!!!)

You would run these two equations:

OFlowpass += alpha * (OFnewmeasurement - OFlowpass);

OFhighpass = OFnewmeasurement - OFlowpass;

OFnewmeasurement is an individual optical flow measurement- you get a new one every frame.

OFlowpass is a "low passed" version of the optical flow measurement that eliminates twitches. OFhighpass is the "high passed" version that includes twitches but eliminates slow drift.

You can even then run OFhighpass through it's own low-pass filter (with a larger alpha value) to remove glitches, e.g.

OFfinal += alpha2 * (OFhighpass - OFfinal)

In this case alpha2 would have to be larger than alpha. For example, you might choose alpha=0.1 and alpha2=0.5 or something like that.

Comment by Clinton McKinnon on February 11, 2013 at 6:03pm

Thanks

I see there is already the function in the code for low pass filter

ArduEyeOFO.LPF(&Filtered_OFlinear,&OFlinear,.35);

so will put in the high pass filter.

in essence what we had was the low pass filter on a low pass filter which actually gave us a function we might be able to use but first we will implement the above

thanks again

Comment by Clinton McKinnon on February 21, 2013 at 6:44pm

Swapped to using a teensy2++ board to lesson hardware requirements.  Changed the pin defs file in the library smh file and the example file so to run the usb 1286 which is close to a mega board but with usb connectivity. 

Pictures are of the set up and the processing sketch running the gui.  The light can be seen top left corner.

Comment by Clinton McKinnon on March 4, 2013 at 7:28pm

In an effort to cut down wiring we have gone to the teensy 2++ however not being one to shy away from frustration and a challenge have looked at using the teensy3 which is an ARM cortex processor.    One of the issues is that the teensy 3 pin mapping is not in port rows or even the gpiox are not in nice lines but the avr port, ddr, and pin is not the same as the ARM so it makes for introducing the ARM difficult for the novice programmer.  Don't get me wrong I take my hat off (if I could) to those who help out and develop modules and share what is 1000's of hours of time for free but I like the idea of being able to use existing code for Arduino that I can use and share my results.  I assume these difficulties are going to be the same for the Arduino Due .

Below is an example of the setting up ports on a teensy 3 in both arduino speak and directish access.

 

/* output test:

Teensy-3 Pin, GPIO Port, GPIO Bit #

4 A 13

5 D 7

6 D 4

7 D 2

8 D 3

9 C 3

=================

*/

byte pinTable[] = {4,5,6,7,8,9};

void setup() {

Serial.begin(9600);

//for (int i=0; i<6; i++) { pinMode(pinTable[i],OUTPUT); }

pinMode(4,OUTPUT);

pinMode(5,OUTPUT);

pinMode(6,OUTPUT);

pinMode(7,OUTPUT);

pinMode(8,OUTPUT);

pinMode(9,OUTPUT);

}

void loop() {

   GPIOA_PDOR = GPIOA_PDOR | 8192;

// digitalWrite(4,HIGH);

   delay(50);

   analogRead(0);

  GPIOD_PDOR = GPIOD_PDOR | 128;

//   digitalWrite(5,HIGH);

   delay(50);

   analogRead(1);

   GPIOD_PDOR = GPIOD_PDOR | 16;

  // digitalWrite(6,HIGH);

   delay(50);

   analogRead(2);

  GPIOD_PDOR = GPIOD_PDOR | 4;

// digitalWrite(7,HIGH);

   delay(50);

   analogRead(3);

  GPIOD_PDOR = GPIOD_PDOR | 8;

// digitalWrite(8,HIGH);

   delay(50);

   analogRead(4);

   GPIOC_PDOR = GPIOC_PDOR | 8;

// digitalWrite(9,HIGH);

   delay(50);

   analogRead(5);

  Serial.print(" pin4 "); 

Serial.print(analogRead(0));

  Serial.print(" pin5 "); 

Serial.print(analogRead(1));

  Serial.print(" pin6 "); 

Serial.print(analogRead(2));

  Serial.print(" pin7 "); 

Serial.print(analogRead(3));

  Serial.print(" pin8 "); 

Serial.print(analogRead(4));

  Serial.print(" pin9 "); 

Serial.println(analogRead(5));

delay(1000);

//  GPIOA_PDOR = GPIOA_PDOR | 0;

digitalWrite(4,LOW);

  delay(50);

   analogRead(0);

//   GPIOD_PDOR = GPIOD_PDOR | 0;

digitalWrite(5,LOW);

   delay(50);

   analogRead(1);

//  GPIOD_PDOR = GPIOD_PDOR | 0;

  digitalWrite(6,LOW);

   delay(50);

   analogRead(2);

  // GPIOD_PDOR = GPIOD_PDOR | 0;

   digitalWrite(7,LOW);

   delay(50);

   analogRead(3);

//  GPIOD_PDOR = GPIOD_PDOR | 0;

  digitalWrite(8,LOW);

   delay(50);

   analogRead(4);

//   GPIOC_PDOR = GPIOC_PDOR | 0;

digitalWrite(9,LOW);

   delay(50);

   analogRead(5);

  Serial.print(" pin4 "); 

Serial.print(analogRead(0));

  Serial.print(" pin5 "); 

Serial.print(analogRead(1));

  Serial.print(" pin6 "); 

Serial.print(analogRead(2));

  Serial.print(" pin7 "); 

Serial.print(analogRead(3));

  Serial.print(" pin8 "); 

Serial.print(analogRead(4));

  Serial.print(" pin9 "); 

Serial.println(analogRead(5));

delay(1000);

}

Comment by Geoffrey L. Barrows on March 6, 2013 at 9:24pm

If I am correct in understanding, it seems that the problem you are facing is that the Teensy 3 uses an ARM rather than an Atmel, so the bit-wise operations used to operate the Stonyman chip no longer operate. The key then would be in the ArduEye_SMH.h file, on lines 134 through 150. These define macros SMH1_ResP_Pulse and so on that pulse the four digital lines to the Stonyman chip. The macro versions on lines 142 through 148 are the default and won't work on the ARM. You want instead the macros on lines 135 through 138 which use the digitalWrite() function.

If I understand correctly, you probably would want to modify the ArduEye_SMH.h file so that only those macros on lines 135 through 138 are called, e.g. the ones using the digitalWrite function. You will need to modify them to the pins according to your setup. (From your picture it appears that you have digital 7 hooked up to the ResP pin- if so then you would need to change the SMH1_ResP_Pulse macro to pulse pin 7.) You will of course during initialization need to use pinMode to set the directions correct.

Does this make sense? Please let me know either way or if I misunderstand something.

Comment by Clinton McKinnon on March 6, 2013 at 10:31pm

Hi Geof

picture is of a teensy 2++ that we have working.  we did all the digital writes etc in the SMH.h file but the analog setup also barfs for the teensy 3.  also in the SMHcpp file, there is all the setup at the start for the bit registers which we had swapped for the pin set up - way out of my league but at least we were able to learn how to do low level register writes within Arduino for the ARM

Comment by Clinton McKinnon on March 8, 2013 at 6:40pm

Have teensy 3 ARM chip running a stonyman breakout board just seems noise and timing issues code posted on teensy forum last zip file. 

http://forum.pjrc.com/threads/19245-teensy3-and-ardueye-stonyman-vi...

Comment by Geoffrey L. Barrows on March 10, 2013 at 11:40pm

What are the actual values you are getting off the chip in that case?

When trying a new processor with a Stonyman chip, the first thing I like to do is to just pick one pixel and print the raw value (e.g. numerical value) over and over again to the Serial port (or equivalent) and verify that it changes as I move a light over it. More light = lower value.

Comment by Clinton McKinnon on March 11, 2013 at 7:24pm

Thanks but it barffed when I tried to select a coloum or a row.  Have reworked the SMH  files so will have another look but I noticed by using digital write there is a difference between how the USB1286 behaves and the 32U4 using the same code.  So I suspect going to the ARM has introduced some big timing issues due to how the ARM is simulated using ditial write

Comment by Clinton McKinnon on March 11, 2013 at 8:02pm

Link to zip file with digital write instead of using pin header file

http://forum.pjrc.com/threads/19245-teensy3-and-ardueye-stonyman-vi...

Comment

You need to be a member of Embedded Eye to add comments!

Join Embedded Eye

© 2022   Created by Geoffrey L. Barrows.   Powered by

Badges  |  Report an Issue  |  Terms of Service