Embedded Eye

Give your gizmo the gift of sight

I've started playing with the centeye8 and you can see it attached to the arduPilotMega above.  It's generally working - i can get back data packets with the six values (x,y, totals + averages).

 

One issue though is that sometimes the packets coming back seem to be interrupted.  I.e. if you look at the 3rd row below what's being returned for the last 3 values in the packet looks more like it's actually the first 3 values of the next packet.

 

 

 

 

 

 

 

The code that I'm using is below.  I'm wondering if anyone has any ideas about this.  By the way, I'm quering the sensor at about 50hz.

 

int AP_Mouse_CEYE8::read()
{
 int i = 0;
 char buf[6];

 Wire.beginTransmission(CEYE8_ADDRESS); //connect to sensor
 Wire.send(CEYE8_COMMAND);          // sends address to read from
 Wire.send(CEYE8_COMMAND_ARG_GET_FLOW);   //
 if( Wire.endTransmission() != 0 ) {    //end transmission
     return CEYE_FAIL;
 }

 Wire.requestFrom(CEYE8_ADDRESS, 6);    // request 6 bytes from device
 
 while(Wire.available() && i < 6) {
  buf[i] = Wire.receive();  // receive one byte
  i++;
  delayMicroseconds(100);
 }

 if( i == 6 ) {  // some bytes received?
     last_update = millis();
     x = buf[0];
  y = buf[1];
  x_tot = buf[2];
  y_tot = buf[3];
  x_avg = buf[4];
  y_avg = buf[5];
  return CEYE_SUCCESS;
 }else{
     return CEYE_FAIL;
 }
}

Views: 134

Reply to This

Replies to This Discussion

Hi Randy,

Using an Arduino, I was able to replicate your result. Yes there seems to be a bug somewhere. We should have done a bit more QC before fully using this firmware version. I guess a reasonable hack-around for now would be to just throw away the packet if you get the first three values equaling the last three values, though we'll have to do a firmware update.

Do you have an ISP?

Geof

hey no problem.  I do have an ISP and I think I will dive into the firmware and figure out what's going on.
Thank You, though I'll dive in too! I'm pretty sure you have version 6 of the firmware, since yours is from the December batch.

Hi Goef,

    I don't think this is the issue because it doesn't explain the behaviour, but at around line 415 of ApplicationPrototype.c it seems to be using OFout1, but I would have thought it should be using pOFout which points to the latest output array (i.e. switches back and forth around line 677).

// Returns the optical flow array
case COMM_ATT_OFOUT1:
    xmtbuf.comm_att = COMM_ATT_OFOUT1;

    xmtbuf.read = OFout1.read;
    xmtbuf.read_length = OFout1.read_length;
    xmtbuf.locked = &(OFout1.locked);

    //xmtbuf.read = pOFout->read;
    //xmtbuf.read_length = pOFout->read_length;
    //xmtbuf.locked = &(pOFout->locked);
    break; 

 

By the way, which programmer do you use to program the centeye8?  I'm having some trouble using this stk500 from sparkfun.  I don't have all my tools with me at the moment though so I might have messed up the wiring.

 

-Randy

Hi Randy,

Thank You for pointing that out. Yes there is something fishy there. I need to allocate a time to focus on that code and see what is going on. (It might have something to do with Chris Shake's problem.)

Regarding programmers- we like to use the ISP mkII from Atmel- it costs $29 from Digikey.

Geof

RSS

© 2022   Created by Geoffrey L. Barrows.   Powered by

Badges  |  Report an Issue  |  Terms of Service