I was playing around with oscillator this morning and I realised that we don’t actually have a method for making an oscillator at a desired frequency. For example, given this code:
import nengo
period = 0.5
with nengo.Network() as model:
osc = nengo.Network()
osc.config[nengo.Ensemble].neuron_type = nengo.LIFRate()
nengo.networks.Oscillator(0.1, 1/period, 300, net=osc)
bump = nengo.Node(lambda t: 1 if t < 0.1 else 0)
nengo.Connection(bump, osc.ensemble[0])
p_osc = nengo.Probe(osc.ensemble, synapse=0.01)
I don’t actually get an oscillator with a frequency of 2Hz, as shown below.
Consequently, is it possible to make a more accurate oscillator? I think one way would be to create a frequency controlled oscillator and decrease/increase the gain based off an error, but that feels a bit hacky. Is there some offline/analytical way to do this that avoids having to run the model twice?