Controlled OscillatorΒΆ

Purpose: This demo implements a controlled two-dimensional oscillator.

Comments: This is functionally the analogous to the controlled integrator, but in a 2-D space. The available slider allows the frequency to be directly controlled, to be negative or positive. This behavior maps directly to the differential equation used to describe a simple harmonic oscillator (i.e. \dot{x}(t) = Ax(t) + Bu(t) where A = [0 freq; -freq, 0]). The control in this circuit changes the freq variable in that equation.

Usage: When you run this demo, it will automatically put in a step function on the input to start the oscillator moving. You can see where it is in phase space in the XY plot (if you want to see that over time, right-click on the Oscillator population and select X->value). You can change the frequency of rotation by moving the visible slider. Positive values rotate clockwise and negative values counter-clockwise.

Output: See the screen capture below

import nef

speed=10  #Base frequency of oscillation
tau=0.1   #Recurrent time constant

net = nef.Network('Controlled Oscillator')

#Make controllable inputs
net.make_input('Start', [1,0], zero_after_time=0.15) #Kick it to get it going
net.make_input('Speed', [1]) #Control the speed interactively

#Make two populations, one for freq control, and one the oscillator
net.make('Oscillator', 500, 3, radius=1.7)
net.make('SpeedNeurons', 100, 1)

#Connect the elements of the network
net.connect('Start', 'Oscillator', index_post=[0,1])
net.connect('Speed', 'SpeedNeurons')
net.connect('SpeedNeurons', 'Oscillator', index_post=[2])

#Define the nonlinear interactions in the state space of the oscillator
def controlled_path(x):
    return x[0]+x[2]*speed*tau*x[1], x[1]-x[2]*speed*tau*x[0], 0
net.connect('Oscillator', 'Oscillator', func=controlled_path, pstc=tau)


Nengo User Manual

Table Of Contents

This Page