Mv mipi i2c.sh user guide

From wiki_veye
Jump to navigation Jump to search

查看中文

mv_mipi_i2c.sh Shell scripts usage

1 Overview

The mv_mipi_i2c.sh script is a tool set for configuring MV MIPI series cameras through the I2C.

This script is essentially an access to registers. For registers, please refer to MV Series MIPI Camera Register Map.

2 Raspberry Pi Only, Set IO config

Running

./enable_i2c_vc.sh

./camera_i2c_config

first,it will config IO pin. Then you can run mv_mipi_i2c.sh.

3 mv_mipi_i2c.sh USAGE

./mv_mipi_i2c.sh

Usage:  ./mv_mipi_i2c.sh [-r/w] [-f] function name -p1 param1 -p2 param2 -b bus

options:

    -r                       read

    -w                       write

    -f [function name]       function name

    -p1 [param1]                           param1 of each function

    -p2 [param1]                           param2 of each function

    -p3 [param3]                           param3 of each function

    -p4 [param4]                           param4 of each function

    -b [i2c bus num]               i2c bus number

    -d [i2c addr]                  i2c addr if not default 0x3b

Please open this srcipt and read the COMMENT on top for support functions and samples.

4 i2c bus number on different board

Please refer to the following article to determine which -b parameter you need to use.

i2c bus number on different boards

5 Functions list

5.1 Note

The camera has two states, standby and running, after the start of image acquisition into the running state.

There are some registers that are write-protected in the running state, which will be marked with an asterisk. For example: trgsrc* .

There are some parameters that have strict range restrictions, and it's a good idea to try reading them when you're in doubt.

5.2 Basic Parameters

5.2.1 manufacturer

./mv_mipi_i2c.sh -r -f manufacturer

Get the manufacturer name, which is VEYE.

5.2.2 model

./mv_mipi_i2c.sh -r -f model

Get the product model, such as MV-MIPI-IMX178.

5.2.3 version

./mv_mipi_i2c.sh -r -f version

Get the Controller version number and Logical version number.

The system has two main control chips that serve the control and logic functions respectively.

5.2.4 serialno

./mv_mipi_i2c.sh -r -f serialno

Get the unique serial number of this module.

5.2.5 timestamp

./mv_mipi_i2c.sh -r -f timestamp

Time after system startup in Milliseconds.

This value starts counting again if you call the reboot command, or if the camera reboots unexpectedly.

5.2.6 errcode

./mv_mipi_i2c.sh -r -f errcode

System error code, each bit represents an error type.

bit0: sensor error.

bit1: Logic module startup error.

bit2: Logic module communication error.

bit5: AA(AE&AG) regulation cannot reach the target brightness.

bit6: Authorization failure.

5.2.7 fmtcap

./mv_mipi_i2c.sh -r -f fmtcap

Capbility of data formats supported by the camera.

bit0: Mono8

bit1: Mono10

bit2: Mono12

bit3: Mono14

bit4: UYVY

5.2.8 factoryparam

./mv_mipi_i2c.sh -w -f factoryparam

All parameters restored to factory default values.

5.2.9 paramsave

./mv_mipi_i2c.sh -w -f paramsave

Save all parameters to flash, and they will not be lost when power off.

5.2.10 reboot

./mv_mipi_i2c.sh -w -f reboot

Reboot the camera.

5.2.11 i2caddr

./mv_mipi_i2c.sh -w -f i2caddr -p1 [new]

./mv_mipi_i2c.sh -r -f i2caddr
This module support i2c address changed by software, i2c address range[0x3,0x77].

Will really take effect only after paramsave and reboot .

5.3 Image Acquisition

5.3.1 imgacq

./mv_mipi_i2c.sh -w -f imgacq -p1 [0/1]

Start/Stop acquisition

There is no image output after the camera is powered on, which means it is in the standby state.

After writing 1 to this register, it enters the running state and starts outputting images or waiting for the trigger signal.

Writing 0 will stop the output image and enter the standby state.

5.3.2 trgmode*

./mv_mipi_i2c.sh -w -f trgmode -p1 [0,2]

./mv_mipi_i2c.sh -r -f trgmode

value description
0 Video streaming mode
1 Normal trigger mode.
2 High-speed continuous trigger mode.

See product manual for details.

5.3.3 trgsrc*

./mv_mipi_i2c.sh -w -f trgsrc -p1 [0,1]

./mv_mipi_i2c.sh -r -f trgsrc

value description
0 Software trigger
1 Hardware trigger
5.3.4 trgnum*

./mv_mipi_i2c.sh -w -f trgnum -p1 [1,255]

./mv_mipi_i2c.sh -r -f trgnum

The number of image frames output by one trigger signal in trigger mode.

5.3.5 trginterval*

./mv_mipi_i2c.sh -w -f trginterval -p1 [us]

./mv_mipi_i2c.sh -r -f trginterval

Trigger interval in normal trigger mode, in microseconds. Range:[0.0xFFFFFF].

5.3.6 trgone

./mv_mipi_i2c.sh -w -f trgone

Software trigger command.One execution will perform a soft trigger.

5.3.7 trgcount

./mv_mipi_i2c.sh -r -f trgcount

Trigger count statistics.

Get the total number of triggers and the number of trigger loss.

./mv_mipi_i2c.sh -w -f trgcountclr

Clear trigger count.

5.4 IO Control

5.4.1 trgdelay*

./mv_mipi_i2c.sh -r -f trgdelay

./mv_mipi_i2c.sh -w -f trgdelay -p1 [us]

Trigger delay, effective under both soft trigger and hard trigger mode.

range: 0 to 1000000 (unit: microsecond)

5.4.2 trgedge*

./mv_mipi_i2c.sh -r -f trgedge

./mv_mipi_i2c.sh -w -f trgedge -p1 [0,1]

Effective trigger edge in hard trigger mode.

value description
0 Rising edge
1 Falling edge
5.4.3 trgfilter_enable*

./mv_mipi_i2c.sh -r -f trgfilter_enable

./mv_mipi_i2c.sh -w -f trgfilter_enable -p1 [0,2]

value description
0 No filtering
1 Rising edge filtering (filtering out low-level interference signals)
2 Falling edge filtering (filtering out high level interference signals)
3 Both rising edge and falling edge filtering
5.4.4 trgfilter_time*

./mv_mipi_i2c.sh -r -f trgfilter_time

./mv_mipi_i2c.sh -w -f trgfilter_time -p1 [us]

Trigger signal filtering window width.

range: 1 to 1000000 (unit: microsecond)

5.4.5 trgexp_delay*

./mv_mipi_i2c.sh -r -f trgexp_delay

./mv_mipi_i2c.sh -w -f trgexp_delay -p1 [us]

Exposure delay, i.e. the time to turn on the Strobe signal in advance.

range: 1 to 1000000 (unit: microsecond)

The difference between trgexp_delay and trgdelay, see manual for details.

5.4.6 gpios_status

./mv_mipi_i2c.sh -r -f gpios_status

Get TriggerIN_IO, OUT_IO1 and OUT_IO2 status.

5.4.7 outio1_mode

./mv_mipi_i2c.sh -r -f outio1_mode

./mv_mipi_i2c.sh -w -f outio1_mode -p1 [0,1]

value description
0 strobe
1 user out

strobe: High level active.

user out: defined by outio1_usr.

5.4.8 outio1_usr

./mv_mipi_i2c.sh -r -f outio1_usr

./mv_mipi_i2c.sh -w -f outio1_usr -p1 [0,1]

value description
0 low
1 high
5.4.9 outio1_rvs

./mv_mipi_i2c.sh -r -f outio1_rvs

./mv_mipi_i2c.sh -w -f outio1_rvs -p1 [0,1]

Reverse OUT_IO1 high and low levels if set to 1.

5.4.10 outio2_mode

./mv_mipi_i2c.sh -r -f outio2_mode

./mv_mipi_i2c.sh -w -f outio2_mode -p1 [0,3]

value description
0 strobe
1 user out
2 trigger wait
3 XVS
4 XHS

strobe: High level active.

user out: defined by outio2_usr.

trigger wait: High level active. Indicate that the camera is not busy now, able to respond to the trigger signal.

XHS, XVS: The signal from the corresponding pin of the sensor.

5.4.11 outio2_usr

./mv_mipi_i2c.sh -r -f outio2_usr

./mv_mipi_i2c.sh -w -f outio2_usr -p1 [0,1]

value description
0 low
1 high
5.4.12 outio2_rvs

./mv_mipi_i2c.sh -r -f outio2_rvs

./mv_mipi_i2c.sh -w -f outio2_rvs -p1 [0,1]

Reverse OUT_IO1 high and low levels if set to 1.

5.5 Image Features

5.5.1 maxwh

./mv_mipi_i2c.sh -r -f maxwh

Get the maximum supported resolution of the sensor.

5.5.2 maxfps

./mv_mipi_i2c.sh -r -f maxfps

The maximum frame rate supported in the current mode.

Depending on the configured ROI, the maximum frame rate will be different. This parameter supports decimals.

5.5.3 fps*

./mv_mipi_i2c.sh -w -f fps -p1 [framerate]

./mv_mipi_i2c.sh -r -f fps

Configure the actual frame rate of the camera in the current mode.

Range:(0,maxfps].

In video streaming mode, this parameter determines the actual frame rate.

5.5.4 roi*

./mv_mipi_i2c.sh -w -f roi -p1 [x] -p2 [y] -p3 [width] -p4 [height]

./mv_mipi_i2c.sh -r -f roi

ROI(region of interest) is the sensor output area, and the default is full screen output.

Parameter requirements:

[x] [y] [height] must be 4-aligned;

[width] must be 8-aligned;

The minimum ROI resolution will be different for different sensors.

For example, IMX178 minimum resolution is: 376*320.

The camera will make necessary adjustments to the user parameters to meet the parameter requirements.

So it is highly recommended that you read out the actual ROI parameters after writing them.

5.5.5 imgdir

./mv_mipi_i2c.sh -w -f imgdir -p1 [0,3]

./mv_mipi_i2c.sh -r -f imgdir

value description
0 normal
1 mirror
2 flip
3 flip&mirror

The image is first flipped/mirrored and then ROI cropped. For details, please refer to the manual.

5.5.6 pixelformat

./mv_mipi_i2c.sh -w -f pixelformat -p1 [0,2]

./mv_mipi_i2c.sh -r -f pixelformat

value description
0 Mono8
1 Mono10
2 Mono12
4 UYVY

Note that for the MV-MIPI-IMX178, the AD bits of the sensor is always 12 bits, and the logic unit performs data rounding to achieve a different pixel format.

5.5.7 blacklevel

./mv_mipi_i2c.sh -w -f blacklevel -p1 [blacklevel]

./mv_mipi_i2c.sh -r -f blacklevel

This black level value will be set directly to the sensor.

5.5.8 testimg

./mv_mipi_i2c.sh -w -f testimg -p1 [0,2]

./mv_mipi_i2c.sh -r -f testimg

value description
0 Normal image
1 Test image 1
2 Test image 2

5.6 ISP

5.6.1 gamma

./mv_mipi_i2c.sh -r -f gamma

./mv_mipi_i2c.sh -w -f gamma -p1 [gamma]

Range (0,4.0],accurate is 0.01.

For now, gamma only works on 8bit depth image.

5.6.2 gammaenable

./mv_mipi_i2c.sh -r -f gammaenable

./mv_mipi_i2c.sh -w -f gammaenable -p1 [0,1]

Enable/Disable gamma function.

5.6.3 dpcenable

./mv_mipi_i2c.sh -r -f dpcenable

./mv_mipi_i2c.sh -w -f dpcenable -p1 [0,1]

Enable/Disable DPC(Defect Point Correction) function.

5.6.4 lutenable

./mv_mipi_i2c.sh -r -f lutenable

./mv_mipi_i2c.sh -w -f lutenable -p1 [0,1]

Enable/Disable LUT(Look-Up-Table) function.

5.6.5 lut

./mv_mipi_i2c.sh -r -f lut -p1 [lutfilename]

./mv_mipi_i2c.sh -w -f lut -p1 [lutfilename]

Import or export a lut curve to a file, refer to the provided lut_linear.txt for the file format.

5.6.6 expmode

./mv_mipi_i2c.sh -r -f expmode

./mv_mipi_i2c.sh -w -f expmode -p1 [0,2]

value description
0 ME: manual exposure
1 AE once: auto exposure once
2 AE: auto exposure continuous

Both ME and AE are easy to understand.

AE once: Execute automatic exposure in the set range once, then stop the adjustment.

5.6.7 metime

./mv_mipi_i2c.sh -w -f metime -p1 [us]

./mv_mipi_i2c.sh -r -f metime

Range (0,1000000/fps].Because of Note1 and range limitation, please read back to confirm the real metime take effect.

5.6.8 gainmode

./mv_mipi_i2c.sh -r -f gainmode

./mv_mipi_i2c.sh -w -f gainmode -p1 [0,3]

value description
0 MG: manual gain
1 AG once: auto gain once
2 AG: auto gain continuous

Both MG and AG are easy to understand.

AG once: Execute automatic gain in the set range once, then stop the adjustment.

5.6.9 mgain

./mv_mipi_i2c.sh -w -f mgain -p1 [gain]

./mv_mipi_i2c.sh -r -f mgain

Range [0,MAX_Gain],MAX_Gain varies from sensor to sensor, for example, IMX178 is 48dB.

Read back to confirm the real mgain take effect.

5.6.10 aatarget

./mv_mipi_i2c.sh -r -f aatarget

./mv_mipi_i2c.sh -w -f aatarget -p1 [1,255]

The target brightness of AE and AG algorithm.

Within the set range, the algorithm will prioritize the increase in exposure time,

and increase the gain if the exposure time reaches the maximum and still cannot reach the set target brightness value.

5.6.11 aemaxtime

./mv_mipi_i2c.sh -r -f aemaxtime

./mv_mipi_i2c.sh -w -f aemaxtime -p1 [16,1000000/fps]

Maximum exposure time in AE mode.Range[16,1000000]. Note1.

Please read back to confirm the real metime take effect.

5.6.12 agmaxgain

./mv_mipi_i2c.sh -r -f agmaxgain

./mv_mipi_i2c.sh -w -f agmaxgain -p1 [0,maxgain]

Maximum value of auto gain. The range and step vary according to the model.

Most sensors have a gain step of 0.1dB, some are 0.3dB.

5.6.13 exptime

./mv_mipi_i2c.sh -r -f exptime

Get the current exposure time. This command is valid in any exposure mode.

5.6.14 curgain

./mv_mipi_i2c.sh -r -f curgain

Gets the current gain. This command is valid in any exposure mode.

5.6.15 aaroienable

./mv_mipi_i2c.sh -w -f aaroienable -p1 [0,1]

./mv_mipi_i2c.sh -r -f aaroienable

Whether to enable AAROI statistics function, not enable means full ROI statistics.

5.6.16 aaroi

./mv_mipi_i2c.sh -w -f aaroi -p1 [x] -p2 [y] -p3 [width] -p4 [height]

./mv_mipi_i2c.sh -r -f aaroi

The AAROI coordinates are relative coordinates within the ROI area. So the area must be smaller than the image ROI.

5.6.17 aeag_run_once_save

./mv_mipi_i2c.sh -w -f aeag_run_once_save

Execute AE&AG once operation and save the results to the camera as manual values!
This is a function that is useful when the camera is installed.

It performs the following operations:

  1. Set AE and AG range to MAX.
  2. Run AE once and AG once.
  3. Wait 5 seconds.
  4. Check AE once and AG once result.
  5. Save the previous result to manual mode.
  6. Run paramsave,save to flash.


5.7 Notes

Note1: All parameters of exposure time are in microseconds. However, due to the properties of the sensor, the actual exposure time unit of the sensor is 1 line, can not be accurate to 1us.

Note2: AE: Auto exposure; AG: Auto Gain; AA: AE and AG.

Note3: The AAROI coordinates are relative coordinates within the ROI area.