Capacitor balancing circuit

Hello there,

I am trying to implementing the circuit below:

Ignoring P2 and P3 we are left with P1 and P4. P1 will mean the charge pin and the P4 is the balance pin.
The table of state of P1 and P4 is shown below:

the idea is that during the charging cycle, Csen gets charged to 5v and then during the sharing cycle Csen will share its charge with Cint. then After a certain amount of charge and discharging cycles Cint will eventually reach 5v aswell. My goal is to measure how many cycle it takes. I have also attached the paper that outlined this method.

the code i used for Arduino is the following

int count = 0;
int val = 0;
void setup() {

Serial.begin(9600); // put your setup code here, to run once:
}

void loop() {
  pinMode(6, INPUT);
  delayMicroseconds(1);
  pinMode(5, OUTPUT);
  digitalWrite(5, HIGH);
  delayMicroseconds(500);
  digitalWrite(5, LOW);
  pinMode(5, INPUT);
  delayMicroseconds(1);
  pinMode(6, OUTPUT);
  digitalWrite(6, LOW);
  delayMicroseconds(500);

}

Pin 5 is used as the charging pin (P1 in the picture) and pin 6 is used as the balancing pin (P4 in the picture).

However Cint simply refuses to charge to 5v. It will charge to 0.124 and then stop. And using an oscilloscope to look at P1 shows a non-changing square-wave which should not be the case. Can someone point me at the right direction to debug this circuit? I am really lost. Thanks.

01014a.pdf (789 KB)

Without reading the app note:

  1. The C_INT will never reach 5V - they are comparing it with some fixed voltage reference.

  2. You have a bug in your code: when you try to set pin 5 to INPUT you write it LOW first. That discharges the C_SEN.

  3. If you are continuously measuring C_INT using a DMM it slowly drains the capacitor. The voltage the DMM shows will be function of C_SEN capacitance and the switching frequency (and your DMM resistance). Effectively the DMM "makes a voltage divider with the switching cap" (probably there is some better terminology for this).

You have misread the paper.

the idea is that during the charging cycle, Csen gets charged to 5v and then during the sharing cycle Csen will share its charge with Cint. then After a certain amount of charge and discharging cycles Cint will eventually reach

a threshold voltage.

Clearly it can not ever reach the supply voltage