Yes I got the part that R6 adjusts the current and voltage (and vice versa). I'm curious about sensing the current with this : "Current detection could be done with a second LM301 using a lower threshold voltage (split R2 into two) but watch out for the input offset voltage; you might need to null it out." How is it different from sensing with R6? Are they different currents?
I don't think you do understand. I've redrawn the schematic with a few points labelled, so I can explain it again.
I've corrected an error that was present in the original schematic in the data sheet, and is present in your version. The op-amp inputs are reversed. The connection from downstream of R6 needs to connect to the non-inverting ("+") input of the op-amp.
I've also added a second op-amp and another resistor, R7. R2 in the original schematic was 15 ohms; it is now separated into R7 (3 ohms) and R2 (12 ohms).
Charging current flows from the LM338, through point A, through R6, through point B, and into the battery. This current flow causes a proportional voltage to be dropped across R6, according to Ohm's Law with R = 0.2 ohms. For example, 100 mA of current causes 20 mV to be dropped across R6. In other words, the voltage at point B is 20 mV lower than the voltage at point A.
The circuit consisting of R7, R2, R3 and R1 sets the maximum output voltage of the regulator. The regulator internally generates a reference voltage of 1.24V (nominal) and adjusts its output voltage so that the voltage between point A and point E is equal to that reference voltage. The current flow into the ADJ pin is quite small, so we can make an approximation and say that the currents through R7, R2, R3 and R1 are all the same.
The regulator ensures there is 1.24V across (R7+R2+R3). This means the current in those resistors is I = V / R = 1.24 / 245 = about 0.00506A, or 5.06 mA. The same current must flow through R1, and with the value I've used, 2500 ohms, this will produce a voltage drop of V = I R = 0.00506 * 2500 = 12.653V. This is the voltage at point E if the effect of U2 is ignored. The voltage at point A will be 1.24V higher, i.e. about 13.9V.
The current (5.06 mA) flowing through R7, R2 and R3 causes voltage drops across them that are proportional to their resistances (because V = I R). This means that the voltages at points C and D will be lower than the voltage at point A by fixed amounts. Point C is 15.2 mV lower than point A, and point D is 75.9 mV lower than point A.
As explained in the first paragraph, the voltage at point B is also lower than point A, by an amount that's proportional to the output (charging) current. The op-amps are used to compare the voltage at point B to the voltages at points C and D. So the voltage drops across R7 and across (R7+R2) are thresholds, to which the voltage drop across R6 is compared.
U2 is the current regulator stage. It acts to reduce the LM338's output voltage to limit the charge current. It does this by comparing the voltage across R6 (the shunt voltage) to the voltage across (R7+R2) (the reference voltage). When the shunt voltage is greater than the reference voltage, U2 pulls its output towards 0V, which pulls point E downwards and reduces the LM338's output voltage. The circuit reaches an equilibrium and the current is limited to the current calculated using Ohm's Law with V = 75.9 mV (the reference voltage) and R = 0.2 ohms (the shunt resistance), which is I = V / R = 0.0759 / 0.2 = 380 mA.
I've added U3. It compares the voltage across the shunt resistor to a different reference voltage: the voltage across R7, which is 15.2 mV. This translates to an output current of I = V / R = 0.0152 / 0.2 = 0.076 = 76 mA.
When the charger is actively charging the battery, and the charge current is somewhere between 76 mA and 380 mA, the voltage at point B will be lower than the voltage at point C, and U2's output will be low. As the battery reaches full charge and the regulator output voltage levels off at 13.9V, the voltage across R6 starts to drop as the charging current drops. When the charging current goes below 76 mA, U3's output goes high. This could be used (with a simple R-C delay to avoid false tripping, and/or a top-up charge delay) to control a flip-flop that cuts off the charge path when the charge current has levelled off.
The LM301A has a worst case input offset voltage of 7.5 mV at 25 degrees Celsius, and 10 mV over the full temperature range. This is a significant proportion of the voltage differences being detected - for U2, detecting 76 mV, it's 13%, and for U3, detecting 15.2 mA, it's as much as 66%. Therefore you should null the offset voltage using the circuit shown in the LM301A data sheet.
One more thing: The application is for an emergency alarm that will work even when there is no power i.e. it will only run maybe once in a blue moon and it should not fail to run when there is no mains. What considerations should I make with this given circumstance?
I don't know. When you choose your battery, look on the manufacturer's web site for application notes on float charging and standby applications to see what they recommend.
And am I right to assume that when there is no current drawn by a load there is no power consumed? Because I think linear regulators are not satisfactory even in standby
Regulators (linear and switching) will draw some current all the time, even if the output current is zero.
BTW your design still has two problems that I mentioned on the other thread, in relation to Q1, your P-channel MOSFET that's in series with the load. It won't switch OFF when the input supply disappears, because the voltage from the battery will back-feed to the input through D2. You need a separate diode between the input of the circuit and the input of the regulator to prevent this. Also you should add gate protection to Q1 - a series resistor (e.g. 3k3) and a zener diode from gate to source (cathode to source, for a P-channel MOSFET). Thirdly, there's no path from the input supply to the load when the charger is charging, because Q1 will be OFF. I suggest you use a separate regulator for this, with two Schottky diodes (or a double diode in a single package) to diode-OR the battery and the regulator output together.