groupgets / pylepton

Quick and dirty pure python library for interfacing with FLIR lepton
MIT License
208 stars 93 forks source link

Shutter closes and opens w/ Pi 4 #56

Closed TinManAkshay closed 3 years ago

TinManAkshay commented 3 years ago

Hi,

I've been successful with Lepton 2.5 w/ Breakout board v2.0 and Pi 3 B+ using these libraries. However, when I run the same thing w/ Pi4, I get frequent shutter closes and opens on power on. Its about every 3-5 seconds. Additionally, data coming out of my other sensors connected on I2C protocol freeze and come back alive and then repeat. Although, lepton 2.5 never worked properly.

  1. Earlier I thought it could be a power issue but that didn't seem like it. I have tried giving supply from both adapter and portable battery. But that didn't fix anything.
  2. It seems like its doing FCC over and over again. In other words, Lepton gets faulty signal to perform an FFC. I double checked all wiring, its correct only.

I don't know what's this behavior when I switched to Pi 4. Has anyone gone through this situation or have any clues about the root cause and potential methods to fix the problem? Will appreciate all the info. I could get here.

Thanks, Akshay

kekiefer commented 3 years ago

I don't know about your FFC issues, but regarding differences between older raspbian releases and those that support pi4, there was some frequency scaling features added that can affect SPI transfer rates. To stop the frequency scaling, you can try the following:

sudo sh -c "echo performance > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor"
TinManAkshay commented 3 years ago

Hi,

Thank you for that suggestion and I did make that change.

  1. I installed cpufrequtils and I changed GOVERNOR = performance as a default option. Now the frequency has been changed from 700Mhz to 1.5Ghz. I believe there is no issue on that.
  2. Also, I have increased the SPI buffer size to 65536.
  3. I changed SPI_MESSAGE_LIMIT = 59 for better spi reading. I hope that does not create issues too.

What's your feedback on three changes I made as stated above?

Thanks, Akshay