<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Abhineet's Tech Journal]]></title><description><![CDATA[Abhineet's Tech Journal]]></description><link>https://abhineetstechjournal.hashnode.dev</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1593680282896/kNC7E8IR4.png</url><title>Abhineet&apos;s Tech Journal</title><link>https://abhineetstechjournal.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Thu, 24 Sep 2026 08:24:38 GMT</lastBuildDate><atom:link href="https://abhineetstechjournal.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[State-Space Modeling of an RC Charging Circuit for Sensor Data Sampling in IoT/ML Pipelines]]></title><description><![CDATA[Authors: Abhineet Jaiswal, Harsh Sonawane & Aryan KanhirathingalSardar Patel Institute of Technology (SPIT), Mumbai, India
1. Introduction
An ML model is often judged purely on its architecture or tra]]></description><link>https://abhineetstechjournal.hashnode.dev/rc-circuit-state-space-iot</link><guid isPermaLink="true">https://abhineetstechjournal.hashnode.dev/rc-circuit-state-space-iot</guid><category><![CDATA[state space]]></category><category><![CDATA[contro-systems]]></category><category><![CDATA[Matlab]]></category><category><![CDATA[iot]]></category><category><![CDATA[Machine Learning]]></category><dc:creator><![CDATA[Abhineet Jaiswal]]></dc:creator><pubDate>Fri, 18 Sep 2026 22:13:01 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6aada2051c255009002544ac/ac3c128d-c4f6-4acb-89cd-f16316ce0ca3.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>Authors:</strong> Abhineet Jaiswal, Harsh Sonawane &amp; Aryan Kanhirathingal<br /><em>Sardar Patel Institute of Technology (SPIT), Mumbai, India</em></p>
<h1><strong>1. Introduction</strong></h1>
<p>An ML model is often judged purely on its architecture or training data, but its accuracy is capped just as much by the physical signal path delivering that data in the first place. In many sensor front-ends, an <strong>RC (resistor-capacitor) circuit</strong> is present, either by deliberate design, as a smoothing or anti-aliasing filter to remove noise before digitization, or incidentally, due to the parasitic capacitance of the sensor and wiring. Where such a circuit exists, it does not respond to changes instantaneously. It takes a measurable amount of time to settle to the steady-state value of the input signal.</p>
<p>This settling behavior can be captured precisely using <strong>state-space modeling</strong>, a control-systems framework describing how a system's internal state evolves over time. This article derives the state-space model of an RC charging circuit, simulates its response in <strong>MATLAB</strong>, and shows how this behavior affects both <strong>IoT sampling design and ML data quality</strong>.</p>
<h1>2. Detailed Explanation</h1>
<h2>2.1 The Circuit</h2>
<p>Consider a simple series RC circuit: a resistor <strong>R</strong> and capacitor <strong>C</strong> connected in series, driven by an input voltage source <strong>Vin(t)</strong>. The quantity of interest is the voltage across the capacitor, <strong>Vc(t)</strong>, which is the signal typically sampled by an analog-to-digital converter (ADC).</p>
<img src="https://cdn.hashnode.com/uploads/covers/6aada2051c255009002544ac/900ec3a7-ffe5-4bb8-9757-af06adbc325b.png" alt="" style="display:block;margin:0 auto" />

<h2>2.2 Deriving the State Equation</h2>
<p>Applying <strong>Kirchhoff's Voltage Law</strong> around the loop:</p>
<p>$$V_{in}(t) = i(t)R + V_C(t)$$</p>
<p>The current through the capacitor relates to the rate of change of the voltage across it:</p>
<p>$$i(t) = C\frac{dV_C(t)}{dt}$$</p>
<p>Substituting this into the KVL equation:</p>
<p>$$V_{in}(t) = RC\frac{dV_C(t)}{dt} + V_C(t)$$</p>
<p>Rearranging into the standard <strong>state equation</strong> form, with state variable x = V_C$:</p>
<p>$$\frac{dV_C(t)}{dt} = -\frac{1}{RC}x + \frac{1}{RC}V_{in}(t)$$</p>
<p>This single-state system can be written in the general <strong>state-space vector form</strong>:</p>
<p>$$\dot{x} = Ax + Bu$$</p>
<p>$$y = C_{out}x + Du$$</p>
<p>with the matrices:</p>
<p>$$A = -\frac{1}{RC}$$</p>
<p>$$B = \frac{1}{RC}$$</p>
<p>$$C_{out} = 1,\qquad D = 0$$</p>
<p>Here, <strong>C(out)</strong> denotes the output matrix, not to be confused with the physical capacitance <strong>C</strong> used in the circuit equations above.</p>
<h2>2.3 The Time Constant</h2>
<p>The product <strong>τ = RC</strong> is called the <strong>time constant</strong> of the circuit. At <strong>t=τ</strong> , the capacitor voltage has risen to roughly <strong>63%</strong> of its final steady-state value. By <strong>approx 5τ</strong> , it has climbed close enough (over <strong>99%</strong>) that the circuit is treated as settled for practical purposes, though for an ideal first-order system it never reaches that value exactly, only approaches it <em>asymptotically</em>.</p>
<p>This single parameter, <strong>τ</strong> , determines how long one must wait before a reading from this circuit approximately reflects the steady-state input signal.</p>
<h2>2.4 Transfer Function and State-Space Interpretation</h2>
<p>The same RC circuit can also be described in the frequency domain using its <strong>transfer function</strong>. Taking the Laplace transform of the governing equation</p>
<p>$$V_{in}(t) = RC\frac{dV_C(t)}{dt} + V_C(t)$$</p>
<p>with zero initial conditions gives:</p>
<p>$$V_{in}(s) = RCsV_C(s) + V_C(s)$$</p>
<p>Solving for the ratio <strong>Vc(s)/Vin(s</strong>):</p>
<p>$$\frac{V_C(s)}{V_{in}(s)} = \frac{1}{RCs+1}$$</p>
<p>This is the transfer function of the RC circuit, a single <strong>first-order pole</strong> at</p>
<p>$$s = -\frac{1}{RC}$$</p>
<p>consistent with the time constant <strong>τ = RC</strong> identified earlier.</p>
<p>Starting from this transfer function, the state-space model can be recovered directly using the standard procedure for converting a transfer function to state equations. For a general first-order transfer function of the form:</p>
<p>$$H(s) = \frac{b_0}{s+a_0}$$</p>
<p>the corresponding state-space representation (<strong>controllable canonical form</strong>) is:</p>
<p>$$\dot{x} = -a_0x+b_0u$$</p>
<p>$$y=x$$</p>
<p>Matching coefficients with <strong>Vc(s)/V(s) = (1/RC)/(s+1/RC)</strong> gives <strong>a0 = 1/RC</strong> and <strong>b0 = 1/RC</strong>, reproducing exactly the same <strong>A, B, C(out), and D</strong> matrices derived in Section 2.2 from the circuit equations directly.</p>
<p>This confirms that the time-domain (<strong>state equation</strong>) and frequency-domain (<strong>transfer function</strong>) descriptions of the RC circuit are two equivalent representations of the same system, one obtained directly from the physical circuit, the other by converting a transfer function into state-space form.</p>
<h1>3. MATLAB Simulation and Practical Application</h1>
<h2>3.1 Simulation Setup</h2>
<p>To numerically verify the state-space and transfer-function models derived in Section 2, consider:</p>
<p>$$R = 10,k\Omega,\qquad C = 100,\mu F$$</p>
<p>giving:</p>
<p>$$\tau = RC = 1,s$$</p>
<p>A step input</p>
<p>$$V_{in}(t) = 5u(t),V$$</p>
<p>is applied, where <strong>u(t)</strong> is the unit step function. The response follows the state equation from Section 2.2:</p>
<p>$$\dot{x} = -\frac{1}{RC}x + \frac{1}{RC}u,\qquad x=V_C$$</p>
<h2>3.2 MATLAB Implementation</h2>
<p>The response is simulated two ways, via the state-space matrices and via the transfer function, to confirm both representations agree.</p>
<pre><code class="language-plaintext">% RC circuit parameters
R = 10e3; C = 100e-6; tau = R*C;

% State-space model
sys_ss = ss(-1/(R*C), 1/(R*C), 1, 0);

% Transfer function model
sys_tf = tf([1/(R*C)], [1, 1/(R*C)]);

% Simulate step response (5V input)
Vin_amp = 5;
t = linspace(0, 5*tau, 500);
[y_ss, t_ss] = step(Vin_amp*sys_ss, t);
[y_tf, t_tf] = step(Vin_amp*sys_tf, t);

% Plot comparison
figure;
plot(t_ss, y_ss, 'b-', 'LineWidth', 2); hold on;
plot(t_tf, y_tf, 'r--', 'LineWidth', 1.5);
yline(Vin_amp, 'k:', 'V_{in} = 5V');
yline(0.632*Vin_amp, 'g--', '63.2% (1\tau)');
yline(0.993*Vin_amp, 'm--', '99.3% (5\tau)', ...
    'LabelHorizontalAlignment', 'left', ...
    'LabelVerticalAlignment', 'bottom');
xline(tau, 'g:', '1\tau');
xline(3*tau, 'c:', '3\tau');
xline(5*tau, 'm:', '5\tau');
ylim([0, Vin_amp*1.15]);
xlim([0, 5.2*tau]);
xlabel('Time (s)');
ylabel('Capacitor Voltage V_C (V)');
title('RC Circuit Step Response: State-Space vs Transfer Function');
legend('State-space model', 'Transfer function model', ...
    'Location', 'southeast');
grid on;
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6aada2051c255009002544ac/fd617751-8ed0-470e-9fbb-e486aee4fd41.png" alt="" style="display:block;margin:0 auto" />

<p><em>Figure 2: Step response of the RC circuit (<strong>*<em>R = 10k</em>Ω*, C = 100,<em>µ</em>F</strong></em><em>) to a 5 V input, computed using both the state-space and transfer-function models. The two responses overlap, confirming the equivalence of the two representations. The</em> 1τ, 3τ, and 5τ <em>time points, along with the 63.2% and 99.3% response levels, are indicated.</em></p>
<p><strong>Expected result:</strong> The two curves overlap to numerical precision, confirming that the state-space and transfer-function representations describe the same system. For the 5 V step, <strong>Vc</strong> reaches approximately 3.16 V (63.2%) at <strong>t=<strong>τ</strong>=1s</strong> and approximately 4.965 V (99.3%) at <strong>t=5τ=5s</strong>, consistent with Section 2.3.</p>
<h2>3.3 Practical Interpretation</h2>
<p>This illustrates a consideration relevant when an RC stage sits in a sensor's signal path:</p>
<p><strong>Sensor → RC filter → ADC → sampled data → ML pipeline</strong></p>
<p>If a sudden change occurs and the system expects each sample to reflect a fully settled value, sampling before sufficient settling produces a partially-settled reading, a predictable, systematic lag rather than random noise. A model trained on such data may pick up this RC-induced temporal response alongside the actual sensor behavior. If the RC characteristics differ between training and deployment hardware, this mismatch can affect how well the model generalizes.</p>
<p>This isn't a general argument against fast sampling, though. An RC stage is often used deliberately as a low-pass or anti-aliasing filter for continuously varying signals, where sampling well above the circuit's bandwidth is appropriate. The key question is whether the application needs a settled post-change value or is sampling an intentionally filtered, continuous signal. The circuit's time constant is what lets that distinction be made explicitly during sensor-interface design.</p>
<h1>4. Conclusion</h1>
<p>This article derived the state-space model of a simple RC charging circuit, starting from its governing circuit equation and relating it to its transfer function. For the chosen realization, both representations produced consistent state-space equations, demonstrating how the time-domain state-space description corresponds to the Laplace-domain transfer-function representation of the same system. A MATLAB simulation confirmed this equivalence numerically, with the state-space and transfer-function step responses overlapping to numerical precision, and showed how the time constant <strong>τ = RC</strong> governs the rate at which the circuit approaches its steady-state value, reaching approximately 63.2% at <strong>1τ</strong> and 99.3% at <strong>5τ</strong>.</p>
<p>Beyond the mathematics, this first-order model has a practical implication for sensor systems: when an RC stage lies in a sensor's signal path, its time constant determines how quickly the output responds to changes in the input and how long it takes to approach a settled value, a consideration particularly relevant in data-acquisition and machine-learning pipelines where the temporal behavior of sensor signals must be understood. The example therefore shows how a foundational state-space modeling technique connects circuit-level analysis with practical considerations in modern sensing and data systems.</p>
<hr />
<h1>5. References</h1>
<ol>
<li><p>A. Nagoor Kani, Control Systems Engineering, RBA Publications, Chapters on State-Space Analysis and State Equations from Transfer Function.</p>
</li>
<li><p>MathWorks, <a href="https://www.mathworks.com/help/control/ug/state-space-models.html">State-Space Models - MATLAB &amp; Simulink</a></p>
</li>
<li><p>C. K. Alexander and M. N. O. Sadiku, Fundamentals of Electric Circuits, 5th ed., McGraw-Hill, Chapter 7: First-Order Circuits (RC/RL transient response and time constant).</p>
</li>
<li><p>National Instruments, <a href="https://www.ni.com/en/shop/data-acquisition/measurement-fundamentals/analog-fundamentals/is-your-data-inaccurate-because-of-instrumentation-amplifier-set.html">Is Your Data Inaccurate Because of Instrumentation Amplifier Settling Time?</a></p>
</li>
</ol>
]]></content:encoded></item></channel></rss>