1

EDIT: Firstly I wrote it a bit confusing way. So let me summarize my problem. This is something like answer to comment bellow.

(1) I am trying to make somethin like visible light communication based on LED as independent TX part and photodiode with MCP3008 as RX part. I am attaching a photo of my circuit I currently use. The resristor on the TX part has 10 ohms resistivity and the resistor on the RX part has 10K ohms.

Circuit I currently use

(2) I want to receive data on 10 kHz frequency (Code from the TX part: time.sleep(delay) delay is set to 0.0001). This is why I thought that I need to apply Nyquist sampling theorem. This theorem says: Sampling frequency shoult be at least 2-times higher as sampled frequency. So I used 22 kHz frequency on the SPI bus, because I thought that this is my sampling frequency for digital signal of LED (picture bellow - last line marked as 14 TXD). It does not work, so I was trying to find proper frequency to read some of the data and this is why I use 480,750 kHz. This frequency gives me the closest result for my data sent form TX.

PISCOPE

(3) Unfortunately, I do not have a scope, so I can not show you exact shape of signals. I use a PISCOPE for some analysis (picture above). The bottom GPIO pin is for sending information using LED. I sent this sequence, which is capturend on the PISCOPE: 000011110101100101010001001111010011110100111110. The RX part recieve after some management this sequence: 1011001001000100111010011101 (First eight and last eught bits from TX sequence are cut, because those are only for communication starting and ending. There you cn see that a lot of bits are lost or doubled - this is why my RX sequence start with 1. The 1 is from start sequence, which has, as it seems to be, on bit doubled).

(4) I explain to you already what I mean by a Nyquist. I mean Nyquist-Shanonn sampling theorem.

Question: So my question is. How can I set a proper SPI bus frequency (sampling frequency?) for the 10 kHz if I want to receive all the sent bits in correct oreder? I am new in this field, so any kind of help will be much appreciated. Thank you and sorry for my brief explanation above :-)

8
  • 1
    Nothing really to do with the Pi. I'd like to see some evidence that you have calculated the number of bits you expect to receiver per second from the ADC (for the samples you are taking). – joan Mar 4 at 13:18
  • #dejv_IT, I found your question very confusing. Let me try to summarize: (1) You are using Rpi SPI MCP3008 ADC to convert two analog signals Rx and Tx to two 10-bit digital values, (2) You are setting SPI frequency to 480,750 kHz. (3) But I don't know how the analog signals look like. Are they square waves or aperiodic waves? It would be nice if you can show us a picture, or describe in more details how they look like. (4) I don't understand what do you mean by a "Nyquist". Are they some sort of oscillation peaks? – tlfong01 Mar 4 at 13:53
  • 1
    @tlfong01 I updated my explanation bellow. Sorry for confusing question I wrote before – dejv_IT Mar 4 at 18:02
  • By default piscope will only reliably show signals at or below 100 kHz. It samples at 200 kHz. That would explain missing data. – joan Mar 4 at 18:52
  • 1
    @joan I used PISCOPE only for showing shape of the signal I sent via LED. I do not use PISCOPE for receiving data. – dejv_IT Mar 4 at 18:56

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.