Hi,
I'm trying to implement de-alias. As recommanded in https://e2e.ti.com/support/sensors-group/sensors/f/sensors-forum/891035/faq-opt3101-dealias-operation, I use the 8.57 MHz frequency.
At the OPT initialization, I initialize the registers like this:
typedef struct { uint8_t registerAddress; uint16_t eepromAddress; uint32_t value; } initValues_s; const initValues_s registerToEeprom[NB_OF_INIT_REGISTERS] = { /* EN_TEMP_CONV = enabled */ {EN_TEMP_CONV, 0x03, 0xA0000}, /* OVERRIDE_CLKGEN_REG = 0, CLIP_MODE_OFFSET = wrap around, CLIP_MODE_TEMP = wrap around, CLIP_MODE_NL = wrap around, CLIP_MODE_FC = clip */ {CLIP_MODE_FC, 0x07, 0x200101}, /* XTALK_FILT_TIME_CONST = 4 (tau = 16), IQ_READ_DATA_SEL = raw I/Q, USE_XTALK_REG_ILLUM = calibration value, USE_XTALK_FILT_ILLUM = filter, USE_XTALK_REG_INT = register value, USE_XTALK_FILT_INT = filter, INT_XTALK_CALIB = 0, DIS_AUTO_SCALE = enabled, FORCE_SCALE_VAL = 0 (digital scale = 64) */ {FORCE_SCALE_VAL, 0x0B, 0x4002E0}, /* IAMB_MAX_SEL = 11 (= 50 uA) */ {IAMB_MAX_SEL, 0x0F, 0xB0}, /* GPIO2_IBUF_EN = enabled, GPIO2_OBUF_EN = enabled, GPIO1_OBUF_EN = enabled, GPO2_MUX_SEL = DVSS, GPO1_MUX_SEL = DIG_GPO_0, GPO3_MUX_SEL = DVSS */ {GPIO_REGISTER, 0x2F, 0x19080}, /* PDN_GLOBAL = active, DIS_GLB_PD_I2CHOST = enabled, DIS_GLB_PD_OSC = disabled, DIS_GLB_PD_AMB_ADC = disabled, DIS_GLB_PD_AMB_DAC = disabled, DIS_GLB_PD_AFE_DAC = enabled, DIS_GLB_PD_AFE = enabled, DIS_GLB_PD_ILLUM_DRV = enabled, DIS_GLB_PD_TEMP_SENS = enabled, DIS_GLB_PD_REFSYS = disabled */ {GLOBAL_POWER, 0x37, 0x161}, /* NUM_AVG_SUB_FRAMES = 63, NUM_SUB_FRAMES = 63 */ {NUM_AVG_SUB_FRAMES, 0x3F, 0x3F03F}, /* TG_SEQ_INT_START = 9850 */ {TG_SEQ_INT_START, 0x43, 0x267A}, /* TG_SEQ_INT_END = 9858 */ {TG_SEQ_INT_END, 0xB3, 0x2682}, /* TG_SEQ_INT_MASK_END = 63 */ {TG_SEQ_INT_MASK, 0x47, 0x03F03F}, /* ILLUM_SCALE_H_TX0 = 1.4 mA, ILLUM_SCALE_L_TX0 = 1.4 mA, HDR_THR_HIGH = 65535 */ {ILLUM_SCALE_H_TX0, 0x4B, 0x1BFFFF}, /* HDR_THR_LOW = 0 */ {HDR_THR_LOW, 0x4F, 0x0}, /* ILLUM_DAC_H_TX0 = 15, ILLUM_DAC_L_TX0 = 13 */ {ILLUM_DAC_H_TX0, 0x53, 0x1ED}, /* MUX_SEL_COMPIN = PHASE_OUT is used for comparator input register */ {MUX_SEL_COMPIN, 0x5B, 0x3}, /* EN_FREQ_CORR = enabled, EN_FLOOP = enabled, EN_AUTO_FREQ_COUNT = measured value, SYS_CLK_DIVIDER = 10, START_FREQ_CALIB = 1, REF_COUNT_LIMIT = 19531 */ {EN_FREQ_CORR, 0x63, 0xF54C4B}, /* EN_CONT_FCALIB = frequency continuously measured */ {EN_CONT_FCALIB, 0x67, 0x8000}, /* PHASE_OFFSET_HDR1_TX0 = 7497 */ {PHASE_OFFSET_HDR1_TX0, 0x105, 0x1D49}, /* SCALE_PHASE_TEMP_COEFF = 2, EN_TEMP_CORR = disabled, EN_PHASE_CORR = enabled */ {EN_TEMP_CORR, 0x93, 0x81}, /* MONOSHOT_FZ_CLKCNT = 9900, MONOSHOT_NUMFRAME = 6, MONOSHOT_MODE = continuous mode */ {MONOSHOT_MODE, 0x9B, 0x26AC18}, /* SEL_HDR_MODE = ILLUM_DAC_H, EN_ADAPTIVE_HDR = disabled, TX_SEQ_REG = 0-0-0-0-0-0, SEL_TX_CH = TX0, EN_TX_SWITCH = disabled */ {EN_ADAPTIVE_HDR, 0x9F, 0xF90000}, /* TG_ILLUMEN_START = 0*7/6 */ {TG_ILLUMEN_START, 0xB7, 0x0}, /* TG_ILLUMEN_END = 8500*7/6 */ {TG_ILLUMEN_END, 0xBB, 0x26BC}, /* TG_CAPTURE_START = 9300*7/6 */ {TG_CAPTURE_START, 0xBF, 0x2A62}, /* TG_CAPTURE_END = 9800*7/6 */ {TG_CAPTURE_END, 0xC3, 0x2CA9}, /* TG_CALC_START = 8500*7/6 */ {TG_CALC_START, 0xC7, 0x26BC}, /* TG_CALC_END = 9999*7/6 */ {TG_CALC_END, 0xCB, 0x2D91}, /* CAPTURE_CLK_CNT = 8600*7/6 */ {CAPTURE_CLK_CNT, 0xCF, 0x2731}, /* SUB_VD_CLK_CNT = 9999*7/6, TG_EN = disabled */ {TG_EN, 0x97, 0x5B22}, };
Then, at the end of the initialization, I activate the sequencer like this:
/* Sequencer commands */ I2cOptSendValue(SEQUENCER_COMMAND_0_1, 0x122100); I2cOptSendValue(SEQUENCER_COMMAND_2_3, 0x400); /* Second modulation frequency settings */ I2cOptSendValue(NCR_CONFIG, 0x400001); I2cOptSendValue(AMB_PHASE_CORR_PWL, 0x0); /* Sequencer enable */ I2cOptSendValue(TG_EN, 0x5B22); I2cOptSendValue(DIS_INTERRUPT, 0x30000); I2cOptSendValue(TG_EN, 0x5B23);
1) I obtain two phases that alternate (I displayed them on the sensor's screen), which I presume is normal because we have two frequencies. Is that right?
2) The calibration cannot be done correctly. The crosstalk is too high (around 120-130) and the phase, which is supposed to be around 1749 at a distance of 400 mm at modulation frequency of 10 MHz, is way too high too (8xxx). But sometimes, it is an acceptable value (around 18xx). Why do I obtain these results?
3) During the crosstalk calibration, I display the crosstalk scale, iPhase, qPhase for both frequencies + alpha1 & beta1 (we only use them as we don't perform internal crosstalk calibration). Sometimes, all of them are null, and sometimes they aren't. Why? Moreover, in the de-alias documentation it's written that alpha & beta are comprised between -32 and 31, but I sometimes obtain a value of 48... How is that possible?
4) When I have an acceptable calibration (that is to say, crosstalk to 0 (though I think it is suspect) & phase offset in 18xx), The distance with the equations (3) and (4) of the de-alias document is way too high: more than ten meters instead of 400 mm. But when I replace the equation (3) with the following one, I get something more interesting: 1150 mm instead of 400 mm.
uint64_t Opt3101CalculateDealiasedPhase(uint8_t dealiasBin, uint16_t freq, uint8_t overflow, uint16_t phase) { // return 4uLL*(uint64_t)((uint16_t)dealiasBin*freq) + ((uint64_t)overflow << 16) + (uint64_t)phase; return (uint64_t)(dealiasBin * (1 << 16)) + (uint64_t)phase; }
How is that possible? Is the equation (3) wrong?
Thanks in advance for your answers.