Microcontrollers, PLC and Industrial Automation — formula sheet
Mechatronics Engineering · GATE ME · SI units. Drafted with Aria, checked by the AiCanCode.org team.
Microcontroller Architecture and Timing
T_clk = 1 / f— Clock period (s); f = clock frequency (Hz).T_mc = 12 / f_osc— Machine-cycle time (s) of the classic 8051; f_osc = crystal frequency (Hz). 1 µs at 12 MHz.t_exec = N × CPI / f— Execution time (s); N = instructions executed, CPI = average cycles per instruction.MIPS = f / (CPI × 10⁶)— Millions of instructions per second.RELOAD = f × T_tick − 1— Cortex-M SysTick reload (counts) for tick period T_tick (s); must not exceed 2²⁴ − 1.
Embedded C: GPIO and Bit Manipulation
x | (1 << n)— Sets bit n (bits numbered from 0 at the LSB).x & ~(1 << n)— Clears bit n.x ^ (1 << n)— Toggles bit n.(x >> n) & 1— Reads bit n.(x & ~(m << p)) | ((v & m) << p)— Writes value v into a k-bit field at position p; m = 2ᵏ − 1.R = (V_CC − V_F) / I_F— LED series resistor (Ω); V_F = LED forward voltage (V), I_F = LED current (A).
Timers, Counters and Interrupts
T_tick = N_pre / f_clk— Timer tick (s); N_pre = prescaler, f_clk = timer clock (Hz).T_max = 2ⁿ × T_tick— Longest interval of an n-bit timer (s).Preload = 2ⁿ − T_d / T_tick— Overflow-mode preload for a delay T_d (s).OCR = f_clk / (N_pre × f_int) − 1— Compare value for an interrupt frequency f_int (Hz) in clear-on-compare (CTC) mode.f_sig = 1 / (Δ × T_tick)— Frequency (Hz) from input capture; Δ = (C₂ − C₁) mod 2ⁿ counts between edges.
Serial Communication: UART, SPI and I2C
T_bit = 1 / baud— UART bit time (s); baud in bit/s.t_char = (1 + n_data + n_parity + n_stop) / baud— Time per UART character (s); 10 bit times for 8N1.baud = f_osc / (16 × (UBRR + 1))— AVR USART baud rate in normal mode; UBRR = baud-rate register value, f_osc = CPU clock (Hz).baud = f_osc / (384 × (256 − TH1))— Classic 8051 baud rate with Timer 1 in mode 2 and SMOD = 0.t_SPI = 8 × n_bytes / f_SCLK— SPI transfer time (s).t_I2C ≈ 9 × n_bytes / f_SCL— I2C transfer time (s); 8 data bits + ACK per byte, address bytes included.
ADC Interfacing and Sensor Reading
LSB = V_ref / 2ⁿ— ADC step size (V); n = resolution in bits, V_ref = reference voltage (V).D = int(V_in × 2ⁿ / V_ref)— Output code (datasheet convention); many textbooks use (V_in / V_ref) × (2ⁿ − 1), which differs by under 1 LSB.V_in ≈ D × V_ref / 2ⁿ— Input voltage (V) from a code D.f_s > 2 f_max— Nyquist sampling condition; f_s = sampling rate, f_max = highest signal frequency (Hz).SNR = 6.02 n + 1.76— Ideal signal-to-quantisation-noise ratio (dB) of an n-bit ADC.x = x_min + (I − 4) / 16 × (x_max − x_min)— Engineering value from a 4–20 mA signal I (mA).
PWM Generation and Motor Interfacing
D = t_on / T— Duty cycle; t_on = high time (s), T = period (s).V_avg = D × V_s— Average output voltage (V); V_s = supply voltage (V).f_PWM = f_clk / (N × (TOP + 1))— Edge-aligned PWM frequency (Hz); N = prescaler, TOP = period register.ω = (V_avg − I_a R_a) / K_e— DC motor speed (rad/s); I_a = armature current (A), R_a = armature resistance (Ω), K_e = back-EMF constant (V·s/rad).N_rpm = 60 × f_step / steps_per_rev— Stepper speed (rpm); f_step = step rate (steps/s), steps_per_rev = 360° / step angle.
Interfacing Displays, Keypads and Relays
Keys = r × c, Pins = r + c— Matrix keypad with r rows and c columns.t_digit = 1 / (N × f_refresh)— On-time per digit (s) of an N-digit multiplexed display refreshed at f_refresh (Hz).I_B = k × I_C / β_min— Base current (A) to saturate a relay-driver transistor; k = overdrive factor (2–5), I_C = coil current (A).R_B = (V_OH − V_BE) / I_B— Base resistor (Ω); V_OH = MCU high-level voltage (V), V_BE ≈ 0.7 V.
Real-Time Operating System Basics
U = Σ C_i / T_i— CPU utilisation; C_i = worst-case execution time (s), T_i = period (s) of task i.U ≤ n (2^(1/n) − 1)— Rate-monotonic schedulability bound for n tasks (sufficient only); 0.828 for 2 tasks, 0.780 for 3, → 0.693.R_i = C_i + Σ_(j ∈ hp(i)) ⌈R_i / T_j⌉ × C_j— Response time (s) of task i under fixed priorities; schedulable if R_i ≤ deadline.
PLC Architecture, I/O Modules and Scan Cycle
t_scan = t_in + t_prog + t_out + t_hk— Scan time (s): input scan, program execution, output scan, housekeeping.t_resp,max ≈ t_filter + 2 × t_scan + t_out,dev— Worst-case input-to-output response (s); t_filter = input filter, t_out,dev = output device delay.t_pulse,min > t_scan + t_filter— Minimum input pulse width (s) reliably seen by normal scanning.
Ladder Logic: Contacts, Coils, Timers and Counters
Motor = (Start + Motor) · Stop_OK · OL_OK— Seal-in (latching) rung; series contacts = AND, parallel = OR.t_set = PV × t_base— Timer delay (s); PV = preset (counts), t_base = time base (s).ET → PT, then Q = 1— TON output turns on when elapsed time ET reaches preset PT with the input continuously on; remaining time = PT − ET.Q_CTU = 1 when CV ≥ PV— Up-counter output; CV = current count, PV = preset.
Sequential Control and Function Block Programming
T_cycle = Σ t_step— Cycle time (s) of a sequence.Throughput = 3600 / T_cycle— Cycles per hour (T_cycle in s).t_fill = A × Δh / Q— Time to change tank level by Δh (m); A = cross-section (m²), Q = flow (m³/s).SR: Q = S + R̄ · Q; RS: Q = R̄ · (S + Q)— Set-dominant and reset-dominant bistables.
PLC Applications: Conveyor, Bottling and Traffic Control
t = d / v— Transit time (s) over distance d (m) at belt speed v (m/s).n_counts = d × PPR / (π D)— Encoder counts for belt travel d (m); PPR = pulses per revolution, D = roller diameter (m).T_cycle = max(t_station) + t_index— Cycle time (s) of an indexing line.C = Σ (G_i + A_i + R_i)— Traffic-signal cycle length (s): green, amber and all-red times.
SCADA and HMI
t_poll = Σ (t_req + t_resp + t_turn)— Polling cycle (s) over all remote stations.Storage = N_tags × bytes per sample × samples per second × t— Historian storage (bytes) before compression.Clear when x < SP − DB— High-alarm reset with deadband DB below set-point SP.
Industrial Networks: Modbus, Profibus, EtherCAT
t_char = n_bits / baud— Serial character time (s); n_bits = 11 for standard Modbus RTU characters.Request = 8 bytes; Response = 5 + 2N bytes— Modbus RTU frames when reading N registers.t_gap = 3.5 × t_char— Minimum Modbus RTU inter-frame silence (s).η = useful bytes / total bytes— Protocol efficiency; effective data rate = η × byte rate.t_cycle ≈ 8 × n_frame / 100 Mbit/s + N_slaves × t_fwd— EtherCAT cycle estimate (s); n_frame in bytes, t_fwd = per-slave forwarding delay.
Industrial IoT and Industry 4.0
OEE = A × P × Q— Overall equipment effectiveness, with A, P, Q as fractions (multiply by 100 for %).A = run time / planned production time; P = ideal cycle time × total count / run time; Q = good count / total count— OEE factors.R = N × n_bytes × 8 × f_s— Raw data rate (bit/s) of N sensors sampled at f_s (Hz).I_avg = D × I_active + (1 − D) × I_sleep— Average current (A) of a duty-cycled node; battery life = capacity / I_avg.