RGB565 Format and Issues

Featured

The image sensors supports kinds of output formats like Raw RGB Bayer, YUV, JPEG, RGB565, RGB555, RGB444 and etc. In preview mode RGB output is preferred and it can be changed to other format when capture mode. In ArduCAM shield the LCD screen only support RGB565 data format, so when we do preview on the screen, we have to configure the sensors to RGB565 output format. Then the ArduCAM shield will display the image directly from the sensor to LCD screen without intervention of the Arduino board.

In this case the pixel data from the image sensors is ordered as RGB565 format, which means one pixel is composed by two consecutive bytes, the first byte is R[4:0]G[5:3] and the second byte is G[2:0]B[4:0]. The following picture show the RGB565 output timing and data ordering.

RGB565_timing

If the two bytes are disordered when saving to file, the color will be wrong. The same shoot but with different byte order the saved image will be different.

normal_image

 

 

 

disorder_image

 

 

 

 

 

 

 

 

 

Sometimes we don’t know the order of the consecutive bytes at the beginning of the horizon signal HREF(Line_valid). To work around this issue ArduCAM example sketches try to read the first dummy byte from the FIFO to adjust the byte order before saving to a file.

  //Write the BMP header
  for( i = 0; i < BMPIMAGEOFFSET; i++)
  {
    char ch = pgm_read_byte(&bmp_header[i]);
    buf[k++] = ch;
  }
  outFile.write(buf,k);
  //Read first dummy byte
  //myCAM.read_fifo();

  k = 0;
  //Read 320x240x2 byte from FIFO
  //Save as RGB565 bmp format
  for(i = 0; i < 240; i++)
    for(j = 0; j < 320; j++)
  {
      VH = myCAM.read_fifo();
      VL = myCAM.read_fifo();
      buf[k++] = VL;
      buf[k++] = VH;
      //Write image data to bufer if not full
      if(k >= 256)
      {
        //Write 256 bytes image data to file from buffer
        outFile.write(buf,256);
        k = 0;
      }
  }

 

ArduCAM host application demonstration

Featured

This post introduces how to use ArduCAM host application to take high resolution time elapse image with ArduCAM shield. We need the following items to complete this demonstration:

  • Arduino UNO board
  • ArduCAM-F or ArduCAM-LF shield
  • OV5642 camera module with fisheye lens
  • Arduino example sketch ArduCAM_SPI_OV5642_FIFO_UART.ino
  • ArduCAM host application

ArduCAM host application is an Windows application which runs in your Windows computer. It is written in Microsoft C# .NET, precompiled execute program can be download from here, source project files can be download from here. Please note that it requires Microsoft .NET Framework 3.5 version to run.

The example sketch ArduCAM_SPI_OV5642_FIFO_UART.ino receives commands from ArduCAM host application then send back image data when capture is done. The ArduCAM host side save the received image binary data into a JPEG file.

With basic knowledge about example and ArduCAM host application, now let’s connect ArduCAM shield to UNO board, attach the OV5642 camera module, then downloading the example sketch ArduCAM_SPI_OV5642_FIFO_UART.ino . ArduCAM_Host_ug ArduCAM_Host

 

 

 

 

 

 

 

By opening the ArduCAM dialog, you have to select the correct COM port for your Arduino board (here using COM77 for example) and select the correct baud rate for the COM port (here using 115200bps). Once you click the Open button, the Capture button activated. Now you can manually issue the capture command by click the Capture button or set the proper time interval (millisecond unit) for auto capture. ArduCAM_OV5642

Time interval should be set great than the time to transfer one entire image data. ArduCAM has max 384KB memory to hold the image data, so the maxim image data will be 384KB. To transfer this amount of image data with 115200 baudrate 1 start bit 1 stop bit none parity, the maxim transfer time will be (384K x 10)/115.2 = 33.3 seconds. If you are sure about the time interval the 40 seconds will work for you. Another example sketch ArduCAM_SPI_OV2640_FIFO_UART.ino also work with ArduCAM host application, it output smaller image data with smaller resolution, so the time interval can be reduced.

The SaveImage option should be selected if you want to save the captured image on your hard disk. The saved file will be appeared on the parent directory of the ArduCAM host application.

The Verbose option can be selected for debug purpose, and check out what binary data is received from the COM port.

With ArduCAM host application we can make a high resolution Arduino time elapse camera by setting the time intervals and select the save image option. Then combine all the capture images into AVI file, you can create your own time elapse video. here is the demo video we created so far, the original images is here.

RaspCAM A Raspberry Pi Based Camera

Featured

Recently ArduCAM team designed a simple-point-and-shoot digital camera for Raspberry Pi B+ board, it integrates both LCD touch screen and 5MP Raspberry Pi camera board into a single shield. It is well mated with Raspberry Pi B+ board, combined the WIFI dongle user can optionally transfer the captured photos to anywhere else. The RaspCAM features changeable lens options, user can replace the lens with fisheye or telescope lens according to their applications.

Feature

  • Well mate with Raspberry Pi B+ board
  • 2.8/ 3.2 inch TFT LCD with touch screen
  • 5MP CMOS camera module
  • M12x0.5 or CS mount lens and lens holder
  • Support kinds of lens options
  • Opensource Raspberry Camera software

Continue reading “RaspCAM A Raspberry Pi Based Camera” »

Raspberry Pi NoIR Camera Now Released

Featured

 

The Pi NoIR is a Raspberry Pi camera module with no Infrared filter for night time and low light photography using an Infrared light. Useful for wildlife research, science projects, night time security or making artistic photo’s.

The Raspberry Pi camera module has been used for many things such as a security camera, for time lapse photography and even sent high up into the atmosphere on a weather balloon.
With the wide range of project Raspberry Pi’s are being used for, some users were finding that the camera was no good when it was being used in low light with an Infrared light source. Unfortunately for them the Raspberry Pi camera module has a Infrared filter built in which makes it unusable for their project. In response we come up with a camera module just for these type of projects called the Pi NoIR camera. It is the same as the standard camera module but without an IR filter.

Without the Infrared filter the camera can be used for night time photography, night time security or for any project where the scene will be lit by an IR light. Without a filter the camera sensor can see short wavelength IR light around 800nm which is the IR wavelengths not generated with heat but just beyond the visible red light in the spectrum.

The camera has the same specifications as the standard camera module but has a black circuit board so it can be told apart from the standard green camera board.

 

 

 

Raspberry Pi Camera Module Released

Featured

In order to meet the increasing need of Raspberry Pi compatible camera modules. The ArduCAM team now released a add-on camera module for Raspberry Pi which is fully compatible with official one. It attaches to Raspberry Pi by way of one of the two small sockets on the board upper surface. This interface uses the dedicated CSI interface, which was designed especially for interfacing to cameras. The CSI bus is capable of extremely high data rates, and it exclusively carries pixel data. The camera is supported in the latest version of Raspbian, Raspberry Pi’s preferred operating system

The board itself is tiny, at around 36mm x 36mm. The highlight of our module is that the Lens is replaceable compared to official one, making it perfect for mobile or other applications where size and image quality are important. It connects to Raspberry Pi by way of a short ribbon cable. The camera is connected to the BCM2835 processor on the Pi via the CSI bus, a higher bandwidth link which carries pixel data from the camera back to the processor. This bus travels along the ribbon cable that attaches the camera board to the Pi.

The sensor itself has a native resolution of 5 megapixel, and has a fixed focus lens onboard. In terms of still images, the camera is capable of 2592 x 1944 pixel static images, and also supports 1080p30, 720p60 and 640x480p60/90 video.

Feature:

  • High-Definition video camera for Raspberry Pi Model A or B
  • Omnivision 5647 sensor in a fixed-focus module with replaceable Lens
  • Lens holder: M12x0.5 or CS Mount
  • 5MPixel sensor
  • Integral IR filter
  • Still picture resolution: 2592 x 1944
  • Max video resolution: 1080p
  • Max frame rate: 30fps
  • Size: 36 x 36 mm
  • Connection by flat ribbon cable to 15-pin MIPI Camera Serial Interface (CSI) connector S5 on Raspberry Pi computer board

 

ArduCAM Shiled Rev.C Now Released

Featured

With the great success of ArduCAM shield Rev.B, we received hundreds of comments and feedbacks from ArduCAM users. The ArduCAM team now released a more powerful ArduCAM shield Rev.C with past few months’ hard work. The new features list as follows:

  • Support camera modules: OV7660 OV7670 OV7675 OV7725 OV2640 OV3640 OV5642 MT9D111
  • Incorporating standard SPI slave interface
  • Reduced IOs consumption, only 4 IOs for SPI, 2 IOs for I2C and 1 IO for SD are required
  • All IOs are 5V and 3.3V tolerant
  • Support all Arduino families including Arduino DUE
  • Can be easily ported to any platforms which have SPI port like Raspberry Pi, BeagleBoard, BeagleBone, pcDuino and etc
  • Support 1080p still JPEG image capture
  • Provide low power mode, reduce power consumption and prolong battery life
  • Well mate with Arudino UNO R3, MEGA2560 R3, Leonardo R3 and DUE boards

SPI interface which is widely used in most micro-controllers and peripherals sensors. SPI is a synchronous serial data protocol used by microcontrollers for communicating with one or more peripheral devices quickly over short distances. With the advantage of SPI bus, the ArduCAM shield Rev.C reduced the IO consumption, achieve higher bus speed than the Rev.B. By using Arduino standard SPI and I2C pin out, the Rev.C can well mate with Arduino mainstream boards like UNO R3, Mega2560 R3 and DUE etc. A brief comparison between Rev.C and Rev.B :

Feature Rev.C Rev.B
IO consumption 7 19
Bus speed 8Mbps < 1MB/s
Low power mode Support Not support
Dedicate SPI/I2C interface Yes No

ArduCAM shield Rev.C not only work with Arduino boards, it now can be ported to any platform easily because it use standard SPI bus. We now are busy with Raspberry Pi and helix_4 porting. The helix_4 FPGA module is an efficient, low cost Altera FPGA System on Module designed to give design teams the best possible FPGA development experience, for more information please visit thin-layer-embedded.com. ArduCAM shield Rev.C also provide low power feature for battery powered device. When it is in idle, user can shut down the LCD back light OFF and disable FIFO and etc to reduce power consumption, and prolong battery.

ArduCAM Shield Rev.B released, significant improvement!

Featured

Improved Features:

  • Provide two board options, ArduCAM-LF has both LCD and FIFO, ArduCAM-F only has FIFO
  • ArduCAM-LF provide live video and real time snapshot
  • Support both Arduino UNO and MEGA1280/2560 boards (but not limited to these boards)
  • 3Mbit memory space and support  the RAW RGB fromat resolution up to 640×600,
  • Support 2MP (1600×1200) JPEG image capture and storage
  • Various Arduino firmware application demonstrations  for IOT (Internet of things)
  • User can add their own camera modules to the ArduCAM library easily

Schematic :

Please download the schematic of ArduCAM Rev.B for connection and pin out.

How to Buy:

Please purchase the ArduCAM shield and camera modules from distributor UCTronics.

Demonstration Video:

 

 

How to use ArduCAM with Arduino DUE board

User frequently reported that the ArduCAM shield doesn’t work with DUE board, and it is now a known issue.

We figured out that in the Due board the default SD library speed is much faster than ArduCAM shield. The current ArduCAM shield SPI timing only supports less than 10Mbps.  So if you want to work ArduCAM and DUE board together, the SPI should be configured with the lower speed.

To work around this issue, you have to modify the SD library below.
1. Please add the last line to \libraries\SD\utility\Sd2Card.h like follows.
/** Set SCK to max rate of F_CPU/2. See Sd2Card::setSckRate(). */
uint8_t const SPI_FULL_SPEED = 0;
/** Set SCK rate to F_CPU/4. See Sd2Card::setSckRate(). */
uint8_t const SPI_HALF_SPEED = 1;
/** Set SCK rate to F_CPU/8. Sd2Card::setSckRate(). */
uint8_t const SPI_QUARTER_SPEED = 2;
uint8_t const SPI_ARDUCAM_SPEED = 3;

 

2. Please change the SDClass::begin() function in the \libraries\SD\SD.cpp file like follows:
boolean SDClass::begin(uint8_t csPin) {
/*
 
Performs the initialisation required by the sdfatlib library.
 
Return true if initialization succeeds, false otherwise.
 
*/
//return card.init( SPI_FULL_SPEED, csPin) &&
//return card.init(SPI_HALF_SPEED, csPin) &&
//return card.init(SPI_QUARTER_SPEED, csPin) &&
return card.init(SPI_ARDUCAM_SPEED, csPin) &&
volume.init(card) &&
root.openRoot(volume);
}

 

An Arduino Time-Lapse Camera Using ArduCam

This Article is written by one of our customer, the original article can be found from here.

AN ARDUINO TIME-LAPSE CAMERA USING ARDUCAM

While experimenting with my pinhole cameras, I did a lot of thinking about capturing and displaying the passage of time.  Day and night, the change of seasons, sunrise, sunset, moonrise, moonset, tides, rush hour, busy times at restaurants, even life and death marks the passage of time.

There are plenty of commercially-available time-lapse photography devices.  These require either an AC power source, a solar panel or a beefy battery, expensive photography equipment, and are large and easy to spot.  Between the size and the expense, this strongly limits the duration of time lapse I would be able to take even if such a device wasn’t prone to being stolen by the first philistine that came across it.  My goal is to make the smallest, most energy efficient and least expensive camera possible so that I am free to set them everywhere and see what the passage of time shows me.

To do this, I decided to give ArduCam a try.

Continue reading “An Arduino Time-Lapse Camera Using ArduCam” »

Hardware

This section describe the ArduCAM shield Rev.C hardware feature and user guide. For information about Rev.B, please refer here.

Introduction

ArduCAM shield hardware integrates all the necessary components to interface with camera modules. User only need a extra support camera modules and a TF/SD card to start image capture.

The shield provide the following features:

  • Dedicate DigtalVideoPort Camera Module Interface
  • Standard SPI slave bus interface
  • 3.2” TFT Color LCD Screen(a)
  • Build-in 3Mbit FIFO Memory
  • TF/SD Card Reader with LED indicator
  • Use Arduino SPI / I2C dedicate pin out
  • Well mated with UNO/MEGA2560/DUE/Leonardo boards

Note: (a) Model ArduCAM-F doesn’t not include a 3.2” LCD screen

ArduCAM Shield Pin Out

ArduCAM shield includes to sets of pin out see Figure 1,  they are identical in function. One is Arduino standard, it can be well mate with standard Arduino boards like UNO, MEGA2560, Leonardo and DUE etc. The other one is alternative port which can be connect to any platform like Raspberry Pi. The detail pin out for each see Table 1 and Table 2.

Figure 1 ArduCAM pin out

ArduCAM_Pinout

 

 

 

 

 

 

Table 1 Arduino Standard Pin Out

Index Arduino Pins Description
1 I2C_SCL I2C clock
2 I2C_SDA I2C data
3 SPI_SCLK SPI clock
4 SPI_MISO SPI Master In Slave Out
5 SPI_MOSI SPI Master Out Slave In
6 9 SD/TF Card Chipselect
7 10 ArduCAM Shield Chipselect
8 Reset Arduino Reset Input
9 5V 5V Power Input
10 GND Gound

Table 2 Alternative Pin Out

Index Arduino Pins Description
1 I2C_SDA I2C data
2 I2C_SCL I2C clock
3 CS_n ArduCAM Shield Chipselect
4 SD_CSn SD/TF Card Chipselect
5 SPI_MISO SPI Master In Slave Out
6 SPI_MOSI SPI Master Out Slave In
7 SPI_SCLK SPI clock
8 Trigger Snapshot Input
9 RST Reset Input
10 GND Gound
11 5V 5V Power Input

Camera Interface

CMOS image sensor interface divided into two catalogs, one is DVP (Digital Video Port) interface, the other is MIPI Mobile Industry Processor Interface. The main difference between DVP and MIPI is that DVP is parallel interface and the MIPI interface is high speed differential serial interface. MIPI interface provide higher data band width than DVP interface and support higher resolution and frame rate. Because the complexity and need additional hardware of MIPI interface, we only discuss DVP interface here.

For a standard DVP image sensor you will find the following signals:

  • SCL: I2C compatible clock signal for sensor registers configuration
  • SDA: I2C compatible data signal for sensor registers configuration
  • XCLK: clock input to the sensor
  • PCLK: clock output from the sensor,
  • HREF: Line valid signal
  • VSYNC: Frame valid signal
  • Data[N-1..0]: Data output from the sensor, N is the internal ADC bit width.

ArduCAM shield provide a DVP interface which support wide range of camera modules from 0.3MP to 5MP. The camera modules should line up with the shield based on Pin1 shown in the Figure 2 and Table 3 provide camera interface pin out on the shield.

Figure 2

CAM Pin Out

CAM Pin Out

 

 

 

 

 

Table 3 Camera Interface Pin Out

Pin Signal Pin Signal
1 +3.3V 2 GND
3 SCL 4 SDA
5 VSYNC 6 HREF
7 PCLK 8 XCLK
9 D7 10 D6
11 D5 12 D4
13 D3 14 D2
15 D1 16 D0

ArduChip

The ArduCAM shield includes a ArduChip which handle complex timing between MCU and LCD, Camera, FIFO. It exports a standard SPI serial interface shown in Table 4 and can be interfaced with wide range of micro-controller. MCU control the shield through a set of ArduChip internal registers shown in Table 6.

Table 4 ArduCAM shield SPI Interface

Signal Arduino UNO Pin Description
SCL I2C_SCL I2C clock
SDA I2C_SDA I2C data
SCLK SPI_SCLK SPI clock
MISO SPI_MISO SPI master in slave out
MOSI SPI_MOSI SPI master out slave in
CSn 10 ArduCAM shield chipselect, active LOW
SD_CSn 9 TF/SD card chipselect,      active LOW

Bus Timing and Protocol

ArduCAM shield Rev.C use standard SPI slave bus protocol (CPOL = 0, CPHA = 0). One bus transaction composed by two 8bit access. Every bus transaction start with CSn goes low. The first 8bit is command phase, and the second 8bit is data phase. The bus timing shown in Figure 3 and Figure 4.

Figure 3 Bus Write Timing

bus_write_timing

Figure 3 Bus Read Timing

bus_read_timing

Data protocol in the command phase see Table 5

Table 5 Command Byte Protocol

Command Byte Protocol

Bits Bit[7] Bit[6] Bit[5:1] Bit[0]
ArduChip Internal Register 1: Write0: Read 0: R/W Register1: RO Register Register Address  bit[5:1] Register Address bit[0]
LCD Command Write 1 0 11111 1
LCD Data Write 1 0 11111 0
FIFO Read 0 0 11110 1

Table 6 ArduChip Registers

Address Name Mode Description
0x00 ARDUCHIP_TEST1 R/W Testing Register, only used in bus testing
0x01 ARDUCHIP_TEST2 R/W Testing Register, only used in bus testing
0x02 ARDUCHIP_MODE R/W Bus Mode selection .Bit[7:3]: Reserved Bit[2]: LCD to MCU, Bit[1]: Camera to LCD , Bit[0]: MCU to LCD
0x03 ARDUCHIP_TIM R/W Timing Control register. Bit[7..6]: Reserved. Bit[5]: FIFO power down, 1 = power down, 0 = normal operation. Bit[4]: reserved. Bit[3]: Camera data delay control. 1 = delay 1 clock, 0 = no delay. Bit[2]: LCD backlight control, 1 = backlight off, 0 = ON. Bit[1]: Camera VSYNC polarity control, 1 = Inverted, 0 = Normal. Bit[0]: Camera HREF polarity control, 1 = Inverted, 0 = Normal.
0x04 ARDUCHIP_FIFO R/W FIFO control Bit[1]: Write 1 to start a capture, Bit[0]: Reset the FIFO read and write pointer to ZERO.
0x40 ARDUCHIP_REV RO Bit[7:6]: Revision integer part. Bit[5:0]: Revision decimal part. Default value is 0xC0.
0x41 ARDUCHIP_TRIG RO Trigger input Register. Bit[7:4]: Reserved. Bit[3]: Capture complete flag, 1 = Complete, 0 = Busy. Bit[2]: Reserved. Bit[1]: Capture button status, 0 = pressed, 1 = released. Bit[0]: Frame start signal, equal to VSYNC