A four-state adaptive Hopf oscillator

Adaptive oscillators (AOs) are nonlinear oscillators with plastic states that encode information. Here, an analog implementation of a four-state adaptive oscillator, including design, fabrication, and verification through hardware measurement, is presented. The result is an oscillator that can learn the frequency and amplitude of an external stimulus over a large range. Notably, the adaptive oscillator learns parameters of external stimuli through its ability to completely synchronize without using any pre- or post-processing methods. Previously, Hopf oscillators have been built as two-state (a regular Hopf oscillator) and three-state (a Hopf oscillator with adaptive frequency) systems via VLSI and FPGA designs. Building on these important implementations, a continuous-time, analog circuit implementation of a Hopf oscillator with adaptive frequency and amplitude is achieved. The hardware measurements and SPICE simulation show good agreement. To demonstrate some of its functionality, the circuit’s response to several complex waveforms, including the response of a square wave, a sawtooth wave, strain gauge data of an impact of a nonlinear beam, and audio data of a noisy microphone recording, are reported. By learning both the frequency and amplitude, this circuit could be used to enhance applications of AOs for robotic gait, clock oscillators, analog frequency analyzers, and energy harvesting.


Introduction
Adaptive oscillators are similar to phase-locked loops, except they have an additional, direct injection of the external forcing on the oscillator itself. Previously, only two circuit implementations of adaptive oscillators have been reported, both of which were Hopf Adaptive Frequency Oscillators (HAFOs)-a VLSI implementation (noting that the VLSI implementation did not report any experimental results) [1] and an FPGA implementation [2]. The two primary goals for this manuscript are 1) to provide a HAFO architecture with an additional plastic state that builds on these important, previous contributions and 2) to report new hardware results for a physical implementation. As few published designs currently exist and verified hardware measurements are scarce in the literature, this second point is especially important. Early studies of adaptive phase oscillators were used as neural models to reproduce sinusoidal inputs [3]. More generally, adaptive oscillators (AOs) can be created by adding additional, plastic states to a nonlinear oscillator [4]. The derivation of adaptive frequency oscillators (AFOs) was originally based on a dynamic Hebbian learning rule implemented in hardware by modifying the Hopf system [5]. The correlation-based Hebbian rule was inspired from the firing rate of neurons, such that the information transmission between different neurons will be increased due to electrical activity, which can synchronize neural networks [6]. Generally, learning characteristics of AOs can be preferable when compared with their counterparts, such as the relaxation oscillator and the phase oscillator [7,8], which are limited to simple inputs and have smaller basins of attraction.
Several practical applications of AOs have been explored. Central pattern generators (CPGs) have been used to control the motion of individual joints of walking robots [9], and adaptive frequency oscillators can work together to create an arbitrary CPG [10][11][12]. Various gait patterns for locomotion can be achieved through assigning specific frequency and phase angles to individual oscillators in an array. Applications for locomotion control using Field Programmable Gate Arrays (FPGAs) with the aid of CPGs and coupled nonlinear oscillators have also been proposed [13][14][15]. Specifically, the HAFO has been used for robotic locomotion control by employing HAFOs as CPGs to tune walking patterns in a cooperative way [16][17][18]. Body dynamics of these robots often vary over time due to obstacles and environmental fluctuations. These oscillators can be used as adaptive controllers that find and match intrinsic frequencies leading to enhanced energy efficiency of the resulting gait [19,20]. Additionally, AFOs have been proposed to detect gait phase and frequency in robots for assisting people with walking difficulties due to muscle weakness [21] or reducing the metabolic cost of walking [22]. State observer AFOs have been used to create cross adaptation between users and assistance robots resulting in reduced effort supporting arm muscles' activities [23]. An array of AOs has also been proposed as a biologically-inspired analog signal analyzer [24]. This form of analog signal analyzer subtracts the dynamic response of AOs from an input signal, which causes the array's frequency states to converge to the frequencies present in the input signal [25].
Considering these mentioned uses, an AO that is capable of learning additional states could be useful to many applications. In this paper, a four-state adaptive oscillator analog circuit that links theory discussed by [5] is presented. The resulting system provides the dynamics of 1) A two-state regular Hopf oscillator, 2) A three-state AO that can learn the frequency of an input sinusoid, and 3) A four-state AO that can learn the frequency and amplitude of an input sinusoid and extends the work of [1,2]. These schemes are similar to AOs that have previously improved phase-locked loop designs through Lyapunov treatments [26]. In this letter, we show a topology that extends the number of adaptive states previously implemented and show direct injection of a forcing signal. This AO is similar to the phase-locked loop Lyapunov design [26]; in the Lyapunov design, the forcing frequency needed to be directly inputted into the system. In the current AO, the forcing signal is injected directly into the x, ω, and α states without knowledge of the frequency. This is an important distinction, since the forcing signal, a sin(Ot + ϕ 0 ), is available, while the forcing frequency, O, might not be precisely known at a specific time.
In the following sections, a standard Hopf oscillator is described. Then, plastic states are progressively added to the Hopf equations by modifying the system dynamics as reported in [5,10]. This treatment results in 1) the addition of a fourth, plastic state and 2) three systems that inform circuit designs based on state variable networks. Government is authorized to reproduce and distribute reprints for Government purposes notwithstanding any copyright notation herein. The funder had no role in study design, data collection and analysis, decision to publish, or preparation of the manuscript. There was no additional external funding received for this study.

Competing interests:
The authors have declared that no competing interests exist.

Two-state system
The Hopf oscillator is a nonlinear oscillator described by the following ordinary differential equations (ODEs) [27]: Here, ω 0 is a resonance constant, μ is a constant that controls the limit cycle radius, and k is a coupling constant. The input signal is a sin(Ot + ϕ 0 ), where a is the amplitude of the sinusoid, O is the external forcing frequency, and ϕ 0 is the phase of the input sinusoid. This nonlinear oscillator is used as the building block for the subsequent adaptive oscillator systems. Since this system is not adaptive, the frequency-amplitude relationship has a single peak, as presented in Fig 5. 3 Three-state system The Hopf Adaptive Frequency Oscillator (HAFO) may learn the frequency of an external stimuli; this implies that the HAFO is a three-state nonlinear oscillator with dynamical plasticity. This synchronization process is appealing, as it does not need any pre-or post-processing.
Here, y is used to replace the term y ffi ffi ffi ffi ffi ffi ffi ffi that was proposed in [5]. If the constants in Eq 1 are chosen to create a stable limit cycle, this limit cycle will have a constant radius after the transient response decays. This modification simplifies the circuit implementation in a similar manner shown in [1]. Fig 1 compares the originally derived AFO in [5] with the simplifications imposed on Eq 2. After their transient response decays, the outputs of the two systems are qualitatively similar. With this modification, the complexity of the circuit implementation is highly reduced and the learning time of the ω state is decreased. The frequency information stored in the third state, ω, is achieved by the system's intrinsic dynamics. The first two ODEs are the classical form of the Hopf oscillator, and the third ODE allows for frequency adaptation. Input forcing causes the resulting HAFO output to increase or decrease in frequency based on a frequency difference referenced to the input signal. The three-state system's ODEs

PLOS ONE
are given as follows: It should be noted that the resonance constant, ω 0 , in Eq 1 has been replaced by the state, ω. By allowing the resonance frequency to be a state variable instead of a constant, the Hopf oscillator may now learn the external forcing frequency. It should also be noted that the external input signal is injected into both the x and the ω states.

Four-state system
By adding another state and modifying the equation for _ x to include xα in Eq 2, a four-state oscillator [10] can be created that learns the amplitude of the external signal in addition to frequency. It should be noted that the magnitude of α at steady state will deviate from the input amplitude when μ 6 ¼ 1. Detailed information concerning the derivation of these equations was reported in [5,28]; however, few circuit designs have been reported and little hardware verification exists in the literature. The four-state system's ODEs are given as follows: Here, η is a coupling constant. It should also be noted that the external input signal is injected into the x, ω, and α states. In the four-state system, Hebbian learning (i.e., subtracting xα from the external input signal) is used to enforce that ω and α converge to the external input signal.

Local analysis
To gain a better understanding of adaptive oscillators, a local analysis is performed on the Hopf adaptive frequency oscillator (Eq 2). For comparison, this local analysis will first be used on the classical Hopf oscillator (the two-state system represented by Eq 1). Removing the forcing term from this equation, the Jacobian may be written as: For the fixed point ðx; yÞ ¼0, Mathematica was used to find the eigenvalues of this system. The eigenvalues of J 1 are the conjugate pair, μ±ω 0 i. This is because the unforced Hopf oscillator given by Eq 1 with μ > 0 possesses a limit cycle with frequency ω 0 [27].
To perform this analysis for the three-state system, the forcing term, sin(Ot + ϕ 0 ), is replaced by an additional oscillator in order for the system of equations to be autonomous, as in [29]: The system represented by Eq 5 has a supercritical Andronov-Hopf bifurcation [30]. Replacing the forcing term in Eq 2, the following system of equations obtained: These equations are autonomous, and their Jacobian may be written as: where For the fixed point ðx; y; u; vÞ ¼0, the eigenvalues for the J 2 are 1 ± Oi, μ ± ωi, and 0. The conjugate pair 1 ± Oi corresponds to the forcing oscillator, with forcing frequency O. The conjugate pair μ ± ωi corresponds to the Hopf adaptive frequency oscillator; thus, the Hopf adaptive frequency oscillator oscillates with frequency equal to the third state, ω. The eigenvalue of 0 corresponds to the ω state. It is not stable or unstable, which allows this state to plastically deform to the forcing frequency.

Circuit design
A circuit implementation of the system described by Eq 3 was designed, fabricated, and tested. A complete, detailed schematic is shown in S1 Fig. For clarification, a simplified schematic is shown in Fig 2. Three potentiometers, annotated as RV1, RV2 and RV3, are set to 10kO, 12.5kO, 200kO, respectively. Additionally, the tunable resistance ranges of RV1, RV2 and RV3 are from 0O to 500kO. All unlabeled resistors are 1kO. The capacitors, labeled C1, C2, C3, and C4, have a capacitance of 0.1 μF. The experimental PCB is shown in Fig 3. This implementation was realized using TL082 opamps and AD633 multipliers in standard configurations with 0805 SMD passive components with 1% error tolerance for resistors and 2% error tolerance for capacitors. Three potentiometers were included to tune the coupling strengths associated with the first, third, and fourth states.
The dynamical system in Eq 3 was then mapped to Eq 7. This was done in a manner similar to that discussed in [31], where Kirchhoff's laws may be used to create a standard, voltagemode opamp integrator configuration paired with voltage multipliers. This also resembles the analog circuit implementations shown in [32]. where V P (t) = [a sin(Ot + ϕ 0 )) − xα] is an external stimulus.

PLOS ONE
Here, the states V x , V y , V ω , and V α correspond to the voltage outputs of opamp integrators. This methodology is similar to the realization of integrator-based state variable networks. By connecting the output pin headers of the α state to the ground, the four-state system can be transformed into the three-state system. This effectively sets the αx term in the _ x, _ o, and _ a equations to zero. By connecting the output pin headers of both the α state to the ground and the ω state to a constant, the four-state system can be transformed into a regular two-state Hopf oscillator. Therefore, the PCB can switch its functionality between a two-state, threestate, and four-state system. The PCB, whose dynamics is represented by Eq 7 was fabricated, and the experimental results from this PCB are depicted in Figs 4 and 5. All the external stimuli for the experimental results were generated with MATLAB and input to the PCB with a National Instruments (NI) cDAQ-9174. In Fig 5(a), the frequencyamplitude response of the two-state Hopf oscillator is shown. A frequency sweep was performed from 5 Hz to 210 Hz. The frequency-amplitude response from the SPICE simulations show qualitatively similar results with slightly different resonance frequency and corresponding magnitude. There is only one resonance peak near ω 0 (which is marked as a vertical dashed line) in the tested frequency range, since it is not an AO. In Fig 5(b), the frequency-amplitude response of the three-state system is shown. Instead of a single resonance, the three-state system maintains a large value over a wide range of frequencies. The percent error is calculated as � 100, where <ω> is the mean of the ω state at steady state. For the experiment, the error is less than 2% when the forcing frequency is between 19 Hz and 173 Hz. For the simulations, the percent error is less than 3% when the forcing frequency is between 20 Hz and 198 Hz. The frequency-amplitude relationship of the three-state oscillator matches closely with the percent error relationship (i.e., when the amplitude is high, the percent error is small).

Range of operation
In Fig 5(c), the frequency-amplitude response of the four-state system is shown. For the experiment, the percent error is less than 2.5% if the forcing frequency is between 25 Hz and 174 Hz. For the simulations, the percent error displays qualitatively similar behavior. In Fig 5  (d), the resulting α when sweeping the input amplitude from 0 to 7 for both the simulations and the experiment are shown. The experimental results show that the linear relationships between a and α is maintained until a > 3. A linear curve-fit was performed in MATLAB (for a < 3), and the slope of the line was 0.986 for the experiment. For the simulation, the linear relationship was maintained even outside this region, and the slope of the curve-fit was 1.018. Both the experiments and simulations have less than 2% error. It should be noted that the scalar parameter, μ, controls the amplitude of x at steady state, and a slight deviation of μ generated by the power supply from its expected value will cause an error between the experiment and the desired result. Additionally, the nonlinearity of the electrical components used in the simulations are not perfectly modeled, so the resulting differences inevitably occur in Fig 5.

Verification of other waveforms
After the initial testing to determine the range of operation of the experimental four-state adaptive oscillator system, the circuit was then tested using several complex waveforms. A signal generator was used to create a square wave and a sawtooth wave; the square wave was constructed so that the fundamental frequency changes over time. These signals are more complex than a simple sinusoidal wave, as they are composed of an infinite series of sinusoids. The results are shown in Figs 6 and 7.

PLOS ONE
Further, the voltage data from a strain gauge that was mounted to a nonlinear beam was used as an input to the adaptive oscillator circuit. By impacting the beam with a hammer, a vibratory system identification was performed to find the first natural frequency of the beam [33]. The results are shown in Fig 8. A vehicle's response to an asphaltophone was recorded with a microphone [34]. This recording had high amplitude low-frequency noise; the amplitudes of this noise were larger than the signal. In this recording, the asphaltophone was designed to reproduce a note of F3 (174.6141 Hz) when the vehicle is traveling 35 miles per hour. As the note is rather short, it was concatenated to create a longer signal. The low-frequency noise was filtered from the recording, and the filtered recording was input to the circuit. It should be noted that this example is the only time that filtering was used in this paper. The results are shown in Fig 9.

PLOS ONE
Last, a robotic player trumpet playing an A − 440 note (440 Hz) was recorded. This note was then rescaled in time to produce a 110 Hz note. Even though the trumpet's timbre has higher harmonics, the adaptive oscillator is still able to learn the fundamental frequency. The results are shown in Fig 10.

Conclusion
In this paper, an adaptive oscillator was designed, fabricated, and tested. SPICE simulations were compared to the experimental results. The results collected from the PCB show

PLOS ONE
qualitatively similar behavior to the adaptive oscillator's simulated equations. The four-state oscillator was shown to learn the forcing frequency successfully from approximately 25 Hz to 175 Hz within 3% error and input amplitudes from approximately 0 to 3 within 2% error. These experimental results were in close agreement with the SPICE simulation results. There are two types of nonlinearity in this paper. The nonlinearities of the ODEs are desired, and they cause the learning to happen. The circuit nonlinearities (e.g., parasitic elements, etc.) are not modeled, and these nonlinearities cause errors in the experimental results.
As demonstrated in Figs 6-10, this adaptive frequency oscillator is capable of learning more complex waveforms, in addition to simple sinusoids. As demonstrated in Fig 8, this oscillator is capable of reporting the first natural frequency of a mechanical system, without the need of a fast Fourier transform or other post-processing techniques. The implementation presented here could be used as an analog controller for walking robots, a circuit component of clock oscillators, an analog signal analyzer, or a component of a electromechanical energy harvester (such as that presented in [35]).
It should also be mentioned that other types of implementations of adaptive oscillators could be achieved. For example, adaptive oscillators could likely be implemented in a field programmable analog array, such as the implementation of a chaotic oscillator in [36]. The circuit presented in this paper is a prototype system that is a physical embodiment of Eq 3, which could be further refined for specific, practical applications.
It should be noted that this design may be scaled in frequency via the capacitors used in the integrator circuits. This scaling creates tuning possibilities for analog adaptive oscillators' frequency-learning range from tens of Hz to MHz. Expanding on the demonstrated capabilities, an array of these circuits could perform a wide range of signal processing capabilities for reallife hardware.
Supporting information S1 Fig. Full schematic of circuit. Full circuit schematic for the four-state adaptive system, with states V x , V y , V ω , and V α . And the DC power supply used here is +15 and −15 volts, in