ADNS 3080 Optical Flow Sensor ansteuern

Hallo Leute,

ich habe gestern einen ADNS3080 optical Flow Sensor gekauft und wollte
die dx/dy Werte rauslesen. (siehe Anhang)
Um die Werte auszulesen benutze ich den Mikrocontroller Arduino Uno.

Folgende Pin-Belegung:

Arduino  ADNS3080
Pin 13: SCK
Pin 11: MOSI
Pin 12: MISO
Pin 10: SS
Pin 9: Reset
Pin 3,3V: 3V
Pin GND: GND

Wenn der Sensor mit einer Spannung versorgt wird, sollte eine kleine
Leuchte auf der Platine leuchten. Normalerweise sollte der Sensor
mittels 5V Betriebsspannung betrieben werden. Doch wenn ich den 5V Pin
mit meinem Mikrocontroller verbinde, leuchtet die Leuchte nicht.
Seltsamerweise leuchtet Sie mit 3,3V.

Den Code habe ich aus dem Internet übernommen, um zu gucken ob überhaupt
der Sensor funktioniert.

https://github.com/Neumi/OpticalFlowA3080ArduinoPr...

Doch irgendwie bekomme ich immer, dass mein Sensor nicht initialisiert
ist. Das heißt ich habe keine Kommunikation zu dem Sensor. Woran könnte
das liegen?
Habe den Code jetzt mit einen Mega und Uno versucht. Bei beidem die
selben Fehler...

Wenn ein Anschluß mit 3,3V beschriftet ist, würde ich das erst mal glauben. Ob der an einem 5V Controller funktioniert, würde ich erst mal bezweifeln.

Aber ich bekomme trotz allem keine richtige Kommunikation zum Sensor. Der ID-Wert des Sensor muss laut dem Register 0x17 23 sein, bei mir kommt immer 0 raus. Habe hier nochmal einen aktuelle Code von mir.

SPISettings spiSettings(2e6, MSBFIRST, SPI_MODE3); // 2 MHz, mode 3

// Register Map for the ADNS3080 Optical OpticalFlow Sensor
#define ADNS3080_PRODUCT_ID            0x00
#define ADNS3080_MOTION                0x02
#define ADNS3080_DELTA_X               0x03
#define ADNS3080_DELTA_Y               0x04
#define ADNS3080_SQUAL                 0x05
#define ADNS3080_CONFIGURATION_BITS    0x0A
#define ADNS3080_MOTION_CLEAR          0x12
#define ADNS3080_FRAME_CAPTURE         0x13
#define ADNS3080_MOTION_BURST          0x50

#define ADNS3080_PRODUCT_ID_VALUE      0x17

static const uint8_t Reset=9;
static const uint8_t NPD=8;

void setup() {
 Serial.begin(115200);
 while (!Serial); // Wait for serial port to open
 SPI.begin();

 pinMode(MOSI, OUTPUT);
 pinMode(MISO, INPUT);
 pinMode(SCK, OUTPUT);
 pinMode(SS, OUTPUT);
 pinMode(Reset, OUTPUT);
 pinMode(NPD, OUTPUT);


 //******Reset durchführen********
 digitalWrite(Reset, HIGH);
 delayMicroseconds(10);       //siehe Datenblatt 
 digitalWrite(Reset, LOW); 
 delayMicroseconds(500);    //siehe Datenblatt 
 //*******************************

 digitalWrite(NPD,HIGH);
 delay(75);                       //siehe Datenblatt 

}

int spiRead(uint8_t reg) {
 int MISO_Data;
 SPI.beginTransaction(spiSettings);
 digitalWrite(SS, LOW);

 SPI.transfer(reg); 
 delayMicroseconds(75); 
 MISO_Data= SPI.transfer(0x00); 

 digitalWrite(SS, HIGH);
 SPI.endTransaction();
 return MISO_Data;
}

void spi_read_Burst()
{
 int Motion,dx,dy,squal,shutter,shutter_low,maxx;
 
 SPI.beginTransaction(spiSettings);
 digitalWrite(SS, LOW);
 SPI.transfer(0x50);
 delayMicroseconds(75);
 
 Motion=SPI.transfer(0);
 dx=SPI.transfer(0);
 dy=SPI.transfer(0);
 squal=SPI.transfer(0);
 shutter=SPI.transfer(0);
 shutter_low=SPI.transfer(0);
 maxx=SPI.transfer(0);
 
 delayMicroseconds(4);
 digitalWrite(SS, HIGH);
 SPI.endTransaction();
 
 Serial.println(String(Motion)+" "+String(dx)+" "+String(dy)+" ");
}
void loop() {

 spi_read_Burst();
 Serial.println("ID"+String(spiRead(0x00)));

}

Ich würde es erst mal mit einer deutlich niedrigeren Taktrate versuchen, und auch mit etwas längeren Delays.

Der Sensor ist mir unbekannt, aber ich möchte nochmal auf #1 verweisen:

DrDiettrich:
Ob der an einem 5V Controller funktioniert, würde ich erst mal bezweifeln.

Einen Sensor mit 3,3 V an einen UNO/Mega mit 5 V auf den Datenleitungen zu verbinden, ist grundsätzlich keine gute Idee. Da sollte für SPI eine Pegelwandlung vorgesehen werden.

Verwendest Du das nackte IC oder eine Platine? Bei Platinen habe ich einen 5V-Pin neben GND gesehen. Hier könnte ein Link zur verwendeten Hardware nützlich sein, Dir zu helfen.

Hallo und vielen Dank für deine Antwort.
Ich nutze nicht das nackte IC, sondern habe eine vorgefertigte Platine gekauft.

Dazu der Link in Ebay:

Die 5V sind neben dem Grund, das ist korrekt. Ich hatte am Anfang auch direkt an die 5V gesteckt, weil ich allen Tutorials, die 5V benutzt wurden.

Ein "nichtleuchten" einer LED hört sich
zunächst mal nach kein Saft, oder zu viel Saft gehabt an.
Nur, weil ich interesse halber Deinem Link gefolgt bin...
(Siehe Anhang)

3-3 oder 5V.jpg

Hello!

I found a solution!

After weeks of going nuts over this sensor I could not get this sensor to work. I recruited many friends to look at this and still couldnt get it to work. I ended up giving up and buying another flow sensor.

I was using this same code from Neumi, Simon Winder and Lazalus and digging through the datasheet.

I believe I got it to work. So in all the examples the jumper cables are attached to the actual header pins 10,11,12,13 etc. These DO NOT work for some reason as indicated in this video :

I got this code to work by hooking up the serial pins(MOSI,MISO,SCK,RST,VCC,GND) to the ICSP header pins in the orientation as described in the image at the bottom of in this link; SPI - Arduino Reference

I have never encountered an issue with serial com in the digital pins on the side but for some reason this does not work.

I moved the CS pin to pin 10 and RST to pin 9 in my code that worked. I dont know if those need to be in any particular header also.

There are a lot of comments about this same issue around the web but I could not find a solution

Hello!

I found a solution! at least for me.

After weeks of going nuts over this sensor I could not get this sensor to work. I recruited many friends to look at this and still couldnt get it to work. I ended up giving up and buying another flow sensor.

I was using this same code from Neumi and Simon Winder and also spent a lot of time digging through the datasheet.

I believe I got it to work. So in all the examples the jumper cables are attached to the actual header pins 10,11,12,13 etc. These DO NOT work for some reason contrary to whats indicated in this video :

I got this code example code above to work by hooking up the serial pins(MOSI,MISO,SCK,RST,VCC,GND) to the ICSP header pins in the orientation as described in the image at the bottom of in this link; SPI - Arduino Reference

I have never encountered an issue with serial com in the digital pins headers VS ICSP but for some reason this does not work with this serial communication.

I moved the CS pin to pin 10 and RST to pin 9 in my code that worked. I dont know if those need to be in any particular header also.