Hi everyone, hoping someone from Arducam can help. I’m using the Arducam library v1.0.0 (the same version that was used for the original Arducam Mini 2MP and Mini 2MP Plus cameras) and I’m seeing a difference with the newer camera boards I have.
When I write myCAM.wrSensorReg8_8(0xff, 0x01) to select bank 1 it returns an error. This executes after a 3mS delay from powering up the camera (I also tried 10mS with no difference) and it works fine on the earlier versions of the camera.
This is the code path:
Wire.begin(SDA, SCL, I2CCLKSPD); // start up the I2C again and perform dummy transmission - this prevents the miscolouration that is mentioned in the email thread below
Wire.beginTransmission(0x60>>1); // the address of the OV2640
Wire.endTransmission(); // finish a dummy transmission
//Change to JPEG capture mode and initialize the module
myCAM.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); //disable low power
myCAM.set_format(JPEG);
myCAM.InitCAM();
myCAM.OV2640_set_JPEG_size(OV2640_640x480);
myCAM.flush_fifo();
myCAM.clear_fifo_flag();
if (!myCAM.wrSensorReg8_8(0xff, 0x01)) ESP_LOGE(TAG,"Error setting camera bank1"); // set to sensor bank1 of registers // <<<<this causes the error message to be logged.
I get the logged error Error setting camera bank1. For context, the discolouration I had earlier was fixed by starting the I2C again and doing a dummy transmission (a known I2C arbitration lock-up on the ESP32).
I need something that lets me use the same code with both variants of the camera. Any ideas?
Thanks for the detailed report. Quick confirmation from our side on the dummy byte: yes, you’re right that for the 2MP Plus the first byte is valuable - you can’t discard it. In the older MIPI_2MP version the first dummy data was discarded when reading image data; for the latest version you don’t do that. The camera firmware was modified between the two, which is likely why you’re seeing different behaviour.
On the error you’re hitting (bank 1 selection failing), can you send over the demo/code you’re using? As a sanity check, both the old and the latest camera use the same process steps: clear fifo, start capture and wait for capture done, then read the image data over SPI. If it’s failing earlier than that, we need to look at your init sequence in detail.
Also - we’ve shipped many library versions, so I want to make sure we’re looking at the exact lib you’re using. If you can share the library version you’ve built against, we may be able to modify it to support both the old and new camera.
I’m not using the original cameras at all anymore - just the Plus version and the recent Rev B Plus version (the camera board version got upgraded). The new versions use replacement chips because the original chips were out of stock.
The dummy write has already been removed and is not the issue. My understanding is that the dummy write needed to be removed when going from Arducam Mini 2MP to Arducam Mini 2MP Plus.
The real problem: the new hardware on Rev B (EtronTech chip) powers up about 10 times slower than the Mini 2 Plus (Winbond chip) version.
Environment:
Arducam library v1.0.0
Arducam Mini 2MP Plus and Rev B Plus
The error I get is exactly this, logged from the bank-1 write:
Wire.begin(SDA, SCL, I2CCLKSPD); // start up the I2C again and perform dummy transmission
Wire.beginTransmission(0x60>>1); // the address of the OV2640
Wire.endTransmission(); // finish a dummy transmission
myCAM.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); //disable low power
myCAM.set_format(JPEG);
myCAM.InitCAM();
myCAM.OV2640_set_JPEG_size(OV2640_640x480);
myCAM.flush_fifo();
myCAM.clear_fifo_flag();
if (!myCAM.wrSensorReg8_8(0xff, 0x01)) ESP_LOGE(TAG,"Error setting camera bank1"); // <<<<this causes the error message to be logged.
Log: Error setting camera bank1
Things I’ve already tried: removed the dummy write (no change, not the issue), 3mS delay, and 10mS delay after power-up - neither delay makes a difference on the earlier versions.
To be more specific about the delay, here’s the full power/lifecycle code. The system occasionally captures an image; the rest of the time it hardware powers-down the camera module to save power. A digitalWrite controls a mosFET that supplies Vcc to the module.
digitalWrite(CAMERA_PWR, CAMERA_ON); // turn on Camera module (active low)
vTaskDelay(CAMERA_PWR_UP_DELAY); // allow camera i2C to settle before writing; 3mS about right
if (xSemaphoreTake(I2CGatekeeper, 100)) { // grab access to the I2C bus
//Hack to correct I2C arbitration loss that sometimes occurs after power-up
Wire.begin(SDA, SCL, I2CCLKSPD); // start up the I2C again
Wire.beginTransmission(0x60>>1); // the address of the OV2640
Wire.endTransmission(); // finish a dummy transmission
//Change to JPEG capture mode and initialize the module
myCAM.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); //disable low power
myCAM.set_format(JPEG);
myCAM.InitCAM();
myCAM.OV2640_set_JPEG_size(OV2640_640x480);
myCAM.flush_fifo();
myCAM.clear_fifo_flag();
if (!myCAM.wrSensorReg8_8(0xff, 0x01)) ESP_LOGE(TAG,"Error setting camera bank1"); // <<<<< FAILs to write sensor registers here
...
}
The code then goes on to restore previously stored exposure/gain values before taking and saving a picture, and finally shutting the power to the camera off again.
The previous Mini 2 Plus (Winbond chip) version works fine with CAMERA_PWR_UP_DELAY = 3mS. The new Rev B (EtronTech chip) needs 40 or 50mS before the error writing to the sensor registers goes away. That’s very slow in comparison and has a real performance implication for me. Can it be improved?
Thanks for the extra detail. A bit strange on our end - as normal, both the old version and the latest version camera use the same process steps: clear fifo, start capture and wait capture done, then read the image data through the SPI bus. I can’t immediately understand why a longer delay is required.
One thing to rule out: does your code contain an extra delay somewhere that only triggers on the new board? If you can send the full demo/code I’ll go through it in detail.
I’ll test this on my side tomorrow and reply as soon as I can.
Sorry for the late reply - I did a detailed assessment and I can reproduce what you’re describing. There is indeed a delay problem. Because the main control chip has been adjusted on the new board, it takes a certain time to load when being powered on. That’s the source of the extra power-up time you’re measuring.
A couple of options:
Option 1 - Low power mode. The camera supports low power mode. If you keep the main chip powered on, you can use:
myCAM.set_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); // enter low power mode
myCAM.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); // exit low power mode
Using this method, keep the main chip powered on the whole time - that way you avoid the power-up load delay entirely, since you’re never fully powering the chip down.
Thanks. I tried the low-power approach, but the power-save mask doesn’t reduce the consumption sufficiently for my use-case. Nowhere near, unfortunately.
The new (Rev B) version doesn’t perform as what I believed I’d ordered, and I’m now in production with a system built around that specification. The production costs are sunk, so it’s too late for me to change course - I’ll have to use the Rev B version and downgrade the end-product performance.
I’m going to go ahead and ship, and re-design around something else for the future. The Mega is a possible contender. Can the Mega be used with different lenses (with or without the case)? That’s important for a redesign.
Understood, and apologies for not telling you in advance that the version had been updated for a long time. The reason for the update is that we had to choose an alternative scheme because of the chip shortage - which is where the slower power-up behaviour comes from. I’m sorry it’s caught you mid-production.
On the Mega: it hasn’t been released yet, so there’s no plan to support changing the lens at present. We may release a version with an M12 lens in the future, so keep an eye out for that.
To summarize where we’ve landed technically:
The bank-1 write failure (Error setting camera bank1) was tied to the power-up time of the new Rev B (EtronTech chip) main control chip, which needs a certain time to load on power-on. Confirmed by our testing.
Workaround if you keep the main chip powered on: enter low power mode with myCAM.set_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK) and exit with myCAM.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK), avoiding the power-up load delay.
If your power budget requires fully cutting Vcc, the Rev B board will need the longer (40-50mS) CAMERA_PWR_UP_DELAY vs the ~3mS of the Winbond Mini 2MP Plus. That extra delay is inherent to the updated chip, so there’s currently no way to shorten it as far as we’ve found.
For future designs, the Mega is a candidate but lens-change support isn’t available yet (possible M12 variant in the future).
If you want to dig further into the low-power numbers, just post your measured figures and I’ll take another look.