Hey, I use AFE4300 to measure BCM.
I test it with RC series, with 464Ohms and 105.6 nF
My value have different % of error, sometimes it's about 0.02% sometimes 1.xx% sometime 20.xx% in FWR mode
I haven't added the resistance of wires and breadboard, but, for example, 1 wire has 0.3 Ohms of resistance 6*0.3 = 1.8 Ohms the full resistance of wires + ~ 1 Ohms (for example) the resistance of breadboard
How to improve to get less then 2% of errors
And the second question, do I need to calibrate the system every time when I measure in the same session, or after reboot/reset. I mean, I powered my board and calibrated once, after that I gonna measure in single/continious mode BCM, do I need to calibrate again before measure?
My code is
uint16_t FWR_read(uint32_t input_mask, uint8_t freq, uint8_t delay) { set_frequency(freq, false); nrf_drv_gpiote_in_event_enable(DRDY_PIN, true); // enable pin IRQ write_register(VSENSE_MUX, input_mask); //Select VSENSE RN1-RP0 write_register(ISW_MUX, input_mask); //Select IOUT RN1-RP0 nrf_delay_ms(delay*1000); uint16_t result; while (true) { if (dflag == 1) // when IRQ pin is changed from high to low dflag becomes 1 { dflag = 0; result = read_register(ADC_DATA_RESULT);//*(1.7/32768.0); result = (result >= 32768) ? result - 65536 : result; break; } } return result; } void set_frequency(uint8_t freq, bool set_IQ_demod) { write_register(BCM_DAC_FREQ, freq); } afe4300_reset(); nrf_delay_ms(100); write_register(ADC_CONTROL_REGISTER1, 0x4130); //Differential measurement mode, 32 SPS write_register(MISC_REGISTER1, 0x0000); write_register(MISC_REGISTER2, 0xFFFF); write_register(DEVICE_CONTROL1, 0x0006); //Power up BCM signal chain write_register(ISW_MUX, 0x0408); write_register(VSENSE_MUX, 0x0408); write_register(IQ_MODE_ENABLE, 0x0000); write_register(WEIGHT_SCALE_CONTROL, 0x0000); write_register(BCM_DAC_FREQ, 0x0032); //0x0040 write_register(DEVICE_CONTROL2, 0x0000); write_register(ADC_CONTROL_REGISTER2, 0x0063); //ADC selects output of BCM-I output write_register(MISC_REGISTER3, 0x0030); r1 = FWR_read(0x0201, 50, 0.5); r2 = FWR_read(0x0202, 50, 0.5); double slope = (Ry - Rx) / (r2 - r1); double offset = Rx - (slope * r1); uint16_t z_code = FWR_read(0x0408, 50, 0.5); double Z = slope * z_code + offset; double Z_comp = sqrt(pow(RC_R, 2) + (1 / pow((2 * PI * (50 * 1000) * RC_C),2))); double err = 100 - Z * 100 / Z_comp;