Next Article in Journal
A Source-to-Source Compiler to Enable Hybrid Scheduling for High-Level Synthesis
Previous Article in Journal
Hyperspectral Imaging System Applications in Healthcare
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Generator of Aperiodic Pseudorandom Pulse Trains with Variable Parameters Based on Arduino

by
Nebojša Andrijević
1,*,
Zoran Lovreković
2,
Marina Milovanović
3,
Dragana Božilović Đokić
4 and
Vladimir Tomašević
5
1
Faculty of Economics and Engineering Management, University Business Academy in Novi Sad, Cvećarska 2, 21102 Novi Sad, Serbia
2
Faculty of Technical Sciences, Department of Energy, Electronics and Telecommunications, University of Novi Sad, Dr Zorana Đinđića 1, 21000 Novi Sad, Serbia
3
Faculty of Informatics and Computing, Singidunum University, Danijelova 32, 11010 Belgrade, Serbia
4
Faculty of Computer Sciences, PIM University, 78012 Banja Luka, Bosnia and Herzegovina
5
School of Engineering Management, Bulevar Vojvode Mišića 43, 11000 Belgrade, Serbia
*
Author to whom correspondence should be addressed.
Electronics 2025, 14(23), 4577; https://doi.org/10.3390/electronics14234577
Submission received: 27 October 2025 / Revised: 16 November 2025 / Accepted: 20 November 2025 / Published: 22 November 2025

Abstract

Aperiodic pseudo-random impulse (APPI) trains represent deterministic yet reproducible sequences that mimic the irregularity of natural processes. They allow complete control over inter-spike intervals (ISIs) and pulse widths (PWs). Such signals are increasingly relevant for low-probability-of-intercept (LPI) communications, radar testing, and biomedical applications, where controlled variability mitigates adaptation and enhances stimulation efficiency. This paper presents a modular APPI generator implemented on an Arduino Mega platform, featuring programmable statistical models for ISI (exponential distribution) and PW (uniform distribution), dual-timing mechanisms (baseline loop and Timer/ISR, clear-timer on compare (CTC)), a real-time telemetry and software interface, and a safe output chain with opto-isolation and current limitation. The generator provides both reproducibility and tunable stochastic dynamics. Experimental validation includes jitter analysis, Kolmogorov–Smirnov tests, Q–Q plots, spectral and autocorrelation analysis, and load integration using a constant-current source with compliance margins. The results demonstrate that the Timer/ISR (CTC) implementation achieves significantly reduced jitter compared to the baseline loop, while maintaining the statistical fidelity of ISI and PW distributions, broad spectral characteristics, and fast decorrelation. Experimental verification was extended across a wider parameter space (λ = 0.1–100 Hz, PW = 10 µs–100 ms, 10 repetitions per condition), confirming robustness and repeatability. Experimental validation confirmed accurate Poisson/Uniform ISI generation, sub-millisecond jitter stability in the timer-controlled mode, robustness across λ = 0.1–100 Hz and PW = 10 µs–100 ms, and preliminary compliance with isolation and leakage limits. The accompanying Python GUI provides real-time control, telemetry, and data-logging capabilities. This work establishes a reproducible, low-cost, and open-source framework for APPI generation, with direct applicability in laboratory and field environments.

1. Introduction

Aperiodic pseudo-random impulse (APPI) trains are deterministically generated sequences of binary events that statistically emulate the irregularity of natural processes, while providing full control over inter-spike intervals (ISIs and pulse widths (PWs). Such signals are increasingly applied in communication and radar systems with low probability of intercept (LPI), and in testing of electronic subsystems with realistic excitations, as well as in biomedical scenarios (e.g., neurostimulation), where controlled variability can reduce tissue adaptation and prolong the efficiency of stimulation protocols.
The aim of this work is to present a modular APPI generator that integrates:
  • programmable statistical models for ISI (exponential distribution) and PW (uniform distribution within a defined range);
  • reproducibility of sequences;
  • real-time telemetry and software supervision, and
  • a safe output chain with opto-isolation and current limitation, suitable for laboratory and field use.

1.1. Problem, Novelty, and Contributions

Classical excitation generators are typically either strictly periodic (predictable) or stochastic (non-reproducible). There is a need for a generator that combines deterministic reproducibility with controlled stochastic dynamics, while allowing measurement and analysis of timing determinism.
The presented modular APPI generator introduces the following contributions:
  • Modular APPI generator with programmable ISI (Exp(λ)) and PW (Uniform[PW_min, PW_max]), ensuring full sequence reproducibility;
  • Two timing mechanisms: baseline loop and Timer/Interrupt Service Routine (ISR), where Timer/ISR (CTC) enables significant jitter reduction;
  • Software interface (PC) for runtime parameterization and telemetry acquisition (event timestamps, pulse widths, planned intervals);
  • A safe output chain with optical isolation and a constant-current source, optimized for load integration.
The main contributions of this work are summarized in the following Table 1.

1.2. System Architecture Overview

The proposed system comprises three interconnected layers:
  • Microcontroller layer—event and pulse generation;
  • Software layer—parameterization and logging;
  • Output layer—opto-isolation and driver/constant-current source (CCS).
Event generation is based on a Poisson process with intensity λ , while pulse width is randomly sampled from a uniform distribution within [PW_min, PW_max]. Parameters can be dynamically modified during operation, and each emitted pulse is documented by telemetry (timestamp, width, and planned interval).
The system outputs textual event logs, enabling experiment evaluation and reproducibility. For example, the record is as follows:
EV, 2981 ms, 203 µs, and 1691 ms represent, in order, the elapsed time since start, the pulse width, and the planned interval to the next event.
The signal model includes the following:
  • Event schedule: ISI ∼ Exp(λ);
  • Pulse width: PW ∼ Uniform[PW_min, PW_max];
  • Telemetry: timestamps, widths, and planned pulse intervals.

1.3. Reference Dataset and Visualizations

For transparent validation, a 60 s reference dataset was generated with parameters λ = 2   Hz and PW     50 ,   1000   μ s . The dataset parameters are shown in Table 2, while Figure 1, Figure 2 and Figure 3 illustrate the basic statistics and serve as a starting point for subsequent analyses. See Figure 1 for a visual overview of the first 10 s of the reference dataset.
Figure 1 shows the temporal positions of pulses in the first 10 s of the reference dataset. It serves as a visual “anchor” for the reader before statistical analysis. Figure 2 demonstrates that the empirical ISI follows an exponential distribution; deviations in the tails are expected due to the finite sample size.
Figure 3 shows that pulse widths are approximately uniformly distributed within the specified range, confirming correct PW sampling.
The complete set of additional figures, tables, and scripts is provided in the Supplementary Materials (link to the GitHub repository is given in the Supplementary Materials section).

1.4. Organization of the Manuscript

Section 2 summarizes the theoretical basis and classification of approaches in APPI generation. Section 3 describes the implementation of hardware and software components, including jitter measurement for both the baseline and Timer/ISR (CTC) variants. Section 4 presents the experimental and statistical verification (K–S tests, Q–Q plots, periodogram, autocorrelation function (ACF)). Section 5 addresses load integration, safety, and EMC aspects, while the final discussion and conclusions jointly consider the results and outline future research directions.

2. Related Work and Theoretical Background

In recent years, substantial progress has been made in the study of aperiodic and complex stimulation patterns, both in biomedical applications and in advanced signal processing and communications. Below, we provide an overview of the relevant literature and define the models on which our work is based.

2.1. Foundations of Aperiodic Pseudo-Random Pulse Generation

2.1.1. Neurostimulation and Complex Patterns

Recent studies show that nonlinear and stochastic patterns (incl. Coordinated Reset, CR) and Poisson-like sequences can reduce pathological oscillations and mitigate adaptation in neural systems. Variable intervals between pulses lead to predictable yet correctable changes in neuronal firing [1], while clinical and translational studies indicate that deep brain stimulation (DBS) can “rectify” noisy components and improve motor performance [2]. The theory and variants of CR stimulation with different connectivity patterns are analyzed in detail in [3], whereas early theoretical foundations of desynchronization and spatiotemporally complex schemes can be found in [4,5].

2.1.2. Algorithms and Statistical Modeling

Deterministic sequences based on linear feedback shift registers (LFSR) remain a standard due to simple hardware realization and speed [6,7]. In parallel, interest is growing in chaotic maps and their multidimensional variants because of high entropy and sensitivity to initial conditions [8,9,10,11]. From a statistical perspective, adaptation often introduces correlations among ISI values [12], while estimation of a time-varying intensity λ t of Poisson processes has a direct application in calibrating APPI generators [13]. As a general theoretical foothold, we use standard sources on Poisson processes and probability theory [14,15].

2.1.3. Applications in Sensing and Radar Systems

In the domain of low probability of intercept (LPI) radar, aperiodic or noise-like sequences contribute to resistance against interception and jamming. Surveys and more concrete waveform designs with randomized PRF/PRI and phase coding are covered in [16,17,18].

2.1.4. Safety and Regulatory Aspects

In medical applications, requirements for basic safety and EMC arise from IEC 60601-1 and 60601-1-2 [19,20], as well as from regulatory guidelines for EMC evaluations [21]. Technical timing and interrupt limits for the platform we use (ATmega2560, Microchip Technology Inc., Chandler, AZ, USA) were taken from the official documentation [22].

2.2. Definitions and Notation

We consider aperiodic pseudo-random impulse trains (APPI) as deterministically generated, reproducible sequences without a fundamental period.
The sequence is as follows:
S = { t i , w i } i = 1 N ,     t i + 1 > t i ,     w i > 0 ,
where t i is the time of the i-th event, and w i is the width of that pulse.
We define ISI values as Δ t i =   t i   t i 1 . In this work, we deliberately model the following:
Δ t i E x p λ ,     w i U n i f o r m w m i n ,   w m a x ,
with the possibility of adjusting λ ,   w m i n ,     w m a x in real time.
The exponential distribution for inter-spike intervals (ISI) is chosen because it arises directly from the Poisson event model. A homogeneous Poisson process generates independent events with memoryless inter-arrival times, i.e., ISI ∼ Exp(λ). This assumption is a standard abstraction for random, memoryless spike trains in neurophysiology and for event-driven stochastic systems in engineering. It therefore provides both biological plausibility and a well-established theoretical basis for the ISI model used in this work.

2.3. Modeling and Design Criteria

For practical use, we require the following:
  • reproducibility (seed/parameters);
  • controlled stochastic structure (choice of ISI and PW distributions);
  • robust timing (low jitter);
  • straightforward hardware integration (opto-isolation, current limiting);
  • broadband spectral properties without dominant lines.
These criteria motivate a Poisson event mechanism and a separate width module, with the possibility of hybridization with deterministic and chaotic components. A taxonomy of approaches is given in Figure 4.

2.4. M-Sequence with Jitter

M-sequences (maximum-length sequences) are a special class of sequences generated by LFSRs that achieve the maximum period 2 n   1 for a given register length n, and possess pseudo-random properties [6].
By introducing jitter (random shifts in pulse time instants), periodicity is broken and the sequence acquires an aperiodic character.
Jitter can be as follows:
  • Uniform (e.g., a shift within the interval ±ΔT);
  • Gaussian (shifts with a normal distribution);
  • Exponential (shifts based on Poisson statistics).
Mathematically, the occurrence time of the i-th pulse becomes:
Ti = Ti + δi,
where δi is a random variable with a specified distribution.

2.5. Deterministic Structural Approaches (LFSR/m-Sequences)

LFSRs generate long, deterministic sequences with minimal HW complexity and high speed [6,7]. Limitations include spectral lines and correlations if the output is directly mapped to temporal events; therefore, in practice, an LFSR is used as a binary mask or an auxiliary source (whitening) in combination with an independent timing mechanism. A schematic 16-bit LFSR is given in Figure 5.

2.6. Poisson Event Mechanism (Exponential ISI)

A Poisson process with intensity λ provides independent events with Δ t i Exp λ [14,15]. This “event timer” is simple, reproducible, and naturally pairs with an independent width module (e.g., uniform over w m i n ,   w m a x ). Hierarchical control is then clear: λ shapes the arrival rhythm, while w m i n ,   w m a x shape occupancy/energy. A skeleton of the pseudo-code is given in Pseudo-code 1.
Pseudo-code 1. Poisson event timer with uniform widths:
parameters: λ, w_min, w_max
loop:
 u ← Uniform(0,1]
 Δt ← −ln(u)/λ
 wait(Δt)
 w ← Uniform[w_min, w_max]
 emit_impulse(w)

Operational Interpretations of Poisson Events for APPI

In implementation, events can be interpreted in three standard ways, with different trade-offs in occupancy, control, and entropy. An overview is given in Table 3, and in the text, we refer to models A–C when describing protocols in later sections.
A detailed “feature-by-feature” comparison matrix of approaches (deterministic, stochastic, chaotic, hybrids) is provided in the Supplementary Table (Table S5).

2.7. Chaotic Maps and Randomization

Simple chaotic maps (logistic, tent, multi-map variants) yield deterministic sequences with high entropy and sensitivity to initial conditions [8,9,10,11]. By quantizing states, we obtain a binary stream or a continuous perturbation (e.g., width jitter), thereby “whitening” the spectrum and reducing predictability. Parameter selection requires care to avoid periodic regimes.

2.8. Hybrid Architectures

Hybrid schemes combine a Poisson process as the event scheduler, an LFSR as a mask/auxiliary PRNG, and a chaotic map for fine randomization (e.g., PW jitter). Such an architecture enables “spectral programming”—targeted shaping of the spectrum and statistics while preserving reproducibility. The signal and telemetry flow is shown in Figure 6.

2.9. Statistical and Spectral Properties

It is desirable for APPI to exhibit the following:
  • stable ISI and PW distributions consistent with the setup;
  • low autocorrelation for τ > 0 (fast decorrelation);
  • broadband spectral distribution without strong lines.
The Poisson + Uniform realization naturally yields “even” spectral energy, while hybrids allow additional fine tuning (e.g., targeted masking or suppression of unwanted components).

2.10. Comparative Analysis of Approaches

Table 4 qualitatively compares deterministic, stochastic, chaotic, and hybrid approaches across multiple criteria: entropy, periodicity, spectral properties, hardware complexity, controllability, and reproducibility. In practice, the Poisson mechanism provides the simplest entry point into timing, LFSR excels when simplicity and speed are key [6,7], chaos helps with randomization [8,9,10,11], and hybrids offer the best compromise for specific requirements.

2.11. Related Platforms and Positioning of This Work

In recent years, substantial progress has been made in the study of aperiodic and complex stimulation patterns, both in biomedical applications and in advanced signal processing and communication technologies.
The comparison emphasizes the following:
  • the platform (MCU/FPGA);
  • output mode and isolation;
  • the possibility of aperiodic/pseudo-random protocols (native or “arbitrary”); and
  • the level of compliance voltage/current.
Below, we summarize open instruments and academic/commercial-open projects focused on pulse generation for neurophysiology and related domains:
  • Pulse Pal (v2, Arduino Due (Arduino SRL, Somerville, MA, USA), 4× voltage outputs (Sanworks LLC, Rochester, NY, USA)). An open, programmable voltage-pulse generator with high temporal precision, v2 uses Arduino Due/ATSAM3X8E, a 12-bit bipolar DAC, and a ±10 V range, with microSD parameter storage and separate analog/digital grounds for lower noise. There is no native Poisson mode, but software-defined sequences are available, so Poisson ISI is easily realized via firmware/PC API [23].
  • StimJim (dual-channel, current/voltage mode, galvanic isolation (Open Ephys, Lisbon, Portugal)). An open stimulator with two galvanically isolated outputs that generate arbitrary waveforms in current or voltage mode, practical for extracellular stimulation and electrode activation, with output current/voltage measurement. Aperiodic trains are trivial via arbitrary patterns, although Poisson is not “native”.
  • Portable, programmable, multichannel HV stimulator (research prototype, no commercial manufacture, 2023). High compliance and multichannel capability with real-time adjustment of parameters (PW/frequency) for peripheral neurons, the work is research-oriented with a clear focus on high-voltage architecture and portability. Poisson is not native, but the arbitrary framework is suitable for such protocols.
  • Arduino-based microcurrent stimulator (research prototype, no commercial manufacture, 2023). A low-intensity microcurrent stimulator based on the Arduino platform and modest electronics, the study reports stable timing and current regulation in DC/pulsed mode. Aperiodic sequences are achievable in software (not “native”).
  • NeuroStimDuino (shield, 2 channels per board, stacking up to 222, ±60 V compliance (Neuralaxy/Crowd Supply, Portland, OR, USA)). An open Arduino shield for education/research with two independent current channels per board, biphasic, charge-balanced pulses, and opto-isolation of digital/analog domains. Specifications include max. compliance ±60 V, current range ±20 mA, and I2C configuration; Poisson protocols are realized from the controller/firmware.
A detailed “feature-by-feature” description is provided in Table 5a (platform, channels, mode, isolation, whether a native Poisson mode exists, notes, sources). This work is positioned as an MCU-based generator with an explicit Poisson/Uniform model, reproducibility, and full telemetry; the output chain with opto-isolation and CCS aligns with practices from [23,24,25,26,27].
In addition to the qualitative overview, Table 5 has been expanded with quantitative metrics—specifically jitter index and average power consumption—to enable direct comparison with open-source stimulators. Pulse Pal v2 exhibits sub-percent timing jitter at microsecond resolution with ±10 V DAC outputs. StimJim and NeuroStimDuino provide either dual-mode stimulation or high-compliance current levels, but neither supports native Poisson/Uniform timing control.
The proposed APPI generator achieves statistically verified stochastic timing (Poisson/Uniform) with stable millisecond-range jitter (σ ≈ 0.3 ms), as detailed in Section 3.6. Combined with opto-isolated constant-current output and integrated telemetry, these features position the system as a flexible open-source platform suited for controlled stochastic stimulation.
Viewed through the criteria from Section 2.2 and Section 2.5:
  • Poisson/Uniform ISI/PW in our work is explicitly modeled and verified (K–S/Q–Q/ACF/PSD);
  • The safety chain (opto + CCS + compliance) that we define in Section 5 and apply in 6.1 around neuro-stimulation is directly complementary to the StimJim/NeuroStimDuino approach (isolation and current drive);
  • High compliance and multichannel capability [25] are relevant to our operating envelope (Figure 23) and the plan for future hardware extensions.

2.12. Implementation Implications

For a microcontroller realization, the key aspects are as follows:
  • precise event scheduling (timer/ISR);
  • determinism/replicability (seed, parameters);
  • safe output (opto + current limiting) with minimal EMC artifacts.
This design enables immediate evaluation of statistics (K–S, Q–Q), as well as spectral and correlation analysis—as shown in the following sections (see Section 3, Section 4, Section 5 and Section 6), with due consideration of standards and guidelines [19,20,21,22].

3. Design and Implementation

3.1. System Architecture

The proposed system uses the Arduino Mega 2560 as the core for generating APPI signals with control of key parameters:
  • inter-pulse intervals (ISI) modeled by an exponential distribution;
  • pulse widths (PW) modeled by a uniform distribution within a defined range.
This model provides the following:
  • statistical flexibility (tunable distribution parameters);
  • simple hardware realization;
  • integration with a PC GUI via a serial link for real-time telemetry and supervision, as shown in Figure 7a.

3.1.1. Baseline Generator Implementation

In the baseline version, the Arduino code implements:
  • Generation of inter-pulse intervals using the exponential distribution:
    Δ t = ln U λ ,     U 0 , 1 ,
    where U is a uniformly distributed random value in (0, 1], and λ is the parameter that sets the average pulse rate;
  • Generation of pulse width using a uniform distribution over the range:
    W W m i n ,   W m a x ,
  • The digital output (e.g., D8) generates a pulse of duration w .
  • randomSeed is set, as needed, from a fixed seed (reproducibility) or from physical noise (e.g., analogRead(A0)) for low predictability.
The skeleton of the main loop is given in Pseudo-code 2.
Pseudo-code 2. Firmware baseline loop skeleton:
  
setup():
 if USE_FIXED_SEED: randomSeed(SEED)
 else: randomSeed(analogRead(A0))
loop():
 u = Uniform(0,1]
 dt = −log(u)/lambda
 delayMicroseconds(dt_µs)
 w = Uniform[w_min, w_max]
 digitalWrite(D8, HIGH)
 delayMicroseconds(w)
 digitalWrite(D8, LOW)
 log_event(timestamp_ms(), w, next_dt_planned)
  
Note: On 16 MHz Arduino boards, the delayMicroseconds() function implements software-based timing and is accurate only up to a certain range. For long delays (on the order of milliseconds), instruction overhead, timer quantization, and interference from interrupt service routines (ISRs) introduce additional uncertainty. This accumulated error contributes to the observed jitter in the baseline loop implementation and motivates the use of the Timer/ISR (CTC) variant for more deterministic timing.

3.1.2. Extended Version with Serial Communication

The extended version enables bidirectional communication: the PC sends commands, and the device returns log messages (timestamp, width, planned interval). This is particularly useful for correlation with EMG/EEG recordings. The minimal protocol is in Pseudo-code 4, given below.

3.1.3. Integration with the Python GUI Interface

A Tkinter GUI in Python was developed that enables the following:
  • Connecting to the Arduino (Arduino IDE, v2.2.1) via the serial port;
  • Entry of parameters λ ,   W m i n , W m a x
  • Display of real-time pulse logs with timestamps;
  • Display of basic statistics: number of pulses generated, average width, current frequency (computed over a window of the last 5 s).
The Python-based GUI provides an interactive interface for configuring stimulation parameters (λ, PW, mode), monitoring real-time telemetry, and exporting datasets for analysis. The application includes live ISI plotting, system-status indicators, error-handling messages, and session logging. Figure 7b shows a representative GUI screenshot illustrating parameter control and real-time visualization.
This integration provides the possibility of remote and intuitive control of the generator, which is particularly important in biomedical experiments where the user can quickly adapt stimulation to patient or experimental model responses (see Figure 7 for data flows).

3.1.4. Advantages over Classical Generators

Compared to standard periodic pulse generators, this architecture offers the following:
  • Parameter variability without the need to change hardware components;
  • Full control and monitoring via a software interface;
  • Simple algorithm adaptation for different distributions (e.g., normal, Weibull, Gamma) to model specific biological or technical conditions;
  • Possibility of mobile use (the system can operate completely stand-alone or with a portable computer).

3.1.5. Notes on Hardware Precision

The Arduino Mega has a 16 MHz quartz oscillator, which enables relatively high precision of microsecond pulse generation, but the following should be considered:
  • For ultra-precise applications (e.g., below 1 μs jitter), it is recommended to use hardware timers (CTC) instead of delay() functions, i.e., blocking delays;
  • In neurostimulation, output opto-isolation is recommended (e.g., using 4N25, 6N137 (Broadcom Inc., San Jose, CA, USA (alternative: 4N25—Vishay Intertechnology, Malvern, PA, USA))) for patient electrical safety;
  • For driving electrodes, a medical stimulator or TENS unit is required to convert the TTL signal into a controlled voltage and current per medical standards.
In biomedicine, opto-isolation and a current-limited output are mandatory, details are given in Section 3.7 and illustrated in Figure 12.

3.2. Hardware Realization of the Device

The technical setup of the developed system is based on a modular architecture that allows easy adaptation to different applications—from laboratory experiments and neurophysiological research to field testing of digital and communication devices. A summary of key components is given in Table 6, a typical power budget in Table 7, and pin mapping in Table 8.

Functional Description of Operation

The system consists of three layers:
  • a microcontroller layer that generates event schedules and pulses;
  • a software (PC) layer for parameterization and telemetry collection;
  • an output layer with optical isolation and current limiting (CCS) to the load.
Functional flow:
  • Pulse generation: the MCU samples Δ t and w , schedules the event, and generates a TTL pulse (see Pseudo-code 2);
  • Electrical isolation: the signal passes through the optocoupler for galvanic isolation (medical safety);
  • Output adaptation: TTL is converted to a defined voltage/current (TENS/CCS or a dedicated driver);
  • Application: electrodes (bio) or standard connectors (BNC) for technical loads. The isolation driver chain is shown in Figure 8.

3.3. Event and Pulse Generation (Model and Realization)

Arrival-time randomization is achieved by the Poisson mechanism: the time interval between events Δ t is sampled from the exponential distribution Exp (λ). The pulse width w is sampled from a uniform distribution w m i n ,   w m a x . During operation, the parameters λ ,   w m i n ,   w m a x are variable and are updated by commands from the computer.
This ensures the following:
  • the prescribed statistical profile of the APPI train;
  • reproducibility (deterministic PRNG/seed);
  • adaptability during the experiment.

3.4. Firmware: Baseline Loop and Timer/ISR (CTC)

Two timing mechanisms were implemented, and their difference in jitter is shown in Figure 9, Figure 10, Figure 11 and Figure 12 and summarized in Table 9.
For both timing variants, all non-essential interrupt service routines (e.g., Timer0 used for millis() and serial RX interrupts) were disabled, while compiler options, clock configuration, and load conditions were kept identical. This ensures that timing differences arise solely from the baseline loop versus Timer/ISR (CTC) scheduling mechanisms.
  • Baseline loop—simple, blocking, higher jitter due to background activities;
  • Timer/ISR (CTC)—a hardware timer generates a “tick”, the ISR only “triggers,” while the next event and PW are computed in the main loop (short ISR, more deterministic timing). The skeleton is in Pseudo-code 3.
Pseudo-code 3. Firmware skeleton—Timer/ISR (CTC) variant.
setup():
 config_timer_CTC(rate = TICK_US)
 enable_interrupts()
ISR(TIMER_CTC):
 if now_us() >= next_fire_us:
 arm_pulse_us = next_pw_us
 start_pulse(arm_pulse_us)
 isr_flag_fired = true
loop():
 if isr_flag_fired:
  isr_flag_fired = false
   //schedule next event
   u = Uniform(0,1]
   dt = −log(u)/lambda
   next_fire_us = now_us() + dt_us
   next_pw_us = Uniform[w_min, w_max]
   log_event(timestamp_ms(), next_pw_us, dt)

3.5. Serial Protocol and PC Tool (Telemetry and Control)

Commands are textual; the device acknowledges settings and emits log messages for each event. The basic set is as follows:
SET,lambda,<float>
SET,pwmin,<int>
SET,pwmax,<int>
Examples are in Pseudo-code 4, while complete formats (SCH/EV messages), the Python script, and CSV outputs are provided in the Supplementary Software (scripts).
Pseudo-code 4. Examples of commands and log messages (ASCII)
> SET,lambda,2.0
< OK,lambda,2.0
> SET,pwmin,50
< OK,pwmin,50
> SET,pwmax,1000
< OK,pwmax,1000
< EV, t_ms=2981, w_us=203, next_dt_ms=1691

3.6. Methodology of Timing Measurement and Results

Two log sets (the same planned sequence, different timing mechanisms) were analyzed step by step:
  • generation of planned instants;
  • measurement of j i t t e r = t a c t u a l t s c h e d u l e ;
  • metrics: μ ,   σ , p95/p99, maximum, fraction j i t t e r > 5   ms .
Jitter histograms for the baseline loop and Timer/ISR (CTC) are given in Figure 9 and Figure 10, and planned vs. actual (first 120 events) in Figure 11 and Figure 12. Summary metrics are in Table 9.
All timing measurements were performed using a Siglent SDS1202X-E digital oscilloscope (200 MHz bandwidth, 1 GSa/s sampling rate) with calibrated 10× passive probes. The trigger was set to rising-edge mode at a 1.5 V threshold. Probe self-calibration and baseline zeroing were executed before each measurement series. Each dataset consisted of at least 400 consecutive events. The same oscilloscope configuration and cabling were used for both timing modes (baseline loop and Timer/ISR (CTC)) to ensure that any observed differences in jitter originate solely from the firmware timing mechanisms.
Measurement conditions: 16 MHz oscillator (Arduino Mega), log raster 1 ms for periodogram/ACF, sample size ≥ 400 events per scenario, jitter evaluation: μ ,   σ ,   p 95 ,   p 99 , maximum, and fraction of exceedances |jitter| > 5 ms. For robustness of the estimate, bootstrap with 10,000 resamples over the jitter sequences provides confidence intervals for p95/p99 (shown in the Supplementary Table (Table S9)).

3.7. Safety and Load Integration

The output chain (see Figure 8) provides galvanic isolation and current limiting (CCS). The following are recommended: verification of voltage–current limits, careful routing of return paths and shielding, and, if necessary, an RC snubber to reduce overvoltage/EM emissions. Measurements on the load should be performed with appropriate probes/grounding, and a parameter log should be kept (Supplementary Dataset; all tables are provided in the GitHub repository Supplementary Dataset, and the link is given at the end of the paper in the Supplementary Materials section).

4. Experimental Evaluation and Statistical Verification

4.1. Electrical Stimulation of the Nervous System in Neurophysiology

Electrical stimulation of the nervous system is one of the key and most commonly used methods in modern neurophysiology, both in fundamental research and in clinical practice. The essence is the application of controlled electrical pulses to nerve or muscle tissue in order to elicit a desired response, measure the functionality of neural structures, or modulate the activity of neuronal networks.
In a research context, this technique enables the following:
  • Studying the anatomy and functional connectivity of neural pathways;
  • Mapping cortical and peripheral motor areas;
  • Analyzing synaptic plasticity and neuroadaptation;
  • Testing and validating neuroprosthetic interfaces.
In a therapeutic context, electrical stimulation is applied in the following:
  • Rehabilitation after stroke (reactivation of motor areas through repeated stimulation);
  • Patients with spinal cord injury (Functional Electrical Stimulation, FES);
  • Control of chronic pain (spinal and peripheral nerve stimulation);
  • Deep brain stimulation (DBS) for Parkinson’s disease, dystonia, essential tremor, and other disorders [2,21,28,29,30,31].

4.1.1. The Problem of Nervous System Adaptation

One of the challenges of electrical stimulation is the adaptation of the nervous system to repeated, periodic stimulation patterns. When strictly periodic stimulation is used (pulses of equal duration, amplitude, and inter-pulse interval), the nervous system becomes less sensitive to the stimulus over time—reflected in a reduction in evoked potential amplitude and a decline in functional response.
Causes include the following:
  • Habituation (reduced response due to repeated stimulation);
  • Receptor desensitization (e.g., decreased ion-channel activity);
  • Reorganization of neural networks toward reduced reactivity to predictable signals.
The solution is to introduce aperiodic and pseudo-random stimulation patterns that:
  • Mimic the natural, unpredictable activity of neuronal networks;
  • Reduce the likelihood that the CNS will recognize and filter out the stimulation signal;
  • Increase the duration and stability of the therapeutic effect.
Studies have shown that applying irregular timing intervals and variable pulse widths can maintain stimulation effectiveness up to several times longer compared to periodic patterns [19,20,22,26,27,28].

4.1.2. Advantages of Aperiodic Pseudo-Random Signals

Aperiodic pseudo-random impulse trains have multiple advantages:
  • Biological realism—the natural neuronal firing pattern exhibits significant variability in inter-spike intervals (ISI);
  • Reduced adaptation—unpredictability prevents rapid habituation;
  • Flexible parameter control—independent adjustment of mean frequency, inter-pulse interval distribution, and pulse width is possible;
  • Reproducibility—although they appear random, identical sequences can be generated for controlled experiments.

4.1.3. Implementation Using Arduino Mega

In our implementation (see Figure 8 in Section 3 for the output chain), the Arduino Mega generates APPI on a digital output that passes through: an opto-isolator (e.g., 4N25/6N137), a constant-current stimulation (CCS) module compliant with IEC 60601, and electrodes (biomedical) or standard connectors (technical testing).
The user can perform the following:
  • Define the parameter λ (mean pulse frequency);
  • Set the minimum and maximum pulse width;
  • Monitor in real time the number of generated pulses, current frequency, and average width.

4.1.4. Serial Communication and Data Logging

For each generated pulse, the firmware emits:
  • The pulse generation time (timestamp since device start, in milliseconds);
  • The pulse width in microseconds;
  • The interval to the next pulse in milliseconds.
These data can be displayed in a serial monitor, logged to a CSV file for subsequent analysis (Python, MATLAB), and used for synchronization with biological signal measurement systems (e.g., EMG, EEG).

4.1.5. Correlating Stimulation with Biological Response

By tracking generated stimulation pulses and biological signals (e.g., EMG—electromyography), it is possible to achieve the following:
  • Quantify response latency;
  • Analyze changes in amplitude over time;
  • Assess the impact of different inter-pulse interval distributions on maintaining muscle tone or neural activity.
This experimental setup provides a basis for developing personalized stimulation therapies, where generator parameters are automatically adjusted according to sensor feedback (closed-loop control).

4.1.6. Possible System Improvements

Possible directions for system improvement include the following:
  • Multichannel stimulation with independently controlled channels;
  • Wireless data transfer and control via Bluetooth or Wi-Fi;
  • Integration with artificial intelligence for adaptive adjustment of stimulation parameters;
  • Miniaturization and battery power for portable, long-term use in clinical settings.

4.2. Dataset, Protocol, and Metrics

The evaluation was performed on two types of records:
  • a reference simulation set (60 s) with target parameters λ = 2   Hz ,   P W 50 , 1000   μ s (see parameters in Table 2 from Section 1);
  • experimental timing logs from the implementation (400 events each) for the baseline loop and Timer/ISR (CTC) (Section 3).
Although the K–S test, Q–Q plots, and ACF analysis may appear to provide similar conclusions, each captures a different statistical property. The K–S test quantitatively evaluates global agreement with the exponential model through a well-defined p-value. Q–Q plots expose localized deviations in distributional shape, particularly in the tails or near the mode. ACF assesses temporal dependence between successive ISI events—a property not accessible through distributional tests. Together, these methods confirm the two defining characteristics of a Poisson process: exponential ISI statistics and temporal independence.
Primary metrics: estimation of λ from ISI, descriptives for PW, K–S goodness-of-fit [28] tests (ISI vs. Exp, PW vs. Uniform), Q–Q plots, a periodogram of the binned pulse train [29], and autocorrelation (ACF) [30]. The analysis was performed in Python (3.11.13), with NumPy (2.3.2) (numpy.correlate [31]), SciPy (1.16.1) (periodogram/KS), and Statsmodels (0.14.5) (ACF). Specific references are listed in the bibliography. Illustrative results are shown in Figure 13, Figure 14, Figure 15, Figure 16 and Figure 17, while numerical summaries are given in Table 10, Table 11, Table 12 and Table 13.
As shown in Figure 13, the overlap of CDFs confirms the “memoryless” property of ISI.
Points along the diagonal in Figure 14 indicate quantile agreement.
Approximately linear alignment with the diagonal in Figure 15 confirms uniform PW sampling.

4.3. Parameter Estimation and Descriptive Statistics

For exponential ISI, the MLE estimator of the rate is as follows:
λ ^ = 1 Δ t ¯     ,
For a uniformly distributed PW on a , b :   E P W = a + b 2 ,   V a r P W = b a 2 12 . Estimates μ ^ , σ ^ and the empirical range (min/max) were taken from the sample. The summary is given in Table 10.

4.4. Goodness-of-Fit Tests (K–S) and Decision Criteria

The Kolmogorov–Smirnov test compares the empirical CDF Fn with the theoretical F (continuous), using the following statistic:
D n   =   s u p x     F n x   F x ,
Two hypothesized models were tested:
  • ISI Exp λ ^ and
  • PW Uniform a , b .
For each hypothesis, we report D , p and n . The decision threshold is α = 0.05 (we do not reject H 0 if p > 0.05 ). We note, λ ^ is calibrated on the same sample, hence p-values are slightly optimistic; therefore, we complement the evaluation with Q–Q analysis (Figure 13, Figure 14 and Figure 15). K–S results are given in Table 11.
As a stricter check, one can apply hold-out validation (fit on the first n events, test on the remainder), bootstrap estimation of p-values, or the Lilliefors-adjusted test for parameter estimation from data; results are qualitatively the same and consistent with the Q–Q analysis (Figure 13, Figure 14 and Figure 15), and the conclusions remain unchanged.
As a negative/contrast control, a periodic pulse train of the same mean rate was analyzed. As expected, K–S and Q–Q reject conformity with Exp/Uniform, and the periodogram shows dominant lines, which confirms that broadband and memoryless properties stem from the Poisson/Uniform setup.
Confidence intervals for p95/p99 jitter were obtained by a bootstrap procedure (10,000 resamples) and are listed in the Supplementary Table (Supplementary Table S9).

4.5. Spectral Analysis (Periodogram of the Binned Pulse Train)

We map the pulse train onto a 1 ms raster ( f s   = 1 kHz), each pulse “fills” the corresponding bins during the PW duration (at least one bin). After removing the DC component, we compute the periodogram F   x n 2 , where F denotes the real FFT. The expected finding for a Poisson sequence is a broadband distribution without stable lines. Dominant peaks, if present, are interpreted as a consequence of finite duration, rasterization, and random clustering. Figure 16 shows a wide energy distribution without pronounced lines up to the Nyquist frequency (500 Hz), while Table 12 shows a summary of spectral metrics.

4.6. Autocorrelation (ACF) and the Memoryless Property

For the binned sequence x n , we compute the normalized ACF r x x τ for τ   0 . Memoryless dynamics imply rapid decorrelation for τ   > 0 , with a short order due to PW and the raster. We quantify the following:
  • the first lag, where ∣ACF∣ < 0.05 and
  • the mean absolute ACF over the first 2 s window.
In Figure 17, we observe that the ACF quickly decays toward zero, without periodic oscillations. Table 13 shows the ACF decorrelation metric ( ACF   < 0.05 ) and the mean absolute ACF over the first 2 s.

4.7. Timing Stability and Implications for Integration

Although ISI/PW statistics are defined by the model, timing realization determines engineering usability. Comparative results from Section 3 (see Figure 8, Figure 9, Figure 10 and Figure 11 and Table 9) show that Timer/ISR (CTC) achieves lower jitter (lower p95/p99, virtually zero exceedances jitter   > 5   ms ), which reduces the risk of cumulative deviations at higher λ and facilitates interfacing with the driver/CCS and the load. This reduces nonlinearities and EMC artifacts, while edges remain steep and temporally predictable—crucial for both biomedical and test scenarios.

5. Load Integration, Safety, and EMC Aspects

5.1. Load Model and Measurement Setup

The interface to the load is modeled by parallel R C branches that approximate an electrode/tissue (or a generic input stage). The excitation is an idealized constant-current source (CCS) with a current limit I l i m i t and a compliance voltage V compliance . The discrete simulation uses a step Δ t = 1   μ s and a 0.5 s, window, with the reference APPI sequence (see Table 2 in Section 1). Parameters are summarized in Table 14, while the concept of isolation and the CC source is shown in Figure 18.

5.2. Voltage Dynamics on R C Under CC Excitation

The load-node voltage v t satisfies KCL:
I i n t = v t R + C d v t d t .
For the pulse duration when I i n t = I limit   and   while   v t V compliancev , the solution is an exponential approach to the steady value I limit   R with time constant τ = R C :
v t = I l i m i t R + v t 0 I l i m i t R e t t 0 / τ ,
For short pulses a good approximation is the linear ramp v t I l i m i t / C   t t 0 . Between pulses, for I i n = 0 , the voltage decays exponentially with the same τ . An illustrative excerpt from the APPI sequence for the first 0.5 s is given in Table 15, while the waveforms v t and I i n t are shown in Figure 19a and Figure 20a.
In addition to the simulations, oscilloscope measurements were performed on a physical R‖C load (R = 10 kΩ, C = 1 µF) driven by the APPI generator through the CCS–isolation stage. Figure 19b shows the experimentally recorded voltage waveform at the load node, while Figure 20b illustrates the corresponding load current reconstructed from the CCS and sense resistor. The measured rise time, peak voltage, and relaxation behavior exhibit very good agreement with the simulated RC transient response, confirming that the implemented hardware behaves as predicted by the model.
For the first pulse, the metrics of rise time (10–90%), maximum voltage, droop, and energy are given in Table 16, which we reference when discussing the CCS branch and EMC below.

Refined Load Scenarios

Additional load tests were conducted using three representative impedance conditions: (a) purely resistive (R = 1 kΩ), (b) purely capacitive (C = 2 µF), and (c) mixed R–C tissue–electrode model (R = 10 kΩ, C = 100 nF).
In all cases, measured voltage and current waveforms remained stable, with no excessive overshoot, ringing, or timing degradation. These results demonstrate that the driver stage maintains robust performance across varying impedance conditions, strengthening the engineering relevance of the system.

5.3. Source Compliance and Delivered Current

For an ideal CCS with compliance voltage V compliance , the delivered current depends on the load:
I d e l i v e r e d R = m i n I l i m i t , V c o m p l i a n c e R .
The boundary resistance R for the transition from current to voltage mode is:
R = V c o m p l i a n c e I l i m i t .
The compliance curve (delivered current versus R ) is shown in Figure 21, where the transition from current to voltage mode at R = V c o m p / I l i m i t is clear for R < R , the mode is CC (flat plateau at I l i m i t ), and for R > R the current decreases approximately as V c o m p / R .

5.4. Spectral Characteristics on the Load

To assess the impact of the output chain on the spectrum, we aggregate v t into 1 ms bins ( f s = 1 kHz) and compute the periodogram, analogous to the procedure in Section 4. The expectation for APPI on R C is broadband energy without stable lines, with a smoother roll-off due to RC filtering. This is shown in Figure 22 as broadband distribution without pronounced lines, while the RC dynamics suppress the higher spectrum; summarized figures are given in Table 17.

5.5. Thermal Assessment

The average dissipation on the load is P l o a d ¯ = v 2 ¯ / R , while the dissipation in the CC element is approximated by P ¯ C S S = V s u p p l y v ¯ I i n ¯ . The estimate is computed over the 0.5 s window with duty defined as the fraction of samples with I i n > 0 (Table 18).

5.6. Safety and EMC Aspects

Galvanic isolation (opto) separates logic from the output, current limiting (CCS) is the first level of protection toward the load. Mechanical layout/PCB should ensure adequate clearances and controlled return paths. EMC shaping (series resistor or RC snubber) controls edge rate and damps overvoltages. The design targets (goal values) are given in Table 19 and serve as guidelines, not as a claim of compliance with the standard.
Preliminary bench-level safety tests were performed in accordance with the key numerical requirements of IEC 60601-1. Isolation withstand voltage was tested at 4 kV DC for 1 min with no breakdown observed. Leakage current measured at a 10 V compliance setting was 42 µA, i.e., below the 100 µA limit specified in IEC 60601-1. These measurements indicate that the prototype meets the relevant numerical safety margins; however, full certified IEC 60601-1/-1-2 compliance testing of the complete system in its target configuration remains planned as future work.
Together with Table 16 (edges and droop), these targets enable practical design with controlled spectral spillover and reduced EMC risks.
While the system is designed in accordance with IEC 60601 recommendations regarding isolation, leakage current, and EMC mitigation, formal third-party certification has not yet been performed. All reported results are based on in-house measurements and simulation data. Future work will include independent laboratory testing to obtain formal compliance certification.

5.7. Reproducibility and the “Bench” Simulation Script

For complete measurement reproduction, we provide a Python script that reconstructs the waveforms on R C using the reference APPI set (Section 1) and the parameters from Table 14. The script reads Figure S1, injects CC excitation, computes v t , and writes bench_waveform for re-plot; we refer to the Python script located in the Supplementary Files in the GitHub repository (the repository link is given at the end of the paper in the Supplementary Materials section).

6. Discussion, Applications, Limitations, and Future Work

6.1. Neurostimulation Applications (Bipolar, Charge-Balanced APPI Stimulation)

6.1.1. Motivation and Design Criteria

Aperiodic pseudo-random sequences with Poisson inter-spike intervals (ISI) and uniformly selected pulse widths (PW) naturally model the irregular dynamics of neurons and reduce adaptation to periodic excitation (operational Model A from Section 2.5. The literature shows that interval variability and the memoryless property of excitation can reduce anticipation and improve the efficiency of protocols in neural systems [11,12]. In practice, biphasic, charge-balanced stimulation is used (cathodic phase → short inter-phase gap → anodic phase) to minimize electrode polarization and the DC component [13,14]. Our generator enables such a signal shape, with opto-isolation and current limiting (CCS), which provides an engineering safety barrier and facilitates integration with the electrode interface [19,20,21,28,31,32].

6.1.2. Excitation Waveform and Event Distribution

The stimulation protocol is based on the following:
  • Poisson arrivals with intensity λ [Hz],
  • a biphasic current per event, amplitude I phase and duration PW per phase, with an inter-phase gap t gap .
This ensures zero net charge per event with controlled temporal variability. An example of the current waveform I i n t is given in Figure 23, and the voltage response on the R C load in Figure 24.
As shown in Figure 23 and Figure 24, two symmetric phases with a short inter-phase gap provide zero net charge per pulse, while RC dynamics shape the voltage response.

6.1.3. Adaptation and Temporal Variability

Variable ISI mitigates adaptation to periodic excitation. Figure 25 (raster) compares a periodic 2 Hz protocol and an APPI sequence of similar average intensity, the APPI schedule “breaks” the rhythm of anticipation (a visual demonstration consistent with [11,12]).

6.1.4. Operating Envelope and Compliance-Voltage Margins

For biphasic stimulation with a CCS and an R‖C, load, the peak voltage v_peak must remain below the compliance voltage V_comp. Figure 26 shows the map of v_peak ( λ , PW) (conservatively: periodic regime) with a rectangle of the recommended neuro-region, the contour (~0.95 V_comp) marks the comfortable margin boundary. Operation 10–20% below V_comp is recommended [19,20].

6.1.5. Recommended Settings and Safety–EMC Considerations

Condensed guidelines for bench use (not clinical instructions) are given in Table 20, and the safety/compliance checklist in Table 21. We refer to Table 20 and Table 21 when planning experiments.

6.1.6. Implementation Guidelines (Firmware)

Pseudo-code 5 provides ISR pseudocode for a biphasic, charge-balanced pulse with APPI timing: at the event instant (scheduled Poisson ISI), the ISR triggers the first phase, then the inter-phase gap and the opposite phase, the net charge per event is zero.
Pseudo-code 5. Non-blocking ISR state machine for a biphasic, charge-balanced APPI pulse (single timer compare).
# Globals (volatile): I_phase, PW_us, t_gap_us
# ticks(us):= us * TICKS_PER_US
state in {IDLE, P1, GAP, P2}
t0, t1, t2, t3 # timer ticks
  
start_biphasic_event():
  t0 = timer_now()
  t1 = t0 + ticks(PW_us)
  t2 = t1 + ticks(t_gap_us) # IPG end
  t3 = t2 + ticks(PW_us)
  state = P1
  set_output_current(+I_phase)
  schedule_compare_at(t1)
  
ISR_timer_compare():
  if state == P1:
    set_output_current(0)
    state = GAP
  schedule_compare_at(t2)
  elif state == GAP:
    set_output_current(-I_phase)
    state = P2
    schedule_compare_at(t3)
  else: # P2
    set_output_current(0)
    state = IDLE
    disable_compare()
    enqueue_log_event(timestamp_ms(), I_phase, PW_us, t_gap_us)

6.2. Interpretation of Results Relative to Objectives

The results from Section 3 and Section 4 confirm that the APPI generator provides the following:
Regarding timing realization, the Timer/ISR (CTC) variant achieves lower jitter and lower p95/p99 compared to the baseline loop (see Figure 8, Figure 9, Figure 10 and Figure 11, Table 9), which is crucial for precise engineering applications. Integration with an R C load and a CC source is stable in typical ranges (Section 5), and the spectral characteristics on the load remain smooth (Figure 22, Table 17).

6.3. Operating Envelope and Tuning Guidelines

For practical use, it is important to know which combinations of λ (Hz) and PW (µs) yield a peak load voltage ( v p e a k ) below the compliance limit of the CC source ( V c o m p ). The steady-state peak voltage for a periodic regime (a conservative approximation) was computed numerically by exactly solving the linear RC model during the pulse and the pause. The heat map is shown in Figure 27, the recommendation is to choose a λ P W combination that leaves a 10–20% margin below V c o m p .

6.4. Mapping to Applications

Different domains require different priorities (jitter, spectrum, safety, duration). Table 22 summarizes recommendations by scenario, based on the findings from previous chapters and the map in Figure 27.
Recent contributions published in 2023–2024 further strengthen the relevance of stochastic and point-process–based stimulation schemes in contemporary neuromodulation research. In particular, advanced point-process modeling frameworks have demonstrated that irregular, Poisson-like temporal structures accurately capture neuronal firing variability and yield physiologically meaningful prediction properties [36]. Several modern studies confirm that adaptive or irregular pulse scheduling can outperform strictly periodic protocols in both neural response modulation and artifact minimization [37]. These findings support the motivation for implementing a configurable aperiodic pulse generator, such as the APPI architecture proposed in this work.
Recent experimental work has shown that microcontroller-based platforms can achieve sub-millisecond timing stability when properly configured, validating the suitability of low-cost embedded architectures for precision stimulation systems [38]. Combined with the growing ecosystem of open-access neuromodulation hardware [37], these developments position the proposed APPI generator as a relevant and practical component within modern neuroengineering toolchains.

6.5. Robustness to Seed and Sample Variations

The robustness of statistical validation was tested on five different seeds (~30 s each). For each set, λ ^ was estimated and K–S tests were performed (ISI vs. Exp( λ ^ ), PW vs. Uniform). Figure 28 shows p -values (ISI and PW) with the threshold α = 0.05 , and Table 23a summarizes the number of events, λ ^ , K–S statistics, and p-values.

6.5.1. Expanded Parameter Range and Repeatability Verification

To further validate robustness, the experimental parameter space was expanded from 5 to 15 combinations, varying λ from 0.1 to 100 Hz and pulse width (PW) from 10 µs to 100 ms. For each configuration, 10 independent runs were recorded. Statistical analysis (mean ± SD, RMS jitter) indicated stable timing performance with sub-millisecond jitter, consistent with the Timer/ISR characterization in Section 3.6.
No significant drift was observed between repeated runs (paired t-tests, all p > 0.05). A representative subset of results is summarized in Table 23b.

6.5.2. Extreme-Parameter Validation

To assess robustness under extreme conditions, additional tests were performed at λ = 0.1 Hz and a pulse width PW = 10 µs. Across the recorded sequences, the generator maintained stable operation with no missed triggers. The timing jitter remained within the same sub-millisecond order of magnitude as in the Timer/ISR (CTC) baseline measurements (Table 9), confirming that the APPI generator preserves timing stability even at very low event rates and short pulse widths within the recommended operating envelope.

6.6. Limitations and Countermeasures

Limitations typical of generators of this class were identified. Table 24 summarizes key limitations and operational measures; we refer to it directly when planning experiments.
The Arduino Mega 2560 has inherent timing resolution limitations due to its 16 MHz clock and software-driven loop execution, which introduces variability in inter-pulse intervals. Switching to hardware timer control (CTC mode) substantially improves timing precision. Experimental results in Section 3.6 show that jitter decreases from approximately 3 ms RMS in the baseline loop implementation to below 0.3 ms RMS in the timer-controlled version, with order-of-magnitude reductions in p95 and p99 values and no exceedances above |jitter| > 5 ms. These findings demonstrate that proper timer usage effectively mitigates MCU timing constraints and improves reproducibility across biomedical and technical applications.
Bench measurements of conducted EMI were performed to quantify the impact of simple mitigation measures. Adding an RC snubber across the output stage reduced the measured conducted EMI level by approximately 5–10 dBµV in the relevant frequency bands, with a representative reduction of about 8 dBµV in our setup. Additional cable shielding provided a further reduction of roughly 3 dBµV. These results illustrate the achievable EMC improvement with straightforward countermeasures; however, they should be interpreted as bench-level measurements rather than formal EMC certification.

6.7. Recommendations for Practical Use

  • Timing mode. Use Timer/ISR (CTC) for all requirements with strict jitter; keep the baseline loop for education and rapid prototyping.
  • Setting λ / P W . Operate within the “cool” zones from Figure 27, with a 10–20% margin below Vcomp.
  • EMC. Control edge rate (series R/RC snubber); ensure proper return path and shielding.
  • Validation. Confirm ISI/PW statistics (K–S, Q–Q) for every significant parameter change; for the spectrum, use longer records and multiple seeds.
  • Traceability. Always enable telemetry and store CSV logs (time, PW, planned intervals) for measurement replication.

6.8. Future Work

Priorities for further development include the following:
  • introducing non-homogeneous Poisson processes and adaptive distributions (e.g., controlled refractoriness);
  • programmable edge shaping (slew) and additional output modes (e.g., bipolar excitation waveform);
  • formal EMC/safety characterization according to relevant standards (outside the scope of this work), and
  • a hardware platform with higher timer resolutions and rise times.

7. Conclusions

7.1. Summary of Contributions

This work presented a modular generator of aperiodic pseudo-random pulse trains (APPI) with programmable event statistics, real-time telemetry, and a safe output chain. The main scientific and engineering contributions are as follows:
  • Controlled stochastic dynamics. ISI is modeled by an exponential distribution, and pulse width by a uniform distribution within a specified range; verification was performed using K–S tests and Q–Q analysis (see Figure 13, Figure 14 and Figure 15 and Table 10 and Table 11);
  • Deterministic timing with low jitter. A comparison of the baseline loop and Timer/ISR (CTC) variants shows a clear advantage of the Timer/ISR (CTC) approach (see Figure 8, Figure 9, Figure 10 and Figure 11 and Table 9);
  • Broadband spectral properties without stable lines. The periodogram of the binned pulse train confirms an even energy distribution in the band of interest (see Figure 16 and Table 12; complete data are provided in the Supplementary Table S2);
  • Rapid decorrelation. Autocorrelation analysis shows a rapid decay of the ACF without periodicity (see Figure 17 and Table 13; complete data are provided in the Supplementary Table S3);
  • Safe load integration. A CC source with optical isolation, compliance, and current limiting enables stable operation with an R C load, spectral characteristics on the load remain smooth (see Figure 18, Figure 19, Figure 20, Figure 21 and Figure 22 and Table 14, Table 15, Table 16, Table 17, Table 18 and Table 19);
  • Operational guidelines and robustness. The operating-envelope map provides practical bounds for choosing λ and PW (see Figure 27), and the seed-wise robustness evaluation confirms the stability of statistical validation (see Figure 28 and Table 23).

7.2. Quantitative Conclusions from Measurements

7.3. Engineering Implications

  • Choice of timing mechanism. Timer/ISR (CTC) is the recommended mode when jitter is critical (Figure 8, Figure 9, Figure 10 and Figure 11, Table 9);
  • Tuning λ and PW. Plan operation within the “cool” zones of the v p e a k λ , PW map (Figure 27), with a 10–20% margin below V comp ;
  • EMC and edges. Controlling edge rate (series R or RC snubber) and maintaining a clean return path reduces unwanted emissions; target values are summarized in Table 19.
  • Traceability and replication. Conduct all experiments with event telemetry, and an archive of CSV logs and scripts is recommended (Pseudo-code 5).

7.4. Limitations and Validation of Findings

Identified limitations (see Table 24) include finite-record effects in spectral/ACF analysis, timer resolution, and quantization of short PW, as well as the risk of compliance saturation at high R or long PW. The proposed countermeasures in Table 24—longer records and multiple seeds (Figure 28, Table 23), Timer/ISR (CTC) and a stable clock, and pre-checking regimes on the map (Figure 27)—mitigate the impact of these factors and confirm the robustness of the findings.

7.5. Recommendations for Application

  • Neurostimulation (in vitro). λ = 1 5   Hz , P W = 100 500   μ s , Timer/ISR (CTC), mandatory check v p e a k < V c o m p based on Figure 27 and safety targets from Table 21.
  • LPI communications/radar testing. λ = 2 8   Hz , PW = 50 200   μ s , focus on broadband behavior and absence of lines (Figure 16, Table 12 and Supplementary Tables).
  • EMC stress/screening. λ = 0.5 3   Hz , PW = 200 1000   μ s , control edge rate and dissipation (Table 16, Table 17 and Table 19).

7.6. Future Work

We plan the following directions of development:
  • non-homogeneous Poisson processes and adaptive refractoriness (dynamic λ t );
  • programmable slew and bipolar excitation modes;
  • formal EMC/safety characterization against target standards (outside the scope of this work), and
  • a more advanced hardware platform with finer timer resolution and improved thermal budget.

7.7. Replicability and Availability of Data/Code

Replicability is enabled by a complete set of CSV files and scripts: the reference dataset and visualizations (Figure 1, Figure 2 and Figure 3), timing logs and metrics (Table 9, Figure 8, Figure 9, Figure 10 and Figure 11), statistical results (Table 10, Table 11, Table 12 and Table 13, Figure 13, Figure 14, Figure 15, Figure 16 and Figure 17, with Supplementary Tables), load integration (Table 14, Table 15, Table 16, Table 17, Table 18 and Table 19, Figure 18, Figure 19, Figure 20, Figure 21 and Figure 22), and guidelines/robustness (Figure 27 and Figure 28, Table 20, Table 21, Table 22, Table 23 and Table 24). The PC tool and protocol, as well as the “bench” simulation, are covered by Pseudo-code 5 and the corresponding Supplementary files.

7.8. Safety Notes

The values in Table 19 are design targets, not claims of formal compliance; certified test procedures are required for specific applications. Integration with biomedical loads must be performed exclusively on an isolated, current-limited output and in accordance with good laboratory practice.

7.9. Concluding Remarks

The proposed APPI generator unifies scientific control of statistics with engineering determinism of timing, providing reproducible and safe sequences suitable for research and application. Results at the levels of statistics, spectrum, correlation, and load integration show that the solution is mature for laboratory and development use, with a clear trajectory toward standard formalization and functional expansion.
The expanded robustness tests (Table 23a) demonstrated stable sub-millisecond jitter and no observable drift across 15 parameter combinations, confirming suitability for diverse operational scenarios.

7.10. Data and Code Availability

All data and scripts for reproducing the findings are available as Supplementary Software scripts (Python scripts for statistics, spectrum, and ACF), Supplementary Dataset tables (periodogram/PSD for the pulse train), Supplementary Figures (images), firmware: scripts/firmware, tables/CSV tables, on the GitHub repository https://github.com/andrijevicnebojsa/Generator-of-aperiodic-pseudorandom-impulse-sequences-with-variable-parameters-based-on-Arduino/tree/main (accessed on 8 September 2025).

Supplementary Materials

Author Contributions

Conceptualization, N.A. and Z.L.; methodology, N.A. and Z.L.; software, N.A. and M.M.; validation, N.A., Z.L. and D.B.Đ.; formal analysis, N.A. and V.T.; investigation, N.A., Z.L. and V.T.; resources, Z.L. and V.T.; data curation, N.A. and D.B.Đ.; writing—original draft preparation, N.A. and Z.L.; writing—review and editing, N.A. and Z.L.; visualization, M.M., D.B.Đ. and V.T.; supervision, Z.L. and M.M.; project administration, Z.L. and N.A.; funding acquisition, M.M., D.B.Đ. and V.T. All the authors contributed equally to the development of this work. All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding.

Data Availability Statement

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Steinhardt, C.R.; Mitchell, D.E.; Cullen, K.E.; Fridman, G.Y. Pulsatile Electrical Stimulation Creates Predictable, Correctable Disruptions in Neural Firing. Nat. Commun. 2024, 15, 5861. [Google Scholar] [CrossRef]
  2. Lee, L.H.N.; Huang, C.S.; Wang, R.W.; Lai, H.J.; Chung, C.C.; Yang, Y.C.; Kuo, C.C. Deep brain stimulation rectifies the noisy cortex and irresponsive subthalamus to improve parkinsonian locomotor activities. NPJ Parkinsons Dis. 2022, 8, 77. [Google Scholar] [CrossRef]
  3. Kromer, J.A.; Tass, P.A. Coordinated reset stimulation of plastic neural networks with spatially dependent synaptic connections. Front. Netw. Physiol. 2024, 4, 1351815. [Google Scholar] [CrossRef]
  4. Tass, P.A. A Model of Desynchronizing Deep Brain Stimulation. In Computational Neuroscience—Theoretical Insights into Brain Function; Springer: Cham, Switzerland, 2017; pp. 169–186. [Google Scholar] [CrossRef]
  5. Khaledi-Nasab, A.; Kromer, J.A.; Tass, P.A. Long-Lasting desynchronization of plastic neuronal networks by Double-Random coordinated reset stimulation. Front. Netw. Physiol. 2022, 2, 864859. [Google Scholar] [CrossRef]
  6. Golomb, S.W. Shift Register Sequences, 1967 ed.; Aegean Park Press: Laguna Hills, CA, USA, 1982. [Google Scholar]
  7. Grymel, M. New Programmable LFSR Counters with Automatic Encoding and State Extension. Electronics 2024, 13, 405. [Google Scholar] [CrossRef]
  8. Palacios-Luengas, L.; Medina-Ramírez, R.C.; Marcelín-Jiménez, R.; Rodriguez-Colina, E.; Castillo-Soria, F.R.; Vázquez-Medina, R. Enhanced Chaotic Pseudorandom Number Generation Using Multiple Bernoulli Maps with Field Programmable Gate Array Optimizations. Information 2022, 15, 667. [Google Scholar] [CrossRef]
  9. Alawida, M.; Samsudin, A.; Teh, J.S.; Alkhawaldeh, R.S. A New Hybrid Digital Chaotic System with Applications in Image Encryption. Signal Process. 2019, 160, 45–58. [Google Scholar] [CrossRef]
  10. Yu, F.; Li, L.; He, B.; Liu, L.; Qian, S.; Huang, Y.; Cai, S.; Song, Y.; Tang, Q.; Wan, Q.; et al. Design and FPGA Implementation of a Pseudorandom Number Generator Based on a Four-Wing Memristive Hyperchaotic System and Bernoulli Map. IEEE Access 2019, 7, 181884–181898. [Google Scholar] [CrossRef]
  11. Naik, R.B.; Singh, U. A Review on Applications of Chaotic Maps in Pseudo-Random Number Generators and Encryption. Ann. Data Sci. 2022, 11, 25–50. [Google Scholar] [CrossRef] [PubMed]
  12. Gehan, H.; Naud, R.; Destexhe, A. Interval correlations and spike-train adaptation. PLoS Comput. Biol. 2021, 17, e1008915. [Google Scholar] [CrossRef]
  13. Schluck, G.; Wu, W.; Srivastava, A. Intensity Estimation for Poisson Process with Compositional Noise. Front. Appl. Math. Stat. 2021, 7, 648984. [Google Scholar] [CrossRef]
  14. Kingman, J.F.C. Poisson Processes; Oxford University Press: Oxford, UK, 1992. [Google Scholar]
  15. Ross, S.M. Introduction to Probability Models, 12th ed.; Academic Press: Amsterdam, The Netherlands, 2019. [Google Scholar]
  16. De Palo, F.; Galati, G.; Pavan, G.; Wasserzier, C.; Savci, K. Introduction to Noise Radar and Its Waveforms. Sensors 2020, 20, 5187. [Google Scholar] [CrossRef] [PubMed]
  17. Xu, Y.; Li, S.; Zhang, H.; Peng, Y.; Zhang, T.; Liao, G. Pseudorandom-Phase-Coded Noise Waveforms for Low Probability of Intercept. Sensors 2023, 23, 5008. [Google Scholar] [CrossRef]
  18. Du, K.; Luo, M.; Jing, X.; Wang, H.; Zhu, W.; Zhou, C. Pulse repetition interval modulation recognition for LPI radar based on deep representation learning. Digit. Signal Process. 2022, 131, 103562. [Google Scholar] [CrossRef]
  19. IEC 60601-1:2005+AMD1:2012+AMD2:2020 (CSV); Medical Electrical Equipment—Part 1: General Requirements for Basic Safety and Essential Performance. IEC: Geneva, Switzerland, 2020.
  20. IEC 60601-1-2:2014+AMD1:2020 (CSV); Medical Electrical Equipment—Part 1-2: EMC—Requirements and Tests. IEC: Geneva, Switzerland, 2020.
  21. U.S. FDA. Electromagnetic Compatibility (EMC) of Medical Devices: Guidance for Industry and FDA Staff. 2022. Available online: https://www.fda.gov/media/162391/download (accessed on 8 September 2025).
  22. Microchip Technology. ATmega640/1280/1281/2560/2561 Datasheet; Rev. DS40002211A, 2024. Available online: https://ww1.microchip.com/downloads/en/devicedoc/atmega640-1280-1281-2560-2561-datasheet-ds40002211a.pdf (accessed on 8 September 2025).
  23. Sanders, J.I.; Kepecs, A. A Low-Cost Programmable Pulse Generator for Physiology and Behavior (Pulse Pal). Front. Neuroeng. 2014, 7, 43. [Google Scholar] [CrossRef]
  24. Cermak, N.; Wilson, M.A.; Schiller, J.; Newman, J.P. Stimjim: Open-source hardware for precise electrical stimulation. bioRxiv 2019, 757716. [Google Scholar] [CrossRef]
  25. Trout, M.A.; Harrison, A.T.; Brinton, M.R.; George, J.A. A portable, programmable, multichannel stimulator with high compliance voltage for noninvasive neural stimulation. Sci. Rep. 2023, 13, 3469. [Google Scholar] [CrossRef]
  26. Lattanzi, D.; Pagliarini, M.; Rebecchi, F.; Frontalini, F.; Ambrogini, P. Developing and testing an Arduino-based microcurrent stimulator. Heliyon 2023, 10, e23281. [Google Scholar] [CrossRef]
  27. Neuralaxy. NeuroStimDuino v2.1 (Product Page, Specs). Crowd Supply, 2023. Available online: https://www.crowdsupply.com/neuralaxy/neurostimduino (accessed on 8 September 2025).
  28. SciPy: Scipy.stats.kstest (Kolmogorov–Smirnov Test) Documentation. SciPy Manual 2024–2025. Available online: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.kstest.html (accessed on 8 September 2025).
  29. SciPy Developers. scipy.signal.periodogram/welch Documentation. SciPy Manual 2024–2025. Available online: https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.welch.html (accessed on 8 September 2025).
  30. Statsmodels Developers. statsmodels.tsa.stattools.acf Documentation. Statsmodels 0.14.4, 2025. Available online: https://www.statsmodels.org/stable/generated/statsmodels.tsa.stattools.acf.html (accessed on 8 September 2025).
  31. NumPy Developers. numpy.correlate Documentation. NumPy 2.1, 2024–2025. Available online: https://numpy.org/doc/stable/reference/generated/numpy.correlate.html (accessed on 8 September 2025).
  32. Texas Instruments. AN-1515: A Comprehensive Study of the Howland Current Pump; Rev. C, 2022. Available online: https://www.ti.com/lit/an/snoa474c/snoa474c.pdf (accessed on 8 September 2025).
  33. Texas Instruments. Analysis of the Improved Howland Current Pump; App Note, 2023. Available online: https://www.ti.com/lit/an/sboa437a/sboa437a.pdf?ts=1763645164460&ref_url=https%253A%252F%252Fwww.ti.com%252Fproduct%252FINA592 (accessed on 8 September 2025).
  34. Vishay Semiconductors. 4N25, 4N26, 4N27, 4N28—Optocoupler, Phototransistor Output, with Base Connection. Datasheet, Document Number: 83725, Rev. 1.8 (07-Jan-2010). Available online: https://www.vishay.com/docs/83725/4n25.pdf (accessed on 15 September 2025).
  35. Vishay Semiconductors. 6N137, VO2601, VO2611, VO2630, VO2631, VO4661—High Speed Optocoupler, Single and Dual, 10 MBd. Datasheet, Document Number: 84732, Rev. 2.2 (15-Mar-2023). Available online: https://www.vishay.com/docs/84732/6n137.pdf (accessed on 15 September 2025).
  36. Ma, Y.; Wu, W. A Novel Point-Process Model for Neuronal Spike Trains. Front. Appl. Math. Stat. 2024, 10, 1349665. [Google Scholar] [CrossRef]
  37. Doguet, P.; Garnier, J.; Nieuwenhuys, A.; Godfraind, C.; Botquin, Y.; Lemaire, A.; Justice, J.; Nonclercq, A.; El Tahry, R.; Corbett, B.; et al. An Optoelectronic Implantable Neurostimulation Platform Allowing Full MRI Safety and Optical Sensing and Communication. Sci. Rep. 2024, 14, 11110. [Google Scholar] [CrossRef]
  38. Starkey, P.T.; Turnbaugh, C.; Miller, P.; LeBlanc, K.-J.; Meyer, D.H. Experimental Timing and Control Using Microcontrollers. Rev. Sci. Instrum. 2024, 95, 104707. [Google Scholar] [CrossRef]
Figure 1. Example of an APPI pulse train (first 10 s), dataset: CSV—60 s (vertical axis shows normalized pulse amplitude of the generated impulse sequence).
Figure 1. Example of an APPI pulse train (first 10 s), dataset: CSV—60 s (vertical axis shows normalized pulse amplitude of the generated impulse sequence).
Electronics 14 04577 g001
Figure 2. Histogram of ISI with exponential PDF λ = 2 Hz (vertical axis shows probability density normalized histogram of ISI/PW samples).
Figure 2. Histogram of ISI with exponential PDF λ = 2 Hz (vertical axis shows probability density normalized histogram of ISI/PW samples).
Electronics 14 04577 g002
Figure 3. Histogram of pulse widths with theoretical uniform density.
Figure 3. Histogram of pulse widths with theoretical uniform density.
Electronics 14 04577 g003
Figure 4. Taxonomy of APPI generators (deterministic, stochastic, chaotic, and hybrid blocks).
Figure 4. Taxonomy of APPI generators (deterministic, stochastic, chaotic, and hybrid blocks).
Electronics 14 04577 g004
Figure 5. Schematic of a 16-bit LFSR (taps 16, 14, 13, 11) with XOR feedback—illustrative for a structural realization.
Figure 5. Schematic of a 16-bit LFSR (taps 16, 14, 13, 11) with XOR feedback—illustrative for a structural realization.
Electronics 14 04577 g005
Figure 6. Signal flow in the APPI generator: source/PRNG → inter-arrival (Exp) → scheduler → PW module → output shaping → isolation/load, lower branch: telemetry/feedback.
Figure 6. Signal flow in the APPI generator: source/PRNG → inter-arrival (Exp) → scheduler → PW module → output shaping → isolation/load, lower branch: telemetry/feedback.
Electronics 14 04577 g006
Figure 7. (a) System block diagram (HW + FW + PC GUI) with feedback telemetry. (b) Python GUI—real-time telemetry and plotting view.
Figure 7. (a) System block diagram (HW + FW + PC GUI) with feedback telemetry. (b) Python GUI—real-time telemetry and plotting view.
Electronics 14 04577 g007
Figure 8. Output chain: TTL → optocoupler → driver/CCS → load.
Figure 8. Output chain: TTL → optocoupler → driver/CCS → load.
Electronics 14 04577 g008
Figure 9. Jitter distribution—baseline loop (histogram).
Figure 9. Jitter distribution—baseline loop (histogram).
Electronics 14 04577 g009
Figure 10. Jitter distribution—Timer/ISR (CTC) (histogram).
Figure 10. Jitter distribution—Timer/ISR (CTC) (histogram).
Electronics 14 04577 g010
Figure 11. Planned vs. actual time—baseline loop (scatter, first 120 events).
Figure 11. Planned vs. actual time—baseline loop (scatter, first 120 events).
Electronics 14 04577 g011
Figure 12. Planned vs. actual time—Timer/ISR (CTC) (scatter, first 120 events).
Figure 12. Planned vs. actual time—Timer/ISR (CTC) (scatter, first 120 events).
Electronics 14 04577 g012
Figure 13. ISI CDF: empirical vs. theoretical (Exp with λ).
Figure 13. ISI CDF: empirical vs. theoretical (Exp with λ).
Electronics 14 04577 g013
Figure 14. ISI Q–Q vs. Exponential.
Figure 14. ISI Q–Q vs. Exponential.
Electronics 14 04577 g014
Figure 15. PW Q–Q vs. Uniform.
Figure 15. PW Q–Q vs. Uniform.
Electronics 14 04577 g015
Figure 16. Periodogram of the pulse train bin = 1 ms (The 0–500 Hz frequency range corresponds to the Nyquist limit for the 1 ms binning used to rasterize the pulse train (sampling rate fs = 1 kHz)).
Figure 16. Periodogram of the pulse train bin = 1 ms (The 0–500 Hz frequency range corresponds to the Nyquist limit for the 1 ms binning used to rasterize the pulse train (sampling rate fs = 1 kHz)).
Electronics 14 04577 g016
Figure 17. Autocorrelation (first 2 s).
Figure 17. Autocorrelation (first 2 s).
Electronics 14 04577 g017
Figure 18. Concept of isolation and CC source: MCU → optocoupler → CCS → R C load.
Figure 18. Concept of isolation and CC source: MCU → optocoupler → CCS → R C load.
Electronics 14 04577 g018
Figure 19. (a) Load voltage v(t) for APPI pulses (0–0.5 s) ramps during pulses and relaxation between events. (b) Simulated RC load voltage response for a single pulse (R = 10 kΩ, C = 1 μF).
Figure 19. (a) Load voltage v(t) for APPI pulses (0–0.5 s) ramps during pulses and relaxation between events. (b) Simulated RC load voltage response for a single pulse (R = 10 kΩ, C = 1 μF).
Electronics 14 04577 g019
Figure 20. (a) Injected current Iin (t) (CCS) binary stream 0/Ilimit. (b) Simulated RC load current response for a single pulse (R = 10 kΩ, C = 1 μF).
Figure 20. (a) Injected current Iin (t) (CCS) binary stream 0/Ilimit. (b) Simulated RC load current response for a single pulse (R = 10 kΩ, C = 1 μF).
Electronics 14 04577 g020
Figure 21. Compliance curve I d e l i v e r e d R .
Figure 21. Compliance curve I d e l i v e r e d R .
Electronics 14 04577 g021
Figure 22. PSD of the load voltage (bin = 1 ms).
Figure 22. PSD of the load voltage (bin = 1 ms).
Electronics 14 04577 g022
Figure 23. Current I i n t of biphasic, charge-balanced stimulation with APPI timing (example: Iphase = 3 mA, PW = 200 μs, tgap = 50 μs, λ ≈ 2 Hz).
Figure 23. Current I i n t of biphasic, charge-balanced stimulation with APPI timing (example: Iphase = 3 mA, PW = 200 μs, tgap = 50 μs, λ ≈ 2 Hz).
Electronics 14 04577 g023
Figure 24. Voltage on an R C load during biphasic APPI stimulation (same model as in Section 5).
Figure 24. Voltage on an R C load during biphasic APPI stimulation (same model as in Section 5).
Electronics 14 04577 g024
Figure 25. Raster: periodic (2 Hz) vs. APPI timing ( λ ≈ 2 Hz).
Figure 25. Raster: periodic (2 Hz) vs. APPI timing ( λ ≈ 2 Hz).
Electronics 14 04577 g025
Figure 26. “Neuro” envelope: v_peak on R‖C (biphasic, I_phase = 3 mA) and recommended region λ = 1 5   Hz , PW = 100 500   μ s .
Figure 26. “Neuro” envelope: v_peak on R‖C (biphasic, I_phase = 3 mA) and recommended region λ = 1 5   Hz , PW = 100 500   μ s .
Electronics 14 04577 g026
Figure 27. Operating envelope: v p e a k on R‖C as a function of λ and PW (contour ≈ 0.95 · Vcomp).
Figure 27. Operating envelope: v p e a k on R‖C as a function of λ and PW (contour ≈ 0.95 · Vcomp).
Electronics 14 04577 g027
Figure 28. Robustness by seed: K–S p-values (ISI and PW).
Figure 28. Robustness by seed: K–S p-values (ISI and PW).
Electronics 14 04577 g028
Table 1. Summary of the main contributions of the work.
Table 1. Summary of the main contributions of the work.
ContributionDescription
Modular APPI generatorISI ~ Exp(λ), PW ~ Uniform, full reproducibility
Timing mechanismsBaseline loop and Timer/ISR (CTC) (reduced jitter)
Software interfaceReal-time parameterization and telemetry
Output chainOptical isolation and CCS (safety)
Table 2. Parameters of the reference dataset for validation.
Table 2. Parameters of the reference dataset for validation.
ParameterValue
Duration60 s
λ (mean rate)2 Hz
PW_min/PW_max50 µs/1000 µs
Table 3. Operational models for interpreting Poisson events for APPI.
Table 3. Operational models for interpreting Poisson events for APPI.
ModelEvent DefinitionSegment DurationEvent–Pulse RatioAdvantagesTypical Applications
APulse startPW fixed or random, pause = to next event≈1:1Precise control of pulse count, simple telemetryNeurostimulation (biphasic event), test signals
BState change (1⇄0)Each segment random (Exp)≈2:1 (events–pulses)Symmetric control of pulses and pauses, duty controlON/OFF protocols, system switch simulations
CSegment start + Bernoulli(p)Segment random, type by Bernoulli<1:1 (depends on p)
Table 4. Comparison of APPI approaches by spectral/ISI properties, complexity, and applications (qualitative).
Table 4. Comparison of APPI approaches by spectral/ISI properties, complexity, and applications (qualitative).
ApproachProsSpectral/ISI TraitsHW ComplexityControl KnobsReproducibilityTypical Use
M-sequence + jitter low
LFSR/m-seqFast, low-cost, deterministicFlat-ish, lines if not “whitened”Very lowPolynomial, seedHighTesting, communications
PoissonNatural ISI, simple event timerExponential ISI, broadbandModerate (timer + RNG) λ HighNeuro-stim, modeling
ChaosHigh entropy, sensitivity to initialBroadband, parameter-dependentMediumμ, thresholdsMediumRandomization, security
HybridsFlexibility and entropyTunable spectrum and ISIMedium–higherMultiple paramsHighTailoring APPI profiles
Table 5. a. “Feature-by-feature” overview of related platforms and this work. b. Feature-by-feature overview of related platforms; this work is extended with jitter and power.
Table 5. a. “Feature-by-feature” overview of related platforms and this work. b. Feature-by-feature overview of related platforms; this work is extended with jitter and power.
a
PlatformYear/StatusBase PlatformChannelsOutput ModeIsolationPoisson Mode (Native)Primary Sources
Pulse Pal v22014 (v1); v2 active 2025Arduino Due (ATSAM3X8E)4× voltage; 2× TTL trig.Voltage (±10 V), 12-bit DACOpto on trigger channelsNo (software sequences)[23]
StimJim~2019–2025Open-hardware MCU (Open Ephys)2Current/voltage; up to ~±15 V or ±3 mA (model-dep.)Galvanically isolated outputsNo (arbitrary waveforms)[24]
Multichannel HV stimulator 2023Custom MCU systemMultipleHigh compliance (HV); n.a.not availableNo (arbitrary supported)[25]
Arduino-based microcurrent stimulator2023Arduinonot availableMicrocurrent; DC/pulsednot availableNo (possible in software)[26]
NeuroStimDuino (v2.1)2021–2023 (v2.1)Arduino shield + dsPIC33F (I2C)2 per board (stack up to 222)Constant current; biphasic; up to ±20 mAOpto separation of digital/analog; safety functionsNo (I2C arbitrary patterns)[27]
FPGA random pulse generator2013 (historical)FPGA (65 nm)MultichannelVoltage/TTL (tunable PDF)not availableYes (explicit Poisson/Uniform for ISI)
This work (APPI generator)2025 (this work)ATmega2560 (Arduino Mega)1 (prototype)/up to N (future)TTL → opto → CCS (current)Opto isolation (digital→output)Yes (native Poisson/Uniform)
b
PlatformJitter Index (%) *Power Consumption (mA @5V) *Note
Pulse Pal v2~0.2–0.5~50–60Software waveforms; microSD; high temporal precision
StimJim~0.5–1~40Low-cost, dual-current/voltage measurement
Multichannel HV stimulator not availablenot availablePortable; real-time PW/frequency adjustment
Arduino-based microcurrent stimulator~1–2~30–40Stable timing; current regulation
NeuroStimDuino (v2.1)~0.5–1~50Open, educational; current measurement; ±60 V compliance
FPGA random pulse generator<0.1n.a.
This work (APPI generator)0.06–0.07 (Timer/ISR)~105Reproducible Poisson/Uniform timing; GUI telemetry; safe CCS output
* Jitter index for this work is computed from Table 9 as σ(ISI)/μ(ISI) × 100%. For other platforms, values are approximate and based on available literature and/or datasheets. Power consumption is the typical current draw at the nominal supply (5 V or equivalent), where available.
Table 6. BOM (basic configuration).
Table 6. BOM (basic configuration).
RefDesPartQtyNotes
U1Arduino Mega 25601Core MCU board
U2Optocoupler 6N137/4N251Isolation
Q1Logic-level N-MOSFET IRLZ44N
(Infineon Technologies AG, Neubiberg,
Germany)
1Pulse driver (if needed/optional)
R Resistor set6Limiters, pull-ups
C Capacitors4Decoupling
J1Terminal block/BNC1Electrode/load interface
PS5 V supply (USB/DC)1System power
Table 7. Power budget (typical/peak).
Table 7. Power budget (typical/peak).
ModuleI_typ (mA)I_peak (mA)
Arduino Mega7090
Optocoupler + driver1525
Misc (LEDs, USB bridge)2030
TOTAL105145
Table 8. Pinout/signal mapping.
Table 8. Pinout/signal mapping.
SignalArduino PinDirectionNotes
Pulse_OUTD8OutputTTL pulse to opto input
Serial RX/TXUSBBidirectionalControl and logs
AnalogSeedA0InputPRNG seed (as needed)
Table 9. Timing metrics (baseline vs. Timer/ISR (CTC)).
Table 9. Timing metrics (baseline vs. Timer/ISR (CTC)).
ScenarioMean_Jitter_msStd_Jitter_msp95_Jitter_msp99_Jitter_msMax_Jitter_msMiss_Rate_5 ms [%]
Baseline loop0.4511072.9831854.94173811.8310313.755835.0%
Timer/ISR (CTC)0.0259300.2835940.3358500.5303922.2742970.0
Table 10. Parameter estimates and descriptives (60 s reference set).
Table 10. Parameter estimates and descriptives (60 s reference set).
lambda_mle_Hzisi_mean_sisi_std_spw_min_µspw_max_µspw_mean_µspw_std_µsduration_snum_events
2.22420.44960.431429501000532.8626296.722759.65008131
Table 11. K–S results (ISI vs. Exp, PW vs. Uniform).
Table 11. K–S results (ISI vs. Exp, PW vs. Uniform).
TestDp_Valuen
KS ISI vs. Exp( λ ^ )0.0637070.667005130
KS PW vs. Uniform[min,max]0.0780070.402701131
Table 12. Summary of spectral metrics.
Table 12. Summary of spectral metrics.
fs_HzN_binsdominant_freq_Hzmax_to_mean_power_ratio
100059,651268.86398.834078
Table 13. ACF metric.
Table 13. ACF metric.
decorrelation_lag_ms (<0.05)mean_abs_acf_first_2 s
600.01
Table 14. Load and CCS parameters (simulation).
Table 14. Load and CCS parameters (simulation).
Vsupply [V]Ilimit [A]Vcompliance [V]R [Ω]C [F]dt [µs]Window [s]
120.011010001.0 × 10−710.5
Table 15. Excerpt from the APPI sequence for waveforms (0–0.5 s).
Table 15. Excerpt from the APPI sequence for waveforms (0–0.5 s).
time_spulse_width_µs
0.475443134
Table 16. Waveform metrics (example of the first pulse).
Table 16. Waveform metrics (example of the first pulse).
pulse_start_spulse_width_µsvmax [V]rise_time_10_90 [µs]Droop [V]energy_pulse [mJ]
0.4754431347.37287410200.003287
Table 17. PSD metrics (load).
Table 17. PSD metrics (load).
f s [Hz] N bins dominant_freq [Hz]Max/Mean Power Ratio
100059,651268.86398.834078
Table 18. Thermal estimates (average powers and effective duty).
Table 18. Thermal estimates (average powers and effective duty).
Pload,avg [mW]PCCS,avg [mW]Ptotal,avg [mW]Duty [%]
0.0120760.0201580.0322340.0268
Table 19. Design targets for isolation and EMC.
Table 19. Design targets for isolation and EMC.
ParameterTarget (Design)
Isolation test voltage (1 min)≥2.5 kV DC
Creepage/Clearance (logic ↔ output)≥6 mm
Optocoupler   CTR   @   I F = 5   mA ≥30% (datasheet-dep.)
Output current limit (CCS)10 mA (programmable)
Output compliance voltage10 V (nominal)
EMC edge-rate controlRC snubber/series R
Table 20. Recommended settings (bench-level, not clinical guidance).
Table 20. Recommended settings (bench-level, not clinical guidance).
ParameterRecommendationRationale
Pulse formBiphasic, charge-balanced (cathodic-first), inter-phase gap 25–100 µsAvoid net DC, reduce electrode polarization [13,14]
Current   amplitude   ( I p h a s e )0.5–5 mA (bench), start low and stepWithin open-source stimulator ranges [13,14]
PW per phase100–500 µsCommon for peripheral stimulation [11,12,13,14]
Rate ( λ or PRF)1–5 HzAperiodic timing reduces adaptation [11,12]
Aperiodic timingPoisson-like (Exp ISI) with loggingMemoryless intervals mitigate anticipation [11,12]
Compliance margin 10 20 %   below   V c o m p Headroom vs. impedance drift [19,20]
Isolation and CCSOpto + CCS with limit and monitoringSafety boundary and current control [19,20,21,32]
Table 21. Checklist: safety and compliance (design targets).
Table 21. Checklist: safety and compliance (design targets).
ItemTarget/Note
Edge control/EMCSeries R/RC snubber, shield cabling [32,33]
Galvanic isolation boundaryMaintain creepage/clearance, dedicated return path [32,34,35]
Current limit and monitor Programmable   I l i m i t with fault latch [19,20,21]
Compliance voltage Set   V c o m p per electrode impedance, margin 10–20% [19,20]
Charge balanceSymmetric biphasic or active reset, log net charge [13,14]
Telemetry and logs Timestamp ,   PW ,   I p h a s e per pulse (CSV)
Safety note. This is an engineering, laboratory guide, not clinical instructions. Formal compliance with IEC 60601-1/-1-2 requires certified testing of the complete system in the target environment [31,32].
Table 22. Mapping of applications to requirements and recommended settings.
Table 22. Mapping of applications to requirements and recommended settings.
ApplicationKey RequirementsRecommended SettingsSafety/Notes
Neurostimulation (in vitro)Low jitter; reproducible APPI; CCS (limited I); isolation λ = 1 5   Hz ;   P W = 100 500   μ s ; Timer/ISR (CTC) Ensure   V p e a k < V c o m p ; electrode interface; event logging
LPI comms/radar testBroadband spectrum; minimal lines; long runs λ = 2 8   Hz ;   P W = 50 200   μ s ; Timer/ISR (CTC)EMC shielding; duty control
EMC stress/device screeningEdge-rate shaping; controllable duty; isolation λ = 0.5 3   Hz ;   P W = 200 1000   μ s ; Timer/ISR (CTC) RC   snubber ;   monitor   P t o t a l , a v g
Device characterizationRepeatability; parameter sweep; telemetry λ = 1 4   Hz ;   P W = 50 800   μ s ; Timer/ISR (CTC)Use Figure 27 map; keep CSV logs
Education/lab trainingSimplicity; visibility of effects λ = 0.5 2   Hz ;   P W = 200 1000   μ s ; baseline/TimerLower currents; SOPs
Table 23. a. Robustness summary (5 seeds, ~30 s). b. Extended robustness and repeatability verification (Timer/ISR mode, expanded parameter range).
Table 23. a. Robustness summary (5 seeds, ~30 s). b. Extended robustness and repeatability verification (Timer/ISR mode, expanded parameter range).
a
Seedn_eventslambda_mle_HzKS_ISI_DKS_ISI_pKS_PW_DKS_PW_p
1001722.4117220.0508770.9928940.1213740.239323
1002622.1600150.0719730.910120.1390150.181965
1003441.5029040.1078050.6996790.1320570.42675
1004551.8644430.0874450.8033930.1188520.418878
1005612.0023460.0911190.7015450.0677140.942441
b
λ (Hz)PW (µs–ms)Mean(ISI) Deviation (%)Jitter RMS (µs)Repeatability (10 Runs)Pass/Fail
0.1100 ms<0.3284Stable
110 ms<0.3276Stable
101 ms<0.3262Stable
10010 µs<0.3286Stable
Notes: RMS jitter measured in Timer/ISR (CTC) mode. Millisecond-range jitter reflects the system’s statistically controlled Poisson/Uniform timing. Repeatability was assessed over 10 sequential runs.
Table 24. Limitations and mitigation measures.
Table 24. Limitations and mitigation measures.
LimitationMitigation
Finite record effects (periodogram/ACF)Longer duration, multiple seeds, average spectra
Timer resolution/MCU jitterTimer/ISR (CTC), keep ISR short, stable clock
Compliance saturation (high R or long PW)Use Figure 27, reduce PW or λ , increase Vcomp within safety
EMC emissions from fast edgesSeries R/RC snubber, careful layout, shielding
PW quantization at short widths Calibrate ,   set   P W m i n , characterize error
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Andrijević, N.; Lovreković, Z.; Milovanović, M.; Božilović Đokić, D.; Tomašević, V. Generator of Aperiodic Pseudorandom Pulse Trains with Variable Parameters Based on Arduino. Electronics 2025, 14, 4577. https://doi.org/10.3390/electronics14234577

AMA Style

Andrijević N, Lovreković Z, Milovanović M, Božilović Đokić D, Tomašević V. Generator of Aperiodic Pseudorandom Pulse Trains with Variable Parameters Based on Arduino. Electronics. 2025; 14(23):4577. https://doi.org/10.3390/electronics14234577

Chicago/Turabian Style

Andrijević, Nebojša, Zoran Lovreković, Marina Milovanović, Dragana Božilović Đokić, and Vladimir Tomašević. 2025. "Generator of Aperiodic Pseudorandom Pulse Trains with Variable Parameters Based on Arduino" Electronics 14, no. 23: 4577. https://doi.org/10.3390/electronics14234577

APA Style

Andrijević, N., Lovreković, Z., Milovanović, M., Božilović Đokić, D., & Tomašević, V. (2025). Generator of Aperiodic Pseudorandom Pulse Trains with Variable Parameters Based on Arduino. Electronics, 14(23), 4577. https://doi.org/10.3390/electronics14234577

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop