This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler/OPT9221: Writing Common Offset Calibration parameters

Part Number: OPT9221

Tool/software: TI C/C++ Compiler

Hello, TI!

I performed common offset calibration in our-self board base on our demo-board OPT8221.\

I have got these parameters: phase_corr_1 = -118, phase_corr_2 = 820.

I have question:

Do I write rightly to register negative value by I2C inteface (code fragment is below):

    #define REG_5C 0x5C
    #define REG_58 0x58
    #define REG_READ 192
    #define REG_WRITE 193
 //// some code
  
    unsigned char pocket_send[8];
    unsigned char pocket_recv[6];
    unsigned int len, gotLength;

    pocket_send[0] = REG_5C;
    pocket_send[1] = REG_WRITE;
    pocket_send[2] = 8;
    pocket_send[3] = 0;
    pocket_send[4] = 0x37;
    pocket_send[5] = 0;
    pocket_send[6] = 0;
    pocket_send[7] = 0;
    
    short temp;
    //temp = (phase_corr0<<4)&0xFFF0;
    temp = (phase_corr0 * 16)&0xFFF0;
    memcpy((char*)pocket_send + 5, &temp, 2);

    sendto(server_sock_cmd, pocket_send, sizeof (pocket_send), 0, (struct sockaddr *)&tof_adr_command, sizeof (tof_adr_command));
    len = recvfrom(server_sock_cmd, pocket_recv, sizeof (pocket_recv), 0, (struct sockaddr *)&tof_adr_command, &gotLength);

    short temp_recv;
    memcpy(&temp_recv, (char*)pocket_recv + 3, 2);
    phase_corr0 = (temp_recv / 16);
    if(temp == temp_recv){

        printf("Common Offset Calibration: phase_corr0 = %hi was successfully written to register\n", phase_corr0);
    }

here, I get -118 (for phase_corr_1), but I am not sure that register makes right interpretation of negative values.

2. What is the principal difference between phase_corr_x and hdr_phase_corr_x values and where/when first or second are used?

  • Semenov, 

    Yes, the registers phase_corr_1 and phase_corr_2 take negative values. They have to be written in the signed 2's compliment notation. 

    hdr_phase_corr_x is used when HDR is turned on. See sections 7.3.3.5.1 for description of HDR and section 7.3.8.1 on the difference between phase_corr and hdr_phase_corr from the OPT9221 datasheet. 

    Suramya

  • Suramya, Thank you for your answer!

    So, if for example phase_corr_1 is written as -964 and I read 0x00C3C0 from register 0x5C 0x37 opt9221 through I2C such value, is it means OK?


    If hdr_frm_intg_scale = 0, is it mean I can do not worry about hdr_phase_corr_x parameters? (and opposite, If hdr_frm_intg_scale != 0,
    I can do not worry about phase_corr_x parameters)

    The range 0.5 ~6 m and target speed ~5-6 km per hour is hdr or normal mode?
    Where is border between them?
  • Semenov,

    Yes, 0xC3C is correct for -964 (just for the 12 bits of phase_corr_1, I haven't verified the full register value).

    Yes, if hdr_sale is 0, you need not worry about hdr_phase_corr parameters. However, since hdr_scale is applied to alternate frames, you do need to program both phase_corr and hdr_phase_corr, when hdr_scale > 0.

    HDR is applied to get signal dynamic range. This would depend on the reflectivity of the target and the system parameters. If the signal is saturating at nearby distances (0.5 m in your case), you should consider using HDR mode. This would be application-specific, and we cannot comment on the mode which should be used.

    Since these are alternate frames, the stitching of the final image has to be done in software, based on the saturation flag. See section 7.3.7.5 from the OPT9221 datasheet for more info on flags.

    Suramya
  • Suramya, Thank you for your answer!