Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPI #3

Open
3YY3 opened this issue Dec 12, 2017 · 7 comments
Open

SPI #3

3YY3 opened this issue Dec 12, 2017 · 7 comments
Assignees

Comments

@3YY3
Copy link

3YY3 commented Dec 12, 2017

Hi, I have a problem with running the program. When "Player" is executed in terminal can be seen that it opens and closes the SPI communication to the infinity. Some frames are visible on the screen (like 1 frame per 5 sec.), rest it is looking like the camera is freezed. What can cause this issue?
I´m using Rpi Zero, Jessie, Lepton v3. The processor indicator is not even windy, shows around 40% used computing capacity.
When I try to run "PlayerThread" the processor is used whole, 100%. Almost no frames can be seen and it makes Rpi unuseable unless hard restart is done.

@cosmac
Copy link
Owner

cosmac commented Dec 19, 2017

"When I try to run "PlayerThread" the processor is used whole, 100%."
PlayerThread is using a parallel thread to grab the frames from Lepton. In this way, when you ask for a frame, the latest one read will be returned. Anyway, your Rpi Zero has one core only, so the parallel thread is not actually parallel. The multi-threading overhead while using a single core CPU is too high. For this reason, I would not recommend Rpi Zero with the parallel interface. Please use the serial one.

@cosmac
Copy link
Owner

cosmac commented Dec 19, 2017

Now, I never tested my lib with Rpi Zero (only Rpi 2 and 3). My guess, the SPI resets can be the result of a loss in sync with Lepton.
Please try to increase the number of packets read in one SPI read call. e.g. set packets_per_read to 5, you can find this in LeptonCommon.h

@3YY3
Copy link
Author

3YY3 commented Jan 3, 2018

Well, increasing the number of packets_per_read helped a little. But it is really only small quallity improvement. I found that Rpi Zero has problem with electric interference. Output is much better, if I disconnect usb keyboard. So I think that missing frames is not a software problem but hardware.

@cosmac
Copy link
Owner

cosmac commented Jan 9, 2018

That could be the case. If I put my hands on a Rpi Zero I will try to debug this behavior too. Thanks !

@3YY3
Copy link
Author

3YY3 commented Feb 14, 2018

Uhh, have everything including battery power source inside a faraday cage, yet still not working properly. After a short reading of Rpi 2,3 and Zero differences I have to ask: how the spi speed is set in the program? I have only found setting the speed in Hz in LeptonCommon.h but how is this value interpreted by Rpi? How does it sets the divider? I have tried to find this reading though the program with no success.

@cosmac
Copy link
Owner

cosmac commented Feb 15, 2018

Searching the web, I found many problems with the SPI, since this is based on the CLK and a pre-fixed set of dividers.
Anyway, here is the line that I use to set the speed in Hz: https://github.com/cosmac/LePi/blob/master/lib/leptonAPI/src/LeptonUtils.cpp#L221
However, the speed is not guaranteed. My understanding is that it really depends on the closest (and lowest) possible value. Here is an extract from RPi hardware documentation:

cdiv speed
2 125.0 MHz
4 62.5 MHz
8 31.2 MHz
16 15.6 MHz
32 7.8 MHz
...........................
When asking for say 24 MHz, the actual speed will be 15.6 MHz.

I will read more on this.

@3YY3
Copy link
Author

3YY3 commented Feb 22, 2018

Yeah, I have read something like that on the web. However, I will try to get my hands on Rpi3 :D

@cosmac cosmac self-assigned this Apr 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants