I am using ADNS3080 optical flow in raspberry pi 3. I set SPI connection between raspberry and ADNS3080 optical flow. I used spidev library for reading values in python. I want to read delta_x and delta_y position which registers corresponding to 0x03 and 0x04 numbers in datasheet. So I am using this code for reading registers:

import spidev
import time
spi = spidev.SpiDev()
while True:
   resp = spi.xfer2([0x03, 0x04])
   print resp

I am taking "0,0" results in every loop. I have checked the connections hardware and there are no problems. What is the reason why I can't read these values?

  • Hello @erenpostaci, Welcome and nice to meet you. Ah, let me see. (1) Are you sure your mouse is not in NPD (Power Down Mode)? (2) Are you sure you can spi.xfer2 both ∆x and ∆y registers in a row? To troubleshoot, perhaps you can just do ∆x first. (3) I understand you have double checked hardware wiring (open short tests with a multimeter, I suppose), but I strongly recommend to do SPI loopback to make sure the software side is also OK. Reference: imgur.com/gallery/uxYDTgz. PS - You can search "SPI, loopback" in this forum for my fully debugged, newbie friendly SPI loopback programs. – tlfong01 Feb 20 at 1:36
  • I read the datasheet page 16 saying the following: "Read Operation - A read operation, defined as data going from the ADNS3080 to the micro-controller, is always initiated by the micro-controller and consists of two bytes. The first byte contains the address, is sent by the micro-controller over MOSI, and has a “0” as its MSB to indicate data direction. The second byte contains the data and is driven by the ADNS-3080 over MISO. The sensor outputs MISO bits on falling edges of SCLK and samples MOSI bits on every rising edge of SCLK. / to continue, ... – tlfong01 Feb 20 at 1:45
  • So I guess that to read ∆x register, you should try this: spi.xfer2(∆x-register-addr, dummy-byte). Let me know if my guess is correct. Cheers. – tlfong01 Feb 20 at 1:48
  • @tlfong01 thank you for your answer. I have used optical flow board not ADNS-3080 microcontroller. Also you can look in this link . I checked connection. Also I have checked in ardunio uno board. And I can get values from this board. What can you suggest code for get position in python? – erenpostaci Feb 20 at 12:02
  • Ha, I am confused. The first sentence in your question is: "I am using ADNS3080 optical flow in raspberry pi 3", Just now you are saying: "I have used optical flow board not ADNS-3080 microcontroller". I need to followed the link you just gave me, to clear my mind. See you later. – tlfong01 Feb 20 at 12:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.