# Ov5640 exposure time not making sense with fps

**URL:** <https://forums.openmv.io/t/ov5640-exposure-time-not-making-sense-with-fps/10105>\
**Category:** OpenMV Boards\
**Created:** [October 17, 2024, 5:46pm UTC](https://forums.openmv.io/t/ov5640-exposure-time-not-making-sense-with-fps/10105 "2024-10-17T17:46:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![RayCali](https://avatars.discourse-cdn.com/v4/letter/r/cc9497/32.png) [@RayCali](https://forums.openmv.io/u/RayCali)\
**Post date:** [October 17, 2024, 5:46pm UTC](https://forums.openmv.io/t/ov5640-exposure-time-not-making-sense-with-fps/10105/1 "2024-10-17T17:46:50Z")

</div>

Hi, I’m in a position where i need to be able to accurately and reliably set the exposure time in terms of milliseconds. I use the set\_auto\_exposure() function and it works in a way where a higher exposure\_us gives a brighter image but the value doesn’t really makes sense when looking at the fps. For example in FHD an exposure time of 500 000 us should give me 2 fps, but i get 5… Increasing the exposure time further will also still make the image brighter so its not that it is saturated. This leads me to believe that the exposure time is not really 500 000 us. I looked through the code in the firmware as well, but couldn’t really see any problems in your exposure calculations. Do you know what the problem is?

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [October 17, 2024, 7:34pm UTC](https://forums.openmv.io/t/ov5640-exposure-time-not-making-sense-with-fps/10105/2 "2024-10-17T19:34:35Z")

</div>

Some of that code is user-contributed. But, seems to be correct. We don’t have a relationship with OmniVision where we can get FAE support to improve this. As of right now, the driver was written to the best information we could reverse engineer.

Note that you may wish to slow the PLL down via doing `sensor._write_reg(0x3036, 0x40)` to increase exposure. (SC\_PLL\_CONTRL2).

If you want reliable exposure, use the Global Shutter sensor. We have proper Datasheet access with Onsemi, so the driver for that is much more correct and was not reverse-engineered from minimal documentation.

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [October 17, 2024, 7:36pm UTC](https://forums.openmv.io/t/ov5640-exposure-time-not-making-sense-with-fps/10105/3 "2024-10-17T19:36:39Z")

</div>

I made a bug tracker for this. If you wish to send a PR and are able to fix it then it would be appreciated. I won’t be able to work on this though for a long time otherwise: [OV5640 Exposure Calculation · Issue #2457 · openmv/openmv (github.com)](https://github.com/openmv/openmv/issues/2457)

---

<div class="post-metadata">

**Author:** ![RayCali](https://avatars.discourse-cdn.com/v4/letter/r/cc9497/32.png) [@RayCali](https://forums.openmv.io/u/RayCali)\
**Post date:** [October 17, 2024, 8:01pm UTC](https://forums.openmv.io/t/ov5640-exposure-time-not-making-sense-with-fps/10105/4 "2024-10-17T20:01:41Z")

</div>

yeah, I have also needed to do my fair share of reverse engineering with the FREX trigger as well with this camera 😃. Well, then at least I know that there is something wrong here, I’ll try to see whats wrong and I’ll get back here if I have solved it. Thanks for the help!

---

<div class="post-metadata">

**Author:** ![RayCali](https://avatars.discourse-cdn.com/v4/letter/r/cc9497/32.png) [@RayCali](https://forums.openmv.io/u/RayCali)\
**Post date:** [October 24, 2024, 12:12pm UTC](https://forums.openmv.io/t/ov5640-exposure-time-not-making-sense-with-fps/10105/5 "2024-10-24T12:12:47Z")

</div>

Hi! I have solved the issue and made a pull request. There were two errors done which is roughly explained in the description of the pull request, one was concerning the MIPI bit mode division and one was that the pll-predivider value was extracted incorrectly. After these two errors are corrected, the exposure time and fps match and the fps is never higher than what should be possible. Here is an example with exposure time of 100 000 us resulting in 10 fps in QVGA!

 ![image](https://canada1.discourse-cdn.com/flex029/uploads/openmv1/original/2X/d/da12e786f613bd17f71ea6a4790ba04a4d461db2.png)

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [October 24, 2024, 5:43pm UTC](https://forums.openmv.io/t/ov5640-exposure-time-not-making-sense-with-fps/10105/6 "2024-10-24T17:43:00Z")

</div>

Ah, okay, great! Let me post this info on the pull request.
