As defined before, the each segment will have it’s own battery pack using NiMH cells. In order to define the best option for charging them, I will investigate the application note from ATMEL to see if this concept can be used.

When reading thought the application note I wrote down some items:

- NiMH batteries are charged with a constant current of 1*C
- To determine if the battery is full, dV/dt is used with temperature and absolute voltage as backup
- Trickle charging is done using a current of 0.025*C for maximum 90 minutes
- Charging is allowed between 5 and 40 dC
- Maximum voltage is 1.5V per cell
- Charging is stopped if dV/dt is 0 and/or dT/dt is 0

In any case the charger can not exceed 1A so that approx 15 segments can charge in parallel. This would already mean a power supply that can deliver 16A at roughly 10V so 160W. A current source is easy to build using a PNP transistor or even a LM317, however they both have a problem in dissipating the over voltage, specially when the battery is empty. In that case the regulator must dissipate 10-(5*1.1)=4.5V*1A=4.5W which will require some kind of heat sink.

A better option is to use some kind of PWM based current source, to prevent power being dissipated (and so wasted). This is indeed what the application note uses also in a very elementary form, it basically increases the voltage over the battery while measuring the current. If the current is too high, the PWM frequency is lowered so that a storage capacitor is charged less and in return the voltage is reduced.

This would mean a loop in software that continuously measure the current and adjusts the PWM. Since the current will not vary rapidly this does not have to be done extremely fast and non-interruptible. There are two micro controllers discussed in the application note which both use the same principle but with a different PWM frequency. The lower the frequency, this higher the storage capacity must be and the higher the switching coil must be. I tend to use so higher frequency, but this needs further investigation.

For measuring the current a series resistor is used 0.25E and the voltage drop over the resistors is measured. It might be an option to use this as well for measuring the discharge current, for this it will be needed to measure positive (charge goes in) and negative (charge goes out) voltages. This could be done using an amplifier that amplifies the voltage drop with an offset but perhaps a smarter one is to measure the voltage just before the resistor and directly after the resistor just before the battery and in software subtract the two measured voltages. This has the benefit that the exact voltage of the battery is known as well allowing a second option for cutting of the charger or the consumer in case the battery is almost empty.

Some calculations:

- The AT90CAN has a 10-bit ADC, using the internal 2.56V reference this gives a resolution of 2.5mV per bit
- Using a 0.25E resistor and a voltage drop of 2.5mV this means a resultion of 10mA

With the resolution of 10mA per bit this means a current range of 0..10.24A, this is an overkill by a factor of at least 4. The 10mA will also not be 10mA due to noise and tolerances, typically the first bit should be ignored giving an resolution of 20mA. If the factor of 4 somehow can be used this can be decreased to 5mA which is a very nice resolution. Question is how to multiple the drop by a factor of 4?

One option is to increase the resistor to 1.0E. At the maximum discharge current of (estimated) 2.5A this will result in a voltage drop of 2.5V which is not nice… The other option is to use the amplifier again, in that case we still need to measure two voltages; one is the drop of the resistor and one is the actual battery voltage to see if it is almost empty.

I have to admit that analogue design is not my strongest point so designing this amplifier + offset circuit will go with some trial and error although the basics of OPAMPs are known to me. The most simple model I always use is that an OPAMP tries to match the voltage on the + input and on the – input. If they don’t match it will increase the output voltage if the + voltage is higher than the – voltage and reduce the output voltage if the – voltage is higher than the + voltage.

We need an difference amplifier as indicated on page 3 of the basics, in theory this is nothing else than an non-inverting amplifier with the difference that the ground to which Vout is increased is no longer the fixed ground but now a variable ground. Problem still is that Vout can only follow the positive voltage drops. Assume V1=V2=0V, than Vout is 0V. Assume V2=1V, than Vout is increase until the voltage on the – input is the same voltage as on the + input. Assume V2=-1V, than Vout should decrease the voltage but that is not possible with only a positive voltage supply. So the trick here is to generate a Vout of (2.56/2)=1.28V when V1=V2. Since Vout is increased this means that the voltage on the + input must be 1.28V in this case, so in short, we must add 1.28V to V2 or substract 1.28V from V1.

Assume R1=R2=R3=R4=100E, than when V1=V2=5V the output voltage should be 1.28V. As a result, V- is (((5-1.28)/(100+100))*100)+1.28=3.14V. That means that V+ is 3.14V as well (remember the amplifier tries to make them the same). The current through R3 is than (5-3.14)/100=0.0186A and the voltage drop over R4 must than be 100*0.0186=1.86V requiring the ground not to be 0V but 3.14-1.86=1.28V. That is funny, the 1.28V “virtual ground” matches exactly the offset of 1.28V…..

The amplification factor is given by R2/R1 if R1=R3 and R2=R4. Using a 0.1E resistor with a current of 2.5A results in a voltage drop of 0.25V. If we use 1.1V as the voltage to measure at 2.5A this means a multiplication factor of 1.1/0.25=4.4 times. The impedance “seen” by the 0.1E resistor should be very high to prevent influence of the voltage drop by the measurement circuit. Something in the range of 200 to 400k should be OK (gut feeling). When the resolution must be 10mA by not using the least significant bit this would mean a maximum measured current of (1024/2/2)=256*10mA=2.560A (+ and -). Using a resistor of 0.1E will cause a voltage drop of 0.256V at the maximum current. This should translate into 1.28V offset to “the virtual ground” at the output of the amplifier so a multiplication factor of 1.28/0.256=5.00 times.

Although above schematic looks simple there are some problems to solve:

- The 1.28V voltage supply should be able to sink current instead of supplying it
- The 1.28V voltage should be 50% of the internal 2.56V reference in the AT90CAN

An amplifier can source and sink current, so that can be used for the 1.28V power supply. The 50% can be created by using that same amplifier wired as the image below.

Since R3=R4 the V+ is 1.28V, the output is shorted to the V- and the rule dictates that the amplifier increases the output voltage until V- is V+ hence the 1.28V output. The 2.56V is available inside the AT90CAN but not outside so this can not be used. Instead an external reference diode needs to be used for generating this voltage in which case it can also be applied to the AT90CAN so that we are sure we the offset is always 50% of Vref.

One thing to keeo in mind is that most amplifiers can not generate an output voltage above Vdd-1.5V, some of them can (rail-to-rail amplifiers) but most of them don’t. They can also not work with voltages on V+ and V- that are above Vdd-1.5V, so if the 0.1E resistor was to be connected to the plus of the battery which produces 5*1.2=6.0V and the amplifier is running at 5V you can not work with the voltage drop over the 0.1E resistor since one side is 6.0V and the other side a little bit less; both more than 5-1.5=3.5V. Instead the 0.1E resistor should be connected to the minus of the battery which results in a “virtual” negative ground. This will become clear later.