## 2 Circuit Implementation
### The Continuous-Time Input Common-Mode Current-Feedback Loop
#### 2.1.1 Detailed Description and Operating Principle  
For clamping PLI, it is essential to detect the input CM voltage. The PLI has sinusoidal 50-60 Hz AC and harmonic components as the PLI is mostly non-sinusoidal. To detect the input CM voltage well within the effective frequency range, including PLI components, a resistive and capacitive voltage divider is implemented as the CM detector.  
The operating principle of the continuous-time CM input current-feedback loop is shown in Figure 4. The V\({}_{\text{CM}}\) enters the positive input of the two-window comparator. Subsequently, the V\({}_{\text{CM}}\) is compared with a reference value, BIAS_P, and BIAS_N, which is entered as negative input. Reference values can be also chosen as the external voltage within the transistor saturation range by the analog mux. The compared outputs, V\({}_{\text{GN-P}}\), are connected to the gate node of the negative-channel metal-oxide semiconductor (NMOS) (M1, M2) and the positive-channel metal-oxide semiconductor (PMOS) (M3, M4).  
Figure 4: Operating principle of the continuous-time CM input current-feedback loop.  
Figure 3: Block diagram of the proposed continuous-time common-mode (CM) input current-feedback loop.  
If V\({}_{\text{CM}}\) is over BIAS_P, the feedback sinking current from the NMOS flows into ECG input nodes, ECG_INP and ECG_INN, which leads to I\({}_{\text{F1-2}}\) limitation so that V\({}_{\text{CM}}\) is the same BIAS_P.  
Likewise, if V\({}_{\text{CM}}\) is under BIAS_N, the feedback sourcing current from PMOS limits I\({}_{\text{F3-4}}\) so that V\({}_{\text{CM}}\) is the same BIAS_N. In the case that V\({}_{\text{CM}}\) is in a range between BIAS_P and BIAS_N, each V\({}_{\text{GP, N}}\) is determined to ground and supply voltage, which means that all transistors are in the \"off\" state and cannot flow input feedback current.  
The I\({}_{\text{F1-4}}\) can be varied by the skin-electrode contact impedance, dry electrode impedance, and a measurement environment. If I\({}_{\text{F1-4}}\) are larger than the feedback current, V\({}_{\text{CM}}\) cannot be clamped by the proposed feedback loop and can be saturated to supply rails. To prevent the saturation by a large I\({}_{\text{F1-4}}\), the feedback currents of the proposed feedback loop are controlled by programmable R\({}_{\text{F}}\) between 11 K\(\Omega\) and 1.3 M\(\Omega\).  
Assuming the M1-4 is ideal and has the same transconductance, the transconductance of the output current feedback loop, GM\({}_{\text{F}}\), is expressed using the following equation:  
\[\text{GM}_{\text{F}}=\frac{\text{gm}_{\text{M1-4}}}{1+\text{R}_{\text{F}} \times\text{gm}_{\text{M1-4}}}. \tag{1}\]  
According to Equation (1), GM\({}_{\text{F}}\) can be changed using programmable R\({}_{\text{F}}\), which means that the feedback current can be adjusted by the R\({}_{\text{F}}\). For example, assuming gm\({}_{\text{M1-4}}\) is 50 \(\mu\)A/V, the GM\({}_{\text{F}}\) can change from 0.7 \(\mu\)A/V to 32.3 \(\mu\)A/V. If the maximum absolute value of I\({}_{\text{F1-4}}\) is 3 \(\mu\)A, the small signal of V\({}_{\text{SGP}}\) and V\({}_{\text{GNS}}\) is 0.5 V and the R\({}_{\text{F}}\) is 14.3 k\(\Omega\), and the maximum absolute feedback current is 3.07 \(\mu\)A, which can lead to limiting I\({}_{\text{F1-4}}\) accordingly.  
Good matching of the feedback current is important. If there is a large discrepancy in the feedback current, unwanted differential-mode (DM) components may occur and adversely affect the input signal. Therefore, a careful layout is demanded for the feedback current generator.  
Since all of this clamping process of the input CM voltage is part of the continuous-time domain operation, it is not necessary for the ECG amplifier to have a wide bandwidth of more than several kHz.  
An input buffer is utilized to isolate electrode impedance and the proposed circuit. The isolation between the electrode and the proposed circuit prevents the loading effect, which can cause signal distortion.