GP2AP030A00F < Appendix > Table of contents 1. Abstract 1.1. Features..... ... ... ... .... ... ... ... ... ... ... .. .... ... ... ... ... ... ... .. .... ... ... .Attachment-3 1.2. I2C bus interface....... .... ... ... ... ... ... ... .. .... ... ... ... ... ... ... .. .... ... ... . .Attachment-4 1.2.1. Write Format....... . .... ... ... ... ... ... ... .. .... ... ... ... ... ... ... .. .... ... .Attachment-4 1.2.2. Read Format........ . .... ... ... ... ... ... ... .. .... ... ... ... ... ... ... .. .... .. .Attachment-4 1.2.3. Others and Notes..... .... ... ... ... ... ... ... .. .... ... ... ... ... ... ... .. .... ... .Attachment-4 2. Description of functions 2.1. Ambient light sensor (ALS) mode.... ... ... ... ... . .... ... ... ... ... ... ... .. .... ... ... ..Attachment-5 2.2. Proximity sensor (PS) mode... ... ... ... ... ... ... . .... ... ... ... ... ... ... .. .... ... ... ..Attachment-5 2.3. Software-shutdown mode.... ... ... ... ... ... ... .. .... ... ... ... ... ... ... .. .... ... ... ..Attachment-5 2.4. Hardware-shutdown........ ... ... ... ... ... ... .. .... ... ... ... ... ... ... .. .... ... ... . .Attachment-5 2.5. Auto-shutdown/Continuous operation...... ... ... .. .... ... ... ... ... ... ... .. .... ... ... ..Attachment-5 2.6. Operating mode selection.... ... ... ... ... ... ... .. .... ... ... ... ... ... ... .. .... ... ... ..Attachment-5 2.7. Number of measurement cycles (Persistence)...... .. .... ... ... ... ... ... ... .. .... ... ... . .Attachment-5 2.8. Resolution/Measuring time.... ... ... ... ... ... ... . .... ... ... ... ... ... ... .. .... ... ... .Attachment-5 2.9. Maximum measurable range...... ... ... ... ... ... . .... ... ... ... ... ... ... .. .... ... ... .Attachment-5 2.10. Intermittent operating function........ ... ... ... .. .... ... ... ... ... ... ... .. .... ... ... .Attachment-5 2.11. LED drive peak current setting........ ... ... ... .. .... ... ... ... ... ... ... .. .... ... ... ..Attachment-5 2.12. INT terminal output type setting....... ... ... ... .. .... ... ... ... ... ... ... .. .... ... ... .Attachment-5 2.13. LED modulation frequency(duty) setting....... ... .... ... ... ... ... ... ... .. .... ... ... .. .Attachment-6 2.14. Software reset...... .. .... ... ... ... ... ... ... .. .... ... ... ... ... ... ... .. .... ... ... . .Attachment-6 2.15. Interrupt function :ALS mode..... ... ... ... ... . .... ... ... ... ... ... ... .. .... ... ... ..Attachment-6 2.16. Interrupt function :PS mode..... ... ... ... ... ... .... ... ... ... ... ... ... .. .... ... ... .Attachment-6 3. Basic operation 3.1. Ambient light sensor mode (ALS)...... ... ... ... ... .... ... ... ... ... ... ... .. .... ... ... .Attachment-7 3.2. Proximity sensor mode (PS).... ... ... ... ... ... ... .... ... ... ... ... ... ... .. .... ... ... ..Attachment-7 3.3. PS and ALS alternating mode (PS&ALS)...... ... ... .... ... ... ... ... ... ... .. .... ... ... .Attachment-7 3.4.Count value checking mode (debug mode for PS).. ... .... ... ... ... ... ... ... .. .... ... ... . .Attachment-8 4. Register Mapping 4.1. Register Mapping...... .... ... ... ... ... ... ... .. .... ... ... ... ... ... ... .. .... ... ... ..Attachment-9 4.2. Precautions for Register setting....... ... ... ... ... . .... ... ... ... ... ... ... .. .... ... ... .Attachment-9 4.3. Register Functions...... .... ... ... ... ... ... ... .. .... ... ... ... ... ... ... .. .... ... ... .Attachment-9 4.4. Register settings for Basic operation... ... ... ... ... . .... ... ... ... ... ... ... .. .... ... .. .Attachment-10 4.4.1. Software-shutdown :OP[3].. ... ... ... ... ... .... ... ... ... ... ...Attachment-10 4.4.2. Auto-shutdown/Continuous operation :OP[2].. ... ... ... ... ... .... ... ... ... ... ...Attachment-10 4.4.3. Operating mode selection operation :OP [1:0]... ... ... ... ... .... ... ... ... ... ...Attachment-10 4.4.4. Number of measurement cycles setting :PRST[1:0].... ... ... ... ... ... ... .. .... ... .Attachment-10 4.4.5. Interrupt type setting operation :INTTYPE... ... ... ... . .... ... ... ... ... ... .Attachment-11 4.4.6. Intermittent operating function :INTVAL[1:0].... ... ... .... ... ... ... ... ... .Attachment-11 4.4.7. INT terminal setting operation :PIN[1:0]... ... ... ... .. .... ... ... ... ... ... .Attachment-12 4.4.8. Software reset uous operation :RST.. ... ... ... ... ... . .... ... ... ... ... .. .Attachment-12 Sheet No.: OP13013EN Attachment-1 GP2AP030A00F 5. 6. Register settings for PS 5.1. Output value of sensing result for detection/non-detection 5.2. Output value of PS interrupt result ction/non-detection 5.3. Resolution/Measuring duration setting for PS mode on 5.4. Maximum measurable range detection/non-detection 5.5. LED drive peak current setting detection/non-detection 5.6. LED modulation frequency(duty) setting on-detection 5.7. Proximity low threshold (Loff) detection/non-detection 5.8. Proximity high threshold (Lon) detection/non-detection 5.9. PS Detection result result for detection/non-detection :PROX... ... ... ... ... . .... .Attachment-13 :FLAG_P.... ... ... ... . .... .Attachment-13 :RES_P [2:0]. ... ... ... . .... .Attachment-13 :RANGE_P[2:0]... ... ... .... .Attachment-13 :IS [1:0].. ... ... ... ... . .... .Attachment-14 :FREQ...... ... ... ... . .... .Attachment-14 :PL[15:0].. ... ... ... ... .... .Attachment-14 :PH[15:0]... ... ... ... .. .... .Attachment-14 :D2[15:0]. ... ... ... ... . .... .Attachment-14 Register settings for ALS 6.1. Output value of ALS interrupt result 6.2. Resolution/Measuring duration setting for ALS mode 6.3. Maximum measurable range for ALS mode 6.4. ALS interrupt low threshold on setting for ALS mode 6.5. ALS interrupt high threshold on setting for ALS mode 6.6. ALS Detection result easuring duration setting for ALS mode :FLAG_A....... ... ... . .... .Attachment-15 :RES_A [2:0].. ... ... ... .... .Attachment-15 :RANGE_A[2:0]..... ... .... .Attachment-15 :TL[15:0]. ... ... ... ... . .... .Attachment-15 :TH[15:0].. ... ... ... ... .... .Attachment-15 :D0[15:0],D1[15:0].. ... . .... .Attachment-16 7. INT terminal output mode 7.1. Detection result output mode for PS. ... ... ... ... ... .... ... ... ... ... ... ... .. .... ... ...Attachment-17 7.2. Interrupt output mode... .... ... ... ... ... ... ... .. .... ... ... ... ... ... ... .. .... ... ... .Attachment-17 8. Average consumption current in operation 8.1. Average consumption current in operation....... ... . .... ... ... ... ... ... ... .. .... ... .. .Attachment-18 8.2. Average consumption current at ambient light sensor (ALS) mode....... ... ... ... .... ... .. .Attachment-18 8.3. Average consumption current at proximity sensor (PS) mode..... ... ... ... ... ... .... ... ... .Attachment-18 9. Countermeasure against external light noise in PS mode 9.1. Countermeasure against external light noise in PS mode..... ... ... ... ... ... .... ... ... ... .Attachment-19 10. Recommended operating mode/Procedure of register setting 10.1. Shutdown mode... .... ... ... ... ... ... ... .. .... ... ... ... ... ... ... .. .... ... ... ... .Attachment-19 11. Sample programs 11.1. Sample program of function...... ... ... ... .. .... ... ... ... ... ... ... .. .... ... ... ... ..Attachment-20 11.2. Sample program for PS and ALS alternating mode.... ... ... ... ... ... ... .. .... ... ... ....Attachment-21 11.3. Sample program for ALS mode...... ... ... ... .... ... ... ... ... ... ... .. .... ... ... ... .Attachment-23 12. Recommended Window Size (Reference) 12.1. Without light shield.... .... ... ... ... ... ... ... .. .... ... ... ... ... ... ... .. .... ... ...Attachment-25 12.2. With light shield...... .... ... ... ... ... ... ... .. .... ... ... ... ... ... ... .. .... ... ... .Attachment-26 13. Data(Reference) 13.1. LED drive peak current..... ... ... ... ... ... ... .. .... ... ... ... ... ... ... .. .... ... .. .Attachment-27 13.1.1. LED drive peak current vs. VLED (Vcc=VLED)....... ... ... ... ... ... ... .. .... ... ... .Attachment-27 13.1.2.LED drive peak current vs. Vcc (VLED=3V)...... .... ... ... ... ... ... ... .. .... ... ... .Attachment-27 13.2. Spectral Responsivity...... ... ... ... ... ... ... .. .... ... ... ... ... ... ... .. .... ... ... .Attachment-28 13.3. Proximity sensor (PS) mode.. ... ... ... ... ... ... . .... ... ... ... ... ... ... .. .... ... ... .Attachment-28 Sheet No.: OP13013EN Attachment-2 GP2AP030A00F 1. Abstract GP2AP030A00F is ambient light sensor and proximity sensor with function ambient light sensing and proximity sensing by setting register. Proximity sensor (PS) mode: Judgment result of object existence can be referred by reading register value(16bit) via I 2C bus interface.INT terminal can be changed either interrupt output or sensing result output (detection/non-detection status) by setting register in PS mode. Ambient light sensor (ALS) mode: Detection result of ambient light can be referred by reading register value(16bit) via I2C bus interface. INT terminal can be changed interrupt output by setting register in PS mode. This product is possible to operate both PS and ALS modes alternately. Software-shutdown mode Ambient light sensor(ALS) mode Proximity sensor(PS) mode PS and ALS alternating mode Fig.1 Operating mode of GP2AP030A00F(PS and ALS sensor) 1.1. Features ● Design This product is composed of following two chips in one package, which is IC with a built-in photodiode (PD) (Clear (visible and infrared) photodiode and Infrared photodiode) for ambient light sensors and proximity sensors, and infrared LED. Achieving Small all-in-one package by Doubly-integrally-molded, transparent resin and light shield resin. Spectral sensitivity(ALS) of the human eye without infrared light effects can be obtain by deducting Infrared Photodiode from Clear photodiode. ● I2C bus interface This product has 7bit slave address adherence to I2C bus interface and can change register value for each function via I2C bus. ● INT terminal setting INT terminal can be changed either interrupt output or sensing result output (detection/non-detection status) by setting register in PS mode. ALS mode has only interrupt output setting. ● Power save mode Software-shutdown /Hardware-shutdown ● Slave address Enable to set 2 settings by ADDR terminal setting. Sheet No.: OP13013EN Attachment-3 GP2AP030A00F 1.2. I2C bus interface This product has 7bit slave address adherence to I2C bus interface and can change register value for each function via I2C bus. Besides, illuminance detection result and judgment result for detection/non-detection status can be read via I2C bus. Table 1 Terminals for I2C bus interface are as follows. Pin Name Description SCL I2C Clock SDA I2C Data bus Basic data format are as follows. S T M A S R B T SDA DATA DATA SLAVE ADDRESS L S B R A / C W K A M C S K B A6 A5 A4 A3 A2 A1 A0 D7 D6 D5 D4 D3 D2 D1 D0 L S B S A T C O K P D7 D6 D5 D4 D3 D2 D1 D0 Fig.2 I2C Basic data format DATA: Data which write into internal register/read from internal register. SLAVE ADDRESS:Enable to set 2settings by ADDR terminal setting. Table 2 I2C slave address A5 A4 A3 1 1 1 0 0 0 ADDR terminal setting A6 Lo LEVEL/OPEN 0 Hi LEVEL 1 R/W:Read:X=1, Write:X=0 A2 0 1 A1 0 0 A0 1 0 R/W X X 1.2.1. Write Format Write value in register and enable to write the next address sequentially after writing data. Data writing will be end with inputting stop-condition. WordAddress:00H PROX, FLAG_P and FLAG_A register in 00H are read only. WordAddress:0CH~11H D0[15:0], D1[15:0] and D2[15:0] registers from 0CH to 11H are read only. Bit width S 7 Slave Address 1 0 A 8 Word Address A 8 Write Data1 A 8 Write Data2 A P A: ACK,NA: NACK, S: ST ART , P: ST OP, X: don't care : Master output : Slave output Fig.3 I2C write format 1.2.2. Read Format Enable to read data in register. Following address can be read sequentially by inputting ACK after reading data. Reading data will be stopped by inputting NACK. Stop-condition after setting Word address can be deleted since it corresponds to repeat-start-condition. Reading read data is done by not opening I2C bus interface. Bit width. 7 S Slave Address 1 0 A 8 WordAddress A (P) S 7 Slave Address 1 1 A 8 ReadData1 A 8 ReadData2 NA P A: ACK, NA: NACK, S: ST ART , P: ST OP, X: don't care : Master output : Slave output Fig.4 I2C read format 1.2.3. Others and Notes This product doesn’t support Clock-stretch function and General-call-address function. Sheet No.: OP13013EN Attachment-4 GP2AP030A00F 2. Description of functions 2.1. Ambient light sensor (ALS) mode Ambient light sensing results can be read at D0[15:0] and D1[15:0] register through I 2C bus interface. The device outputs raw data of CLEAR photodiode sensitive to both visible and infrared spectrum and IR photodiode sensitive to only infrared spectrum during ambient light sensing. It is necessary for device host (user side) to get illuminance value with calculation of both CLEAR data at D0[15:0] and IR data at D1[15:0]. The device outputs interrupt signal to INT terminal in case that D0[15:0] exceed/fall below judgment threshold level(TH[15:0]/TL[15:0]) set before sensing operation. 2.2.Proximity sensor (PS) mode Proximity sensing results can be read at D2[15:0] register through I 2C bus interface. The device outputs interrupt signal or detection/non-detection status on INT terminal in which case D2[15:0] exceed/fall below judgment threshold level(PH[15:0]/PL[15:0]) set before sensing operation. 2.3. Software-shutdown mode This product has shutdown function by which all circuits except I 2C go into shutdown mode and cease to draw supply current. In this case, I2C communication is available. Current consumption (Idd-s) in shutdown mode is less than 5uA when I2C bus interface is not used. 2.4. Hardware-shutdown All the circuits can be completely stopped by stopping the power supply to the terminal Vcc, and the current consumption can completely be cut. 2.5. Auto-shutdown/ Continuous operating function Select continuous operation or auto-shutdown after one time operation by setting OP[2] register. 2.6. Operating mode selection Operating modes are decided by setting OP[1:0] registers. Please select either mode, PS&ALS alternating mode, ALS only mode or PS only mode. In addition to these modes, you can set counts value checking mode (debug mode for PS) to confirm the reflection counts from the panel when your product is developed. 2.7. Number of measurement cycles(Persistence) Select number of measurement cycles by setting PRST[1:0] register(1time, 4times, 8times, and 16times). Sensor outputs interrupt signal or judgment result of detection/non-detection state by detecting threshold setting cycles continuously. This function helps to decrease malfunction by noise such as flash of camera. 2.8. Resolution/Measuring time ALS mode : Resolution and measuring time can be changed by setting RES_A[2:0] register. PS mode : Resolution and measuring time can be changed by setting RES_P[2:0] register. 2.9. Maximum measurable range ALS mode : Maximum measurable range can be changed by setting RANGE_A[2:0] register. PS mode : Maximum measurable range can be changed by setting RANGE_P[2:0] register. 2.10. Intermittent operating function This function is to reduce average consumption current by stopping part of circuit intermittently, and this is different from software shutdown function. Intermittent operating duration can be changed by setting INTVAL[1:0] register. Setting a longer intermittent operating duration makes LED average consumption current lower. However, update period of the detection result becomes long. It will make response time of detecting longer. 2.11. LED drive peak current setting Change drive peak current by setting IS[1:0] register. (LED drive peak current is 16.3mA, 32.5mA, 65mA and 130mA) 2.12. INT terminal output type setting INT terminal can be changed either interrupt output or sensing result output (detection/non-detection status) by setting PIN[1:0] register in PS mode. ALS mode has only interrupt output setting. Sheet No.: OP13013EN Attachment-5 GP2AP030A00F 2.13. LED modulation frequency (duty) setting LED modulation frequency setting can be changed by setting FREQ register. (Freq:327.5kHz, 81.8kHz at pulse width:1.5usec only) Setting a lower modulation frequency makes LED average consumption current lower. 2.14. Software reset All registers can be initialized by writing 1 to RST register. RST register value also becomes 0 automatically which is initial value. 2.15. Interrupt function :ALS mode Interrupt function becomes available by setting TH[15:0] register and TL[15:0] register in ALS mode. Interrupt signal is outputted to INT terminal in case that detection result (D0[15:0] value) is less than TL[15:0] setting value or more than TH[15:0] value. 2.16. Interrupt function :PS mode Interrupt function becomes available by setting PH[15:0] register and PL[15:0] register in PS mode. Interrupt signal or detecting/non-detecting judgment result is outputted to INT terminal in case that detection result (D2[15:0] value) is less than PL[15:0] setting value or more than PH[15:0] value. Enable to change desirable threshold in detecting distance and hysteresis by setting PH[15:0] and PL[15:0] registers. However, detecting distance depends on LED output power as well. It can be changed by setting IS[1:0] register. Sheet No.: OP13013EN Attachment-6 GP2AP030A00F 3. Basic operation 3.1. Ambient light sensor (ALS) mode There are 2 photodiodes, CLEAR(sensitive to visible and infrared spectrum) and IR photodiodes (sensitive to only infrared spectrum) in this sensor. Illuminance value can be obtained by calculation from CLEAR and IR data. The device continues to execute integration operation until set measuring time(100msec, recommended) passes, and then outputs the results of CLEAR photodiode at D0[15:0] register and IR photodiode at D1[15:0] register. Illuminance value can be obtained by some calculation using D0[15:0] and D1[15:0]. Ambient light sensor mode ALS ALS ALS ALS D0[15:0] clear result clear result clear result clear result D1[15:0] infrared result infrared result infrared result infrared result Fig.5 Output results for ALS mode 3.2. Proximity sensor mode (PS) In PS mode, the device can detect proximity objects by which integrates incident light in IR(infrared) photodiode during the time without emission of LED (LED off) and the time with emission of LED (LED on) in order to eliminate the influence of ambient light. In PS mode, the way of detection is as follows; [1]Obtain detection result1 at LED off which integrates incident light amount in PD for PS during a set period (recommended value: 1.56ms). (Detection result1 is not outputted to register). [2]Obtain detection result2 at LED on which integrates incident light amount in PD for PS during a set period (recommended value: 1.56ms). (Detection result2 is not outputted to register). [3]Then, obtain detection result3 by subtracting Detection result2 and result1. So this value has external light cancellation. By using this value, proximity sensing judgment is done if reflective object is there or not. Proximity sensor mode PS (LEDoff) PS (LEDon) detection result1 detection result2 D2[15:0] PS (LEDoff) PS (LEDon) detection result3 = detection result2- detection result1 detection result3 = detection result2- detection result1 Fig.6 Output results for PS mode 3.3. PS and ALS alternating mode (PS&ALS) This product is possible to operate both PS and ALS modes alternately. In PS and ALS alternating mode, the way of detection is as follows; [1]Obtain detection result1 at LED off which integrates incident light amount in PD for PS during a set period (recommended value: 1.56ms). (Detection result1 is not outputted to register). [2]Obtain detection result2 at LED on which integrates incident light amount in PD for PS during a set period (recommended value: 1.56ms). (Detection result2 is not outputted to register). [3]Then, obtain detection result3 by subtracting Detection result2 and result1. So this value has external light cancellation. By using this value, proximity sensing judgment is done if reflective object is there or not. [4]The device integrates incident light in CLEAR photodiode and IR photodiode during a set period (recommended value: 25msec), and then outputs the detection results to D0[15:0] and D1[15:0] respectively. The raw integrated data of CLEAR photodiode and IR photodiode can be obtained in D0[15:0] and D1[15:0] respectively. Sheet No.: OP13013EN Attachment-7 GP2AP030A00F ALS and PS mode PS (LEDoff) PS (LEDon) detection result1 detection result2 PS (LEDoff) ALS D0[15:0] clear result D1[15:0] infrared result D2[15:0] detection result3 = detection result2- detection result1 PS (LEDon) ALS clear result infrared result detection result3 = detection result2- detection result1 Fig.7 Output results for PS and ALS alternating mode 3.4. Count value checking mode (debug mode for PS) Count value checking mode (debug mode for PS) can be used when developing your product. Enable to output detection result1(LEDoff) to D1[15:0] and detection result2(LEDon) to D2[15:0] by setting “11” in OP[1:0] register. If you use this mode, you can examine the counts reflected from panel by subtracting result1 from result2. Sheet No.: OP13013EN Attachment-8 GP2AP030A00F 4. Register Mapping 4.1. Register Mapping When Vcc power is supplied, GP2AP030A00F starts up with initializing all registers. Table 3 Register Mapping ADDRESS 00H 01H 02H 03H 04H 05H 06H 07H 08H 09H 0AH 0BH 0CH 0DH 0EH 0FH 10H 11H DATA D7 OP3 D6 OP2 D5 OP1 PRST1 PRST0 RES_A2 0 INTTYPE RES_P2 INTVAL1 INTVAL0 IS1 TL7 TL6 TL5 TL15 TL14 TL13 TH7 TH6 TH5 TH15 TH14 TH13 PL7 PL6 PL5 PL15 PL14 PL13 PH7 PH6 PH5 PH15 PH14 PH13 D0_7 D0_6 D0_5 D0_15 D0_14 D0_13 D1_7 D1_6 D1_5 D1_15 D1_14 D1_13 D2_7 D2_6 D2_5 D2_15 D2_14 D2_13 D4 OP0 D3 RES_A1 RES_P1 IS0 TL4 TL12 TH4 TH12 PL4 PL12 PH4 PH12 D0_4 D0_12 D1_4 D1_12 D2_4 D2_12 D2 D1 D0 0 PROX FLAG_P FLAG_A RES_A0 RANGE_A2 RANGE_A1 RANGE_A0 RES_P0 RANGE_P2 RANGE_P1 RANGE_P0 PIN1 PIN0 FREQ RST TL3 TL2 TL1 TL0 TL11 TL10 TL9 TL8 TH3 TH2 TH1 TH0 TH11 TH10 TH9 TH8 PL3 PL2 PL1 PL0 PL11 PL10 PL9 PL8 PH3 PH2 PH1 PH0 PH11 PH10 PH9 PH8 D0_3 D0_2 D0_1 D0_0 D0_11 D0_10 D0_9 D0_8 D1_3 D1_2 D1_1 D1_0 D1_11 D1_10 D1_9 D1_8 D2_3 D2_2 D2_1 D2_0 D2_11 D2_10 D2_9 D2_8 Initial Value H'00 H'00 H'00 H'00 H'00 H'00 H'FF H'FF H'00 H'00 H'FF H'FF H'00 H'00 H'00 H'00 H'00 H'00 R/W R/W R +clear R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R R R R R R 4.2. Precautions for Register setting - Please start setting registers after power-supply voltage becomes stable up to 90% or more set value. Please wait for some 1msec before setting registers from power-on. - PROX, FLAG_P and FLAG_A registers are able to be cleared by writing 0 data in each register. (but these registers can’t be written 1 data.) - Please don’t set the address 12H and the larger ones. (Test registers are assigned in those addresses) 4.3. Register Functions Functions and set contents of the registers are shown below. Table 4 description of the register function ADDR 00H 01H 02H 03H 04H,05H 06H,07H 08H.09H 0AH,0BH 0CH,0DH 0EH,0FH 10H,11H register OP3 OP2 OP[1:0] PROX FLAG_P FLAG_A PRST [1:0] RES_A[2:0] RANGE_A[2:0] INT T YPE RES_P[2:0] RANGE_P[2:0] INT VAL[1:0] IS[1:0] PIN[1:0] FREQ RST TL TH PL PH D0 D1 D2 function Software shutdown Auto shutdown/Continuous operation Operating mode selection PS: detection/non-detection PS: interrupt result ALS: interrupt result Number of measurement cycles ALS:Resolution ALS:Maximum measurable range Interrupt type setting PS:Resolution PS:Maximum measurable range Intermittent operating ILED drive peak current setting INT terminal setting LED modulation frequency Software Reset ALS:low threshold setting ALS:High threshold setting PS:low threshold setting(Loff) PS:High threshold setting(Lon) ALS result:Clear ALS result :IR PS result setting 0:shutdown、1:operation 0:auto shutdown, 1:continuous operating function 00:ALS and PS alternating, 01:ALS, 10:PS, 11: debug mode 0:non-detection, 1:detection 0:non-interrupt, 1:interrupt 0:non-interrupt, 1:interrupt 00:once, 01:4 cycles, 10:8 cycles, 11:16 cycles 000:8bits(0.39msec) - 111:19bits(800msec) 000:×1 - 111:×128 0:level, 1:pulse 100:8bits(0.39msec) - 111:16bits(100msec) 000:×1 - 111:×128 00:0、01:4 times、10:8 times、11:16 times 00:16.3mA、01:32.5mA、10:65mA、11:130mA 00:ALS or PS, 01:ALS, 10:PS, 11:PS(Detection/Non-detection) 0:327.5kHz、1:81.8kHz 0:not reset, 1:reset 16bits counts setting 16bits counts setting 16bits counts setting 16bits counts setting 16bits output data from Clear PD 16bits output data from IR PD 16bits output data in PS mode Sheet No.: OP13013EN Attachment-9 GP2AP030A00F 4.4. Register settings for Basic operation 4.4.1. Software-shutdown: OP[3] (ADDRESS:00H) Control power supply to the circuit. LED drive circuit is always off in shutdown mode. After power on, start with shutdown mode. OP [3] register (Address 00H) 0: shutdown mode 1: operating mode. 4.4.2. Auto-shutdown/Continuous operation: OP[2](ADDRESS:00H) Select auto-shutdown mode or continuous operating mode. After shutdown, OP[3] register will be automatically cleared. OP [2] register (Address 00H) 0: auto shutdown mode 1: continuous operating mode. 4.4.3. Operating mode selection: OP [1:0] (ADDRESS:00H) Select ALS mode or PS mode or alternating mode(PS + ALS). OP [1:0] register (Address 00H) 01: ALS mode Detection result of clear photodiode is output to D0[15:0] register (Address 0CH, 0DH). Detection result of infrared photodiode is output to D1[15:0] register (Address 0EH, 0FH). 10: PS mode Sensing result of detection/non-detection is output to PROX register(Address 00H). Detection result of distance is output to D2[15:0] register (Address 10H, 11H). 00: PS and ALS alternating mode 11: Test mode for PS Confirmation of LEDoff and LEDon counts respectively resulting in PS counts. 4.4.4. Number of measurement cycles setting: PRST[1:0] (ADDRESS:01H) Select number of measurement cycles by setting PRST[1:0] register. Output interrupt result or judgment result for detection/non-detection in case detection result is over threshold continuously more than the set cycles in PRST[1:0] register. PRST[1:0] register(Address 01H): 00: 1cycle 01: 4cycles, 10: 8cycles 11: 16cycles ・Algorithm for detecting object in PS is as follows. <Judge the change from non-detecting status to detecting status> Detection result is over high threshold (Lon) N times continuously : Detection Other : Non-detection <Judge the change from detecting status to non-detecting status> Detection result is over low threshold (Loff) N times continuously : Non-Detection Other : Detection ・Algorithm for detecting object in ALS is as follows. <Judge the change from low illuminance to high illuminance> Detection result is over high threshold (th) N times continuously : Output interrupt Other : Non-output <Judge the change from high illuminance to low illuminance> Detection result is over low threshold (tl) N times continuously :Output interrupt Other : Non-output Sheet No.: OP13013EN Attachment-10 GP2AP030A00F 4.4.5. Interrupt type setting: INTTYPE (ADDRESS:02H) Select level interrupt type or pulse interrupt type. INTTYPE register (Address 02H) 0: level interrupt type In this case, transition from H to L in INT terminal become occurring interrupt signal and INT terminal will hold L level until interrupt is cleared. level interrupt type Occuring INT terminal High (H→L) Low Clearing interrupt Reading data Fig.8 Interrupt output (level interrupt type) 1: pulse interrupt type In this case, L pulse output in INT terminal become occurring interrupt signal and INT terminal will not hold L level. Therefore we need not to clear interrupt flag(FLAG_P, FLAG_A). FLAG_P and FLAG_A are cleared automatically in 1 clock (about 1.5us). pulse interrupt type Occuring interrupt High INT terminal (H→L) Reading data Low Fig.9 Interrupt output (pulse interrupt type ) 4.4.6. Intermittent operating function: INTVAL[1:0](ADDRESS 03H) Enable to change intermittent operating periods by setting INTVAL [1:0] register (Address 03H). 00: 0 time, 01: 4 times, 10: 8 times, 11: 16 times Intermittent operating will be done during setting period in RES_A[2:0] and RES_P(Resolution/measuring time) by the number of times set by INTVAL [1:0] register. For ALS mode, in case of RES_A [2:0]=011 16bit setting(measuring period 100msec) and INTVAL [1:0]=01( 4 intermittent operating cycles), quiescent operation time will be 400msec(=100msec × 4 times). For PS mode, in case of RES_P [2:0]=010 12bit setting(measuring period 6.25msec) and INTVAL [1:0]=01( 4 intermittent operating cycles), quiescent operation time will be 25msec(=6.25msec × 4 times). For ALS mode and PS mode sequentially, in case of RES_A[2:0]=011 16bit setting(measuring period 100msec) ,RES_P [2:0]=010 12bit setting(measuring period 6.25msec) and INTVAL [1:0]=01( 4 intermittent operating cycles), quiescent operation time will be 25msec(=6.25msec × 4 times). PS mode condition takes priority. Although setting a longer intermittent operating period contributes to reduce average consumption current, it makes update period and response time for detection longer as a result. Need to set it considering your actual conditions in use. Ambient light sensor (ALS) mode INTVAL[1:0]=01 : 4 times setting ALS Intermittent operating cycle 4 times Proximity sensor (PS) mode PS (LEDoff) PS (LEDon) ALS INTVAL[1:0]=01 :4 times setting Intermittent operating cycle 4 times PS (LEDoff) PS (LEDon) Proximity and Ambient light sensor (PS & ALS) mode INTVAL[1:0]=01 :4 times setting PS (LEDoff) PS (LEDon) ALS Intermittent operating cycle 4 times PS (LEDoff) PS (LEDon) ALS *PS mode condition takes priority Fig.10 intermittent operating for each mode Sheet No.: OP13013EN Attachment-11 GP2AP030A00F 4.4.7. INT terminal setting: PIN[1:0](ADDRESS 03H) Select output mode in INT terminal by setting PIN register (Address 03H). The outputs by INCLUSIVE-OR(FLAG_P, FLAG_A), FLAG_P, FLAG_A, PROX can be selected. Table 5 INT terminal setting PIN[1:0] Setting Output data 00 01 10 11 Interrupt output for PS mode and ALS mode Interrupt output for ALS mode only Interrupt output for PS mode only Detection/Non-detection judgment output FLAG_P or FLAG_A FLAG_A FLAG_P PROX 4.4.8. Software reset: RST(ADDRESS 03H) Initialize all registers by writing 1 in RST register. RST register is also initialized automatically and becomes 0. Sheet No.: OP13013EN Attachment-12 GP2AP030A00F 5. Register settings for PS 5.1. Output value of sensing result for detection/non-detection: PROX (ADDRESS 00H) Sensing result for detection/non-detection is output in PS mode. There is a function which clears data by writing 0 in PROX register. PROX register(Address 00H): 0: non-detection, 1: detection 5.2. Output value of PS interrupt result: FLAG_P(ADDRESS 00H) FLAG_P register is output interrupt result for PS mode. There is a function which clears by writing 0 in d FLAG_P register. FLAG_P register (Address 00H) : 0: non-interrupt, 1: interrupt 5.3. Resolution/Measuring duration setting for PS mode: RES_P [2:0](ADDRESS 02H) Select measuring resolution and measuring duration for PS mode by setting RES_P [2:0] register (Address 02H). 2 times of measuring duration is required for PS mode since detection result is gotten by subtraction of result 1 (LEDoff) and result 2 (LEDon) If resolution is low, measuring tolerance becomes large. Please have an adjustment at your system. Table 6. Resolution/Measuring duration setting for PS mode RES_P[2:0] Resolution 000 001 010 011 100 101 110 111 16bit 14bit 12bit 10bit 8bit 6bit 4bit 2bit Measuring time PS mode 100msec × 2 25msec × 2 6.25msec × 2 1.56msec × 2 0.39msec × 2 0.097msec × 2 0.024msec × 2 0.006msec × 2 Remarks recommended Not Allowed Not Allowed Not Allowed Not Allowed *Grayed-out portions is not recommended. 5.4. Maximum measurable range for PS mode: RANGE_P[2:0](ADDRESS 02H) Select maximum measurable range for PS mode by setting RANGE_P [2:0] register (Address 02H). Detect with a set range in PS mode. Maximum count value is outputted in case of incident light exceeding maximum measurable range. It is possible to have countermeasure for external light by setting a large count value at maximum measurable range. In case external light exceeds maximum sensing range, “non-detection” will be output because both detection result 1 (LEDoff) and detection result 2 (LEDon) become maximum count values, and the subtraction result(detection result 2 – result 1) become 0. Changing maximum measurable range, detection result count in PS mode is also change. In case of considering 000: ×1 setting as ×1 time, count would be 1/2 times at 001: ×2 setting, 1/4 times at 010: ×4 setting. Adjusting detecting distance by proximity low threshold PL[15:0] and PH[15:0]. It is necessary to set them considering the condition in the actual use and evaluating at your system. If you set Auto Light Cancellation mode, you should be at least four times(×4) the maximum measurable range setting for PS mode(RANGE_P [2:0]). Table 7. Maximum measurable range for PS mode RANGE_P[2:0] Maximum measurable range PS mode 000 001 010 011 100 101 110 111 ×1 ×2 ×4 ×8 ×16 ×32 ×64 ×128 Remarks recommended recommended *Grayed-out portions is not recommended. Sheet No.: OP13013EN Attachment-13 GP2AP030A00F 5.5. LED drive peak current setting IS [1:0](ADDRESS 03H) Enable to select LED drive peak current by setting IS [1:0] register (Address 03H) in PS mode. In case of changing this setting, the count obtained by subtraction detection result 1 (LEDoff) from detection result 2 (LEDon) at PS mode will change correspond to the set LED drive peak current. In case of considering 00:16.3mA setting as x1 time, count will increase 2times at 01:32.5mA setting, 4times at 10:65mA setting, x8 times at 11:130mA setting. Please adjust detecting distance with proximity low threshold PL[15:0] and proximity high threshold PH[15:0]. LED drive peak current will depend on Vcc voltage. (Refer to 13.1. LED drive peak current data) Table 8. LED drive peak current IS[1:0] 00 01 10 11 LED drive peak current 16.3 mA 32.5 mA 65 mA 130 mA Remarks recommended *Grayed-out portions is not recommended. 5.6. LED modulation frequency(duty) setting: FREQ (ADDRESS 03H) Select modulation frequency of LED driving period. FREQ register (Address 03H): 0: 327.5kHz (Duty during a PS measurement: 25.0%) 1: 81.8kHz (Duty during a PS measurement: 6.3%) Changing modulation frequency setting, count obtained by subtraction detection result1 (LEDoff) from detection result2 (LEDon) will be changed correspond to LED modulation frequency setting. Considering 1:81.8kHz setting as ×1 time, the count at 0:327.5kHz setting would be ×4 times. Please adjust detecting distance with proximity low threshold PL[15:0] and proximity high threshold PH[15:0]. 327.5kHz setting helps to adjust threshold value at long distance in PS because the count which subtracted detection result1 (LEDoff) from detection result2 (LEDon) would increase by ×4 times. In this case, average consumption current increase by ×4 times, therefore it is necessary to consider your setting by evaluating your system and condition. The duty and average consumption current under LED drive is shown under below. Table 9. Duty and average consumption current under LED drive INTVAL[1:0] 00 01 10 11 LED driving duty FREQ=0 25.0% 8.3% 5.0% 2.8% IS[1:0]=00(16.3mA) FREQ=0 FREQ=1 4.08 1.03 1.35 0.34 0.82 0.21 0.46 0.11 FREQ=1 6.3% 2.1% 1.3% 0.7% LED Average consumption current [mA] IS[1:0]=01(32.5mA) IS[1:0]=10(65mA) FREQ=0 FREQ=1 FREQ=0 FREQ=1 8.13 2.05 16.25 4.10 2.70 0.68 5.40 1.37 1.63 0.42 3.25 0.85 0.91 0.23 1.82 0.46 IS[1:0]=11(130mA) FREQ=0 FREQ=1 32.50 8.19 10.79 2.73 6.50 1.69 3.64 0.91 *Grayed-out portions is not recommended. 5.7. Proximity low threshold (Loff):PL[15:0](ADDRESS 08H、09H) Sets proximity low threshold in PL[15:0] register at PS mode. Please set it with confirming at optical mounting condition in the actual use. 5.8. Proximity high threshold (Lon):PH[15:0](ADDRESS 0AH、0BH) Sets proximity high threshold in PH[15:0] register at PS mode. Please set it with confirming at optical mounting condition in the actual use. 5.9.PS Detection result: D2 [15:0](ADDRESS 10H,11H) [PS mode] Detection result3 of proximity sensing is output to D2[15:0] register (Address 10H, 11H). Detection result1 and result2 is not output to register. Detection result3 is defined as follows, Detection result3 = Detection result2(LEDon) – Detection result1(LEDoff) In this case, 2 times of measuring duration is required for PS mode. Proximity sensor (PS) mode PS (LEDoff) PS (LEDon) detection result1 detection result2 D2[15:0] PS (LEDoff) detection result3 = detection result2- detection result1 PS (LEDon) detection result3 = detection result2- detection result1 Fig.11 Sensing results output for PS mode (ALC=0) Sheet No.: OP13013EN Attachment-14 GP2AP030A00F 6. Register settings for ALS 6.1. Output value of ALS interrupt result: FLAG_A(ADDRESS 00H) FLAG_A register is output interrupt result for ALS mode. There is a function which clears by writing 0 in d FLAG_A register. FLAG_A register (Address 00H): 0: non-interrupt, 1: interrupt 6.2. Resolution/Measuring duration setting for ALS mode: RES_A [2:0](ADDRESS 01H) Select measuring resolution and measuring duration for ALS mode by setting RES_A [2:0] register (Address 01H). If resolution is low, measuring tolerance becomes large. Please have an adjustment at your system. Table 10. Resolution/Measuring duration setting for ALS mode RES_A[2:0] Resolution 000 001 010 011 100 101 110 111 19bit 18bit 17bit 16bit 14bit 12bit 10bit 8bit Measuring time Remarks ALS mode 800msec 400msec 200msec recommended 100msec recommended 25msec 6.25msec 1.56msec 0.39msec *Grayed-out portions is not recommended. 6.3. Maximum measurable range for ALS mode: RANGE_A[2:0](ADDRESS 01H) Select maximum measurable range for ALS mode by setting RANGE_A [2:0] register (Address 01H). Detect with a set range in ALS mode. Maximum count value is outputted in case of incident light exceeding maximum measurable range. It is possible to have countermeasure for external light by setting a large count value at maximum measurable range. It is necessary to set them considering the condition in the actual use and evaluating at your system. Table 11. Maximum measurable range for ALS mode RANGE_A[2:0] 000 001 010 011 100 101 110 111 Maximum measurable range ALS mode ×1 ×2 ×4 ×8 ×16 ×32 ×64 ×128 Remarks recommended 6.4. ALS interrupt low threshold:TL[15:0] (ADDRESS 04H,05H) Sets interrupt low threshold in TL[15:0] register at ALS mode. Please set it with confirming at optical mounting condition in the actual use. 6.5. ALS interrupt high threshold:TH[15:0](ADDRESS 06H,07H) Sets interrupt high threshold in TH[15:0] register at ALS mode. Please set it with confirming at optical mounting condition in the actual use. Sheet No.: OP13013EN Attachment-15 GP2AP030A00F 6.6. ALS Detection result: D0 [15:0], D1 [15:0](ADDRESS 0CH,0DH,0EH,0FH) Detection result of clear photodiode is output to D0[15:0] register (Address 0CH, 0DH). Detection result of infrared photodiode is output to D1[15:0] register (Address 0EH, 0FH). The results of without infrared light can be obtained by some calculation using D0[15:0] and D1[15:0]. The results of without infrared light = α*D0[15:0] – β*D1[15:0] α and β factor are decided by ratio of D1 [15:0]/D0 [15:0]. These factors are shown below in the case of no panel. These factors might be necessary to be adjusted according to the case panel in use. Table 12. α and β factor for illuminance calculation Ratio of Data1[15:0]/ Data0[15:0] α β Ratio ≦ 0.67 6.650 9.653 0.67 < Ratio ≦0.90 1.805 1.977 0.90 < Ratio 0.000 0.000 Ambient light sensor (ALS) mode ALS ALS ALS ALS D0[15:0] clear result clear result clear result clear result D1[15:0] infrared result infrared result infrared result infrared result Fig.12 Sensing results output for ALS mode Sheet No.: OP13013EN Attachment-16 GP2AP030A00F 7.INT terminal output mode 7.1.Proximity detection/non-detection sensing result output mode INT terminal operates with sensing result output mode by setting PIN[1:0] register(Address 03H) 11:detection/non-detection sensing result output mode. Sensing result whether or not object is detected is able to be read out via I2C bus interface and output from INT terminal with negative logic. Distance Object Distance Far Proximity low threshold (Loff) PL[15:0] high threshold (Lon) PH[15:0] Near Time INT Terminal (H:Non-detect, L:Detect) PROX resister (0: Non-detect, 1:Detect) 0 1 0 1 0 Fig.13 Detection result output mode 7.2. Interrupt output mode Operates as interrupt output mode by setting PIN[1:0] register (Address 03H) 00,01,10: interrupt output mode. There are two kinds of output mode(level interrupt & pulse interrupt, see 4.4.5. Interrupt type setting). Below is a description of the level interrupt type. The result of interrupt judgment for ALS mode is written into FLAG_A register (Address 00H), and is read out from I2C bus interface. (0: Non-interrupt, 1: interrupt.) In this case, transition from H to L in INT terminal become occurring interrupt signal and INT terminal will be hold L level until interrupt is cleared. Interrupt will be cleared in writing 0 data in FLAG_A register. The result of interrupt judgment for PS mode is written into FLAG_P register (Address 00H), and is read out from I 2C bus interface. (0: Non-interrupt, 1: interrupt.) In this case, transition from H to L in INT terminal become occurring interrupt signal and INT terminal will be hold L level until interrupt is cleared. Interrupt will be cleared in writing 0 data in FLAG_P register. Normal term High INT terminal (H→L) Low Occuring Clearing interrupt Reading data Fig.14 Interrupt output (level interrupt type) Detecting operation will continue while INT terminal is L level. Update ALS detection result D0[15:0],D1[15:0] and sensing result of object detection/non-detection status. Therefore, host needs to read data after FLAG_A and FLAG_P register clear. Sheet No.: OP13013EN Attachment-17 GP2AP030A00F For example, as shown in below diagram, Interrupt occurs with FLAG_P=1: interrupt Actual object moves “Detection” to “Non-detection” to “Detection” while interrupt is cleared. In this case, while INT terminal (FLAG_P register) is hold, PROX value will be updated with result of judgment for detection/non-detection of object. Object Distance Distance Far Proximity low threshold(Loff) PL[15:0] high threshold(Lon) PH[15:0] Near Time INT terminal (FLAG_P register) (H→L) Clearing interrupt PROX register 0 1 0 1 (0:Non-detection, 1: Detection) Fig.15 Interrupt output mode (level interrupt type) 0 8.Average consumption current in operation 8.1. Average consumption current in operation Average consumption current in operation is the sum of the average current consumption value with Vcc terminal and LED consumption. The LED driven current flows from LEDA terminal to GND terminal. 8.2. Average consumption current at ambient light sensor (ALS) mode Average consumption current at ALS mode is typical 65uA. Using intermittent operating function, Consumption current can be typical 30uA in intermittence duration. 8.3. Average consumption current at proximity sensor (PS) mode In case of continuous operation, average consumption current in LED is estimated as below. [LED average consumption current] = LED drive peak current× LED modulating frequency setting/ (intermittence operating times+2) [LED drive peak current]: IS[1:0] register. (00:16.3mA、01:32.5mA、10:65mA、11:130mA) [LED modulating frequency]: FREQ register. 0:327.5kHz LED is driven with 1.5usec on time at 327.5kHz Averaging consumption current in LED will be half. 1:81.8kHz LED is driven with 1.5usec on time at 81.8kHz. Averaging consumption current in LED will be 1-8 time. [Intermittence operating cycle]:Enable to set with INTVAL[1:0] 00:0times, 01:4times, 10:8times, 11:16times For example, [LED drive peak current] :16.3mA IS[1:0]=00 [LED modulated frequency setting] :81.8kHz FREQ=1 [Intermittence operating time] :4times INTVAL[1:0]=01 In the above case, [LED averaging consumption current] = 16.3mA × 0.125 /(4 + 2)= 0.339mA Also, using auto-shut down function, it will be automatically shutdown after one operation. Utilizing it with adjusting your system, it contributes to reduce averaging consumption current in LED. Sheet No.: OP13013EN Attachment-18 GP2AP030A00F 9.Countermeasure against external light noise in PS mode 9.1. Countermeasure against external light noise in PS mode This product makes judgment of detection/non-detection by integrating light amount in PD for setting duration. In PS mode, eliminate external noise by subtracting output at LEDon and LEDoff. In case of exceeding maximum detectable range, judgment result will be non-detect status because both LEDoff and LEDon are maximum counts due to over detectable range and subtract value will be 0. Maximum detectable range is changed by setting RANGE_P[2:0] register. It contributes to make countermeasure with setting large value in maximum detectable range. 10.Recommended operating mode/Procedure of register setting When the ALS mode and PS mode switch, please shut down and switched again.. Shutdown mode PS mode ALS mode Fig.16 Recommended operating mode 10.1. Shutdown mode Below is an example of shutdown mode. If you shut down, the INT terminal states are maintained. If the INT terminal is L level, due to the increased power consumption, it is recommended that you clear the interrupt. Table 13 example of setting for Shutdown mode setting example Operation mode Shutdown Detection/non-detection sensing Clear result Detecting interrupt result (PS) Clear Detecting interrupt result (ALS) Clear Register ADDRESS 00H register OP[3]=b’0 PROX=b’0 FLAG_P=b’0 FLAG_A=b’0 Table 14 example of register setting table for Shutdown mode Register value Register bite Hex SYMBOL COMMAND I b’0000_0000 Remarks h’00 Sheet No.: OP13013EN Attachment-19 GP2AP030A00F 11.Sample programs 11.1. Sample program of function. #include <stdlib.h> /////////////// Parameter define #define ADDR_SLAVE_W 0x88 #define ADDR_SLAVE_R 0x89 //slave address of GP2AP030A00F for write mode //slave address of GP2AP030A00F for read mode #define I2C_ACK (0) int16 data_read( int addr); { int16 read_data = 0x0000; unsigned char ack; i2c_start(); //start condition ack = i2c_write(ADDR_SLAVE_W); //slave address send if (ack != I2C_ACK) { m_ErrorMsg(); } ack = i2c_write(addr); //word address send if (ack != I2C_ACK) { m_ErrorMsg(); } i2c_stop(); i2c_start(); ack = i2c_write(ADDR_SLAVE_R); //slave address send if (ack != I2C_ACK) { m_ErrorMsg(); } read_data = i2c_read(0); //nack i2c_stop(); return read_data; } //End of data_read function void data_write(int word_addr, int write_data) { unsigned char ack; i2c_start(); ack = i2c_write(ADDR_SLAVE_W); if (ack != I2C_ACK) { m_ErrorMsg(); return; } ack = i2c_write(word_addr ); if (ack != I2C_ACK) { m_ErrorMsg(); return; } ack = i2c_write(write_data); if (ack != I2C_ACK) { m_ErrorMsg(); return; } i2c_stop(); return; //start condition //slave address send //word address send //write data send Sheet No.: OP13013EN Attachment-20 GP2AP030A00F } 11.2. Sample program for PS and ALS alternating mode Table 15 example of sample program setting for PS mode setting Example register Operation mode Operation status(active) OP[3]=b’1 Operation mode Continuous operation OP[2]=b’1 Operation mode PS and ALS mode OP[1:0]=b’00 Number of detection*1 ×4(initial setting) PRST[1:0]=b’01 Resolution(ALS) 14bit(Measuring time25msec) RES_A[2:0]=b’100 Maximum detectable ×8(initial setting) RANGE_A[2:0]=b’011 range(ALS) RES_P[2:0]=b’011 Resolution(PS) 10bit(Measuring time1.56msec ×2) Maximum detectable ×4 RANGE_P[2:0]=b’010 range(PS) Intermittence duration 0time INTVAL[1:0]=b’00 LED drive peak current 130mA IS[1:0]=b’11 INT terminal setting PS(Detection/Non-detection) PIN[1:0]=b’11 LED modulation frequency 327.5kHz FREQ=b’0 Low threshold (PS) 10 counts(Loff 80mm) TL[15:0]=b’ 0000_0000_0000_1010(d’10) High threshold (PS) 10 counts(Lon 60mm) TH[15:0]=b’0000_0000_0000_1010(d’10) *1 Non-detection state is set to 4 cycles. Detection state is set to 1 cycle. Please refer to the following sample program. ---------------------------------- Sample program for PS and ALS alternating mode ---------------------------------#define Low_lux_mode 0 #define High_lux_mode 1 #defien NO_PROX 0 #define PROX 1 #define NO_INTERRUPT 0 #define INTERRUPT 1 int ALS_MODE = Low_lux_mode; int PROX_MODE = NO_PROX; // Initial setting data_write(0x01, 0x63); data _write(0x02, 0x1A); data _write(0x03, 0x3C); data _write(0x08, 0x0A); data _write(0x09, 0x00); data _write(0x0A,0x0A); data _write(0x0B,0x00); data _write(0x00, 0xC0); // // // // // // // // Write 63h in 1st register ・・・PRST ×4, ALS mode(res:14bit, range×8) Write 1Ah in 2nd register ・・・PS mode(res:10bit, range×4) Write 3Ch in 3rd register ・・・130mA, Detection/Non-detection judgment Write 0Ah in 8th register ・・・PS mode LTH:10 Write 00h in 9th register ・・・PS mode Write 0Ah in 10th register ・・・PS mode HTH:10 Write 00h in 11th register ・・・PS mode Write C0h in 00th register ・・・PS and ALS alternating mode for(;;) { switch(INTERRUPT_STATE){ case NO_INTERRUPT: delay_ms(200); D0 = data_read(0x0c); temp = data_read(0x0d); D0 = (temp << 8) | D0 D1 = data_read(0x0e); temp = data_read(0x0f); D1 = (temp << 8) | D1 Sheet No.: OP13013EN Attachment-21 GP2AP030A00F if(ALS_mode == Low_lux_mode){ if(D0 > 16000){ ALS_mode = High_lux_mode; data_write(0x00, 0x0C); if(PROX == NO_PROX) data_write(0x01, 0x67); else data_write(0x01, 0x27); data_write(0x00, 0xCC); // Low -> High lux mode //shutdown //prst 4, 14bit , ×128 //prst 1, 14bit , ×128 }else{ ratio = (float)data_als1/(float)data_als0; if(ratio<=0.67) lux = (6.650*(float)data_als0 – 9.653*(float)data_als1); else if(ratio>=0.9) lux = 0; else lux = (1.805*(float)data_als0 – 1.977*(float)data_als1); } }else{ if(D0 < 1000){ ALS_mode = Low_lux_mode; // High ->Low lux mode data_write(0x00, 0x0C); //shutdown if(PROX == NO_PROX) data_write(0x01, 0x63); //prst 4, 14bit, ×8 else data_write(0x01, 0x23); //prst 1, 14bit, ×8 data_write(0x00, 0xCC); } else{ ratio = (float)data_als1/(float)data_als0; if(ratio<=0.67) lux = 16*(6.650*(float)data_als0 – 9.653*(float)data_als1); else if(ratio>=0.9) lux = 0; else lux = 16* (1.805*(float)data_als0 – 1.977*(float)data_als1); } } break; case INTERRUPT: data = data_read(10h); if((data & 0x08) == 0x08){ PROX_MODE = PROX; DISPLAY CONTROL; if(ALS_MODE == Low_lux_mode) data_write(0x01,0x23); else data_write(0x01, 0x27); } else if((data & 0x08) == 0x00){ PROX_MODE = NO_PROX; DISPLAY CONTROL; if(ALS_MODE == Low_lux_mode) data_write(0x01,0x63); else data_write(0x01, 0x67); break; //prst 1, 14bit, ×8 //prst 1, 14bit, ×128 //prst 4, 14bit, ×8 //prst 4, 14bit, ×128 Sheet No.: OP13013EN Attachment-22 GP2AP030A00F } } ------------------------------- end of Sample program for PS and ALS alternating mode ------------------------------- 11.3. Sample program for ALS mode Below is a sample program. Table 16 example of sample program setting for ALS mode setting example register Operation mode Operation status(active) OP[3]=b’1 Operation mode Continuous operation OP[2]=b’1 Operation mode ALS mode OP[1:0]=b’01 Resolution(ALS) 14bit(Measuring time25msec) RES_A[2:0]=b’100 Maximum detectable ×8(initial setting) RANGE_A[2:0]=b’011 range(ALS)*1 *1 The range(×8 or ×128) is switched according to the D0 data. Low_lux_mode:×8,High_lux_mode:×128 --------------------------------- Sample program for ALS mode --------------------------------#define Low_lux_mode 0 #define High_lux_mode 1 int ALS_MODE = Low_lux_mode; // Initial setting data_write(0x01, 0x23); // Write 23h in 1st register ・・・ALS mode(res:14bit, range×8) data_write(0x00, 0xD0); // Write D0h in 00th register ・・・ALS mode for(;;) { delay_ms(200); D0 = data_read(0x0c); temp = data_read(0x0d); D0 = (temp << 8) | D0 D1 = data_read(0x0e); temp = data_read(0x0f); D1 = (temp << 8) | D1 if(ALS_mode == Low_lux_mode){ if(D0 > 16000){ ALS_mode = High_lux_mode; // Low -> High lux mode data_write(0x00, 0x0C); //shutdown data_write(0x01, 0x27); //prst 1, 14bit , ×128 data_write(0x00, 0xCC); }else{ ratio = (float)data_als1/(float)data_als0; if(ratio<=0.67) lux = (6.650*(float)data_als0 – 9.653*(float)data_als1); else if(ratio>=0.9) lux = 0; else lux = (1.805*(float)data_als0 – 1.977*(float)data_als1); } }else{ if(D0 < 1000){ ALS_mode = Low_lux_mode; // High ->Low lux mode data_write(0x00, 0x0C); //shutdown data_write(0x01, 0x23); //prst 1, 14bit, ×8 data_write(0x00, 0xCC); } else{ ratio = (float)data_als1/(float)data_als0; if(ratio<=0.67) Sheet No.: OP13013EN Attachment-23 GP2AP030A00F lux = 16*(6.650*(float)data_als0 – 9.653*(float)data_als1); else if(ratio>=0.9) lux = 0; else lux = 16*(1.805*(float)data_als0 – 1.977*(float)data_als1); } } } ------------------------------ End of Sample program for ALS mode ------------------------------ Sheet No.: OP13013EN Attachment-24 GP2AP030A00F 12.Recommended Window Size (Reference) 12.1. Without light shield Light Shielding area Window Light Shielding area Detector IR Emitter GP2AP030A00F h = n×r / (n - 1) =1.2mm n = 1.58 n : mold resin refractive index r = 0.45 r : radius Cg = (h+g)×tan30 Rt = (h+g)×tan30 g≦0.4mm(recommended)g : distance between sensor and panel t≦0.7mm(recommended)t : thickness of panel g+t≦1.1mm(recommended) Fig.17 Recommended window size (Without light shield) 1. Please print or tape up not to transmit infrared. 2. Please execute the Light Shielding between windows. 3. Even recommended window size may cause malfunction depending on the reflection from the panel. In this case, it is effective to be extended the printing area between windows, but affects detection distance and ALS output. 4.Please confirm that there is no problem with an actual machine in consideration of the implementation gap, the misalignment of the windows and voltage variation. 5. The recommended transmissivity (400nm≦λ≦1100nm) of the window is more than 85%. 6. In case that malfunction is not resolved under the window design described above, the light shield is recommended to set, which described below : 12.2.With light shield. Sheet No.: OP13013EN Attachment-25 GP2AP030A00F 12.2. With light shield Light Shielding area Window Detector IR Emitter Light Shielding area GP2AP030A00F h = n×r / (n - 1) =1.2mm n = 1.58 n : mold resin refractive index r = 0.45 r : radius Cg = (h+g)×tan30 Rt = (h+g)×tan30 g : thickness of light shield(recommended material : Silicon) t≦0.7mm(recommended)t : thickness of panel Fig.18 Recommended window size (With light shield) 1. The light shield is recommended to be set to decrease the reflected light from the window. 2. The light shield is recommended to be made by a black Silicon material that doesn’t transmit infrared. 3. Even recommended window size may cause malfunction depending on the reflection from the panel. In this case, it is effective to be extended the printing area between windows, but affects detection distance and ALS output. 4. Please confirm that there is no problem with an actual machine in consideration of the implementation gap, the misalignment of the windows and voltage variation. 5. The recommended transmissivity (400nm≦λ≦1100nm) of the window is more than 85%. Sheet No.: OP13013EN Attachment-26 GP2AP030A00F 13. Data (Reference) 13.1. LED drive peak current 13.1.1. LED drive peak current vs. VLED (Vcc=VLED) LED drive current vs. VLED(Vcc=3.0V) LED peak current[mA] 160 150 140 160 150 140 130 120 110 100 90 80 70 60 50 40 30 20 10 0 ILED=130mA(IS[1:0]=11) 130 120 110 100 <Recommended> 90 80 70 ILED=65mA(IS[1:0]=10) 60 50 40 30 ILED=32.5mA(IS[1:0]=01) 20 10 0 ILED=16.3mA(IS[1:0]=00) 2.2 2.4 2.6 2.8 3 3.2 3.4 3.6 3.8 4 4.2 4.4 4.6 4.8 5 5.2 5.4 VLED[V] Fig.19 LED drive peak current vs. VLED 13.1.2. LED drive peak current vs. Vcc (VLED=3V) LED peak current[mA] LED drive current vs. Vcc(VLED=3.0V) 160 150 140 130 120 110 100 90 80 70 60 50 40 30 20 10 0 ILED=130mA(IS[1:0]=11) <Recommended> ILED=65mA(IS[1:0]=10) ILED=32.5mA(IS[1:0]=01) ILED=16.3mA(IS[1:0]=00) 2.2 2.4 2.6 2.8 3 3.2 3.4 3.6 3.8 4 4.2 4.4 4.6 4.8 5 5.2 5.4 Vcc[V] Fig.20 LED drive peak current vs. Vcc Sheet No.: OP13013EN Attachment-27 1.5 GP2AP030A00F 13.2. Spectral Responsivity Fig.21 Spectral Responsivity 13.3. Proximity sensor (PS) mode Sensor output counts vs. distance Fig22 Sensor output counts vs. distance Sheet No.: OP13013EN Attachment-28