Skip to content

Query on Pi Camera v3 CSI clock rates #43

Closed

Description

@darksidelemm

I've been testing using a Pi Camera v3 for a high-altitude balloon application, where there is a GPS receive in proximity to the raspberry pi. I've previously used Pi Camera v2's with only minimal GPS interference issues, however now I'm testing a Pi Camera v3, I find that as soon as image capture starts, the GPS loses lock.

My suspicion is that the larger sensor size of the v3 results in higher CSI data lane rates, which may have harmonic issues at GPS L1 frequencies (1575 MHz).
How would I determine what CSI rates are in use? I'm capturing full-resolution stills.
Is there any way to force the CSI rate? Again, I'm only interested in capturing the occasional (every few second) still image, not high FPS video...

I've switched back and forth between the Pi Camera v2 and v3, and am fairly certain the issue is more prevalent on the v3 camera.

Activity

  1. darksidelemm commented on Feb 18, 2023

    @darksidelemm
    Author

    Just as confirmation of what's going on here, here's some measurements taken with a HackRF showing the RFI around the GPS L1 frequency when the v3 camera has started:

    Screen Shot 2023-02-18 at 18 26 26

    Here's the same measurement, but with a v2 camera:
    Screen Shot 2023-02-18 at 18 30 11

    In both cases, I use the following python commands to start up the camera:

    from picamera2 import Picamera2
    cam = Picamera2()
    config = cam.create_still_configuration()
    cam.configure(config)
    cam.start()
    
  2. 6by9 commented on Feb 18, 2023

    @6by9
    Collaborator

    All V4L2 sensor subdev drivers should advertise the CSI-2 link frequency/frequencies used via V4L2_CID_LINK_FREQ. Those are generally configured via device tree too for the case where the driver allows variation of them.

    v4l2-ctl -d /dev/v4l-subdev0 --list-ctrls-menu should give you the list, or
    https://github.com/raspberrypi/linux/blob/rpi-5.15.y/drivers/media/i2c/imx708.c#L38

    #define IMX708_DEFAULT_LINK_FREQ	450000000
    

    https://github.com/raspberrypi/linux/blob/rpi-5.15.y/drivers/media/i2c/imx219.c#L48

    #define IMX219_DEFAULT_LINK_FREQ	456000000
    

    Those are both relying on the driver developer having calculated or been given the correct numbers based on the register settings, but I believe they are correct for both sensors.

    In both cases the external oscillator feeding the camera module is 24MHz, but the PLLs may result in different frequencies internally.

  3. 6by9 commented on Feb 18, 2023

    @6by9
    Collaborator

    Checking the information I have from Sony, the link frequency is correct as 450MHz for all modes.

    The internal pixel clock varies based on mode, being 1488MHz for full res, and 1464MHz for binned. HDR mode is 1944MHz, so it might be worth seeing if switching HDR on reduces your interference issue.

  4. darksidelemm commented on Feb 18, 2023

    @darksidelemm
    Author

    OK, I can try this out and see if it moves the EMI somewhere else, however HDR mode loses me the resolution that I'm after.

    Is there any mechanism for adjusting these frequencies?

  5. darksidelemm commented on Feb 19, 2023

    @darksidelemm
    Author

    Unfortunately HDR mode does not solve the problem. The interference changes from being essentially continuous to now being impulsive (presumably with the frame rate?), but is still very much present and causes as much of an issue as it did previously.

    Screen Shot 2023-02-19 at 13 56 58

  6. 6by9 commented on Feb 19, 2023

    @6by9
    Collaborator

    Is there any mechanism for adjusting these frequencies?

    A chunk of the register settings in the driver configure the PLLs. In theory you can change them, but I'm afraid the documentation we have from Sony is under NDA, and it's not something that we would anticipate doing.

    @dp111 Any thoughts? Worth a quick discussion on Monday.

  7. darksidelemm commented on Feb 19, 2023

    @darksidelemm
    Author

    I should note that putting Type-61 ferrites around each end of the camera cable brings the EMI down to the point that it's not taking out the GPS... but I suspect most users of this camera aren't going to have that kind of thing on-hand like I do.

    It would certainly be better if it just didn't emit this in the first place.

    I'm not 100% sure it's something within the camera module itself - I still suspect it's related to the data transfer from the camera itself.

  8. naushir commented on Feb 19, 2023

    @naushir
    Collaborator

    @darksidelemm can you try adjusting your framerate to, say, 15fps (66ms duration) to see if/how that changes your interference? You can do this with something like:

    picam2.set_controls({"FrameRate": 15.0})
    
  9. lurch commented on Feb 19, 2023

    @lurch

    This reminds me of https://www.stuffaboutcode.com/2014/01/raspberry-pi-gps-helmet-cam.html where the solution was to wrap the CSI-cable in tinfoil 😃

  10. naushir commented on Mar 1, 2023

    @naushir
    Collaborator

    @darksidelemm did you have a chance to look at the results with reduced framerates?

  11. darksidelemm commented on Mar 1, 2023

    @darksidelemm
    Author

    Not yet... the hardware I was testing with has been embedded into a balloon payload box so I haven't had the chance to test it.

    On that note, I did fly the PiCamera v3 on a balloon launch. With the ferrites it didn't affect the GPS, unfortunately the lens de-focused during the flight due to the cold (certainly out of specification, but still disappointing).

    I'll try and get to this this weekend.

  12. darksidelemm commented on Mar 2, 2023

    @darksidelemm
    Author

    OK, have tried out a few FPS settings (default, 15fps, 1fps). Clearly the duration of the EMI is dependent on how long the data bus is transmitting imagery, but it's still present. I can't say that going to 1fps is a solution here...

    Is there any way the CSI clock rate can be adjusted, to see if that shifts the frequency of the EMI around?

    Screenshots of results:
    default_fps
    15fps
    1fps

  13. naushir commented on Mar 2, 2023

    @naushir
    Collaborator

    Is there any way the CSI clock rate can be adjusted, to see if that shifts the frequency of the EMI around?

    There is no way at present to do this. We will have to talk with the Sony sensors team to discuss if/how this would be possible.

  14. darksidelemm commented on Mar 2, 2023

    @darksidelemm
    Author

    OK, thanks for that. Please do, as I expect this is going to affect more than just me...

  15. aallan commented on Mar 2, 2023

    @aallan

    I've added a [NOTE] block in the camera documentation pointing at this issue in case others stumble across it.

  16. 35 remaining items

  17. naushir commented on Apr 5, 2023

    @naushir
    Collaborator

    You can get the changes by running a sudo rpi-update command. Note, this will update you to the latest kernel and firmware, so please do keep a backup of your critical work on the sdcard if you need to before running this command.

    Eventually the changes will filter into apt and our official images - probably a week or two for the former.

  18. darksidelemm commented on Apr 24, 2023

    @darksidelemm
    Author

    It's worth noting that the PiCamera HQ appears to have exactly the same EMI issue as the Pi Camera 3, with strong EMI present on 1575 MHz.

    Are there similar settings changes available for the HQ camera to shift the clock rates around?

  19. naushir commented on Apr 24, 2023

    @naushir
    Collaborator

    @darksidelemm - it's possible, but right now I don't have the resources to do it so will be lower on the priority list. However, can you email info@raspberrypi.com and quote this github issue and perhaps we can look into a quick short-term workaround.

  20. athtest800 commented on Apr 30, 2023

    @athtest800

    Is it possible to also fix the same problem for Camera HQ (imx477 overlay)?
    I have serious problems while using this camera and GPS.

  21. darksidelemm commented on Apr 30, 2023

    @darksidelemm
    Author

    I should note that I've been able to make the Pi Camera HQ usable in my application with a stock RPi Zero camera cable, but using the ferrite sleeves i've mentioned previously (Laird P/N: 28R0898-200), one near each end of the cable. You can see the layout of my high-altitude balloon payload in this image: https://twitter.com/vk5qi/status/1650750546922569733/photo/1

    I am using a uBlox 8-series GPS with a patch antenna, with the antenna located approximately 15cm from the camera. The GPS maintains lock outside with a clear view of the sky, but does have issues inside where it would normally gain lock.

    Without the ferrites the GPS does not gain lock however, so they seem to be critical to making it work with the current cable.

  22. SChancey commented on Feb 1, 2024

    @SChancey

    A belated comment but be aware that the ribbon cable used at high (L1) frequencies is also a transmission line. A transmission line (or practically any cable) will act as an antenna for its full and half EMI wavelengths. The "200 mm" ribbon cable is very close to the L1 wavelength. Ferrite beads will add reactance to the cable but altering the ribbon cable's length (moving it away from the L1 wavelength) should be an effective counter-measure to coupling. Don't shorten the cable to a half wavelength (100 mm in this case). For FCC / EMI /RFI product compliance, I always consider interconnecting cable lengths first and if a given cable length happens to correlate to an interfering wavelength, I will shield and / or add respective ferrite cores at the cable ends.

  23. RolandasRazma commented on Feb 1, 2024

    @RolandasRazma

    @SChancey very interesting, could you elaborate please? How to select correct lengths? You mentioning not to shorten it to 100mm, why is that?

  24. lurch commented on Feb 2, 2024

    @lurch

    The "200 mm" ribbon cable is very close to the L1 wavelength.

    Luckily, our cables are available in a range of lengths! 😅
    https://www.raspberrypi.com/products/camera-and-display-cable/
    https://www.raspberrypi.com/products/camera-cable/

  25. SChancey commented on Feb 2, 2024

    @SChancey

    @RolandasRazma Practically speaking, from @lurch's links above, going to 300 mm will lower the effective coupling frequency. You don't want 100 mm due to it being close to L1's half wavelength. Imagine a full sine cycle (full wave) and a 1/2 sine cycle (half wave). A simple antenna of appropriate length is "tuned" if it's length matches the effective full or half wave length. If the imposing EM wave, internal or external, matches the antenna length then coupling is increased. This is true for reception and transmission. Fortunately GNSS receiver modules typically employ input SAW filters (high Q bandpass filters) to reject out of band and unwanted wavelengths since they have extremely high input sensitivity (140 dB+). This means you don't have to de-tune the antenna very much to reduce interference. RF is part art, part "magic" and I'm no expert. A rule of thumb for cable / antenna length for an effective frequency is: Frequency (in MHz) = c (speed of light or propagation in meters / sec) / l (length in meters). At the speed of light, it takes ~ 1 nanosecond to travel 1 foot. Real cables don't support propagation at the speed of light and may have speeds in the ~ 0.8 - 0.9 c range. Optimized cables can have higher speeds. Further coupling reduction can be achieved via shielding and / or ferrite cores as mentioned in this thread. In the end, you have to test it. Hard to argue with reality.

  26. RolandasRazma commented on Feb 2, 2024

    @RolandasRazma

    @SChancey thanks for elaborating, make sense

  27. 03vmate commented on Mar 2, 2024

    @03vmate

    @naushir Any ideas when the HQ camera will have adjustable frequency as well? Using the camera jams all nearby phones' GPS as well, which is quite problematic.

  28. 6by9 commented on Mar 3, 2024

    @6by9
    Collaborator

    @naushir Any ideas when the HQ camera will have adjustable frequency as well? Using the camera jams all nearby phones' GPS as well, which is quite problematic.

    This is the problem with raising secondary issues under one issue in an issue tracker - the primary issue gets resolved and the issue closed. The secondary issue therefore gets lost.

    I've raised raspberrypi/linux#6004 to track it.

  29. SChancey commented on Mar 3, 2024

    @SChancey

    @03vmate Please consider the 300 or 500 mm camera cables as an option. Cable lengths are discussed above. The 200 mm Standard - Mini Camera Cable normally provided may couple interference in the L1 band. Raspberry Pi states the camera cables are shielded but they really only have a ground plane on one side. This is helpful for transmission lines. My Samsung S21 doesn't have GNSS interference problems with my Pi 5 using a 200 mm camera cable. Not all phones are designed equally of course. Good luck.

  30. 03vmate commented on Mar 3, 2024

    @03vmate

    @SChancey Used an FFC-HDMI adapter, so I can run fully shielded cable. Covered the camera and phi in copper tape as much as I could, but there was still significant interference. Adjusting the clock, even by just a few MHz would be nice to have, especially that a lot of other sensors support this.

  31. 6by9 commented on Mar 4, 2024

    @6by9
    Collaborator

    @SChancey Used an FFC-HDMI adapter, so I can run fully shielded cable. Covered the camera and phi in copper tape as much as I could, but there was still significant interference. Adjusting the clock, even by just a few MHz would be nice to have, especially that a lot of other sensors support this.

    It might be nice, but it isn't related to this issue which is regarding the v3 camera module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions