def Vclam(delay, width, delay_2, r, c, gain, sat, gain_p, tau_1, tau_2, psat): pulseg = moose.PulseGen('pulse') pulseg.firstDelay = delay pulseg.firstWidth = width pulseg.secondDelay = delay_2 lp = moose.RC('lowpass') lp.R = r lp.C = c DA = moose.DiffAmp('diffamp') DA.gain = gain DA.saturation = sat pid = moose.PIDController('PID') pid.gain = gain_p pid.tauI = tau_1 pid.tauD = tau_2 pid.saturation = psat comp = moose.element("/proto") moose.connect(pulseg, "output", lp, "injectIn") moose.connect(lp, "output", DA, "plusIn") moose.connect(DA, "output", pid, "commandIn") moose.connect(comp, "VmOut", pid, "sensedIn") moose.connect(pid, "output", comp, "injectMsg") tab = moose.Table("/data/Im") moose.connect(tab, "requestOut", comp, "getIm") return tab
def setup_electronics(model_container, data_container, compartment): """Setup voltage and current clamp circuit using DiffAmp and PID and RC filter""" command = moose.PulseGen('%s/command' % (model_container.path)) command.delay[0] = 20e-3 command.width[0] = 50e-3 command.level[0] = 100e-9 command.delay[1] = 1e9 lowpass = moose.RC('%s/lowpass' % (model_container.path)) lowpass.R = 1.0 lowpass.C = 5e-4 vclamp = moose.DiffAmp('%s/vclamp' % (model_container.path)) vclamp.saturation = 1e10 iclamp = moose.DiffAmp('%s/iclamp' % (model_container.path)) iclamp.gain = 0.0 iclamp.saturation = 1e10 pid = moose.PIDController('%s/pid' % (model_container.path)) pid.gain = compartment.Cm / 100e-6 # Cm/dt is a good number for gain pid.tauI = 100e-6 # same as dt pid.tauD = 0.0 pid.saturation = 1e10 # Current clamp circuit: connect command output to iclamp amplifier # and the output of the amplifier to compartment. moose.connect(command, 'output', iclamp, 'plusIn') moose.connect(iclamp, 'output', compartment, 'injectMsg') # Setup voltage clamp circuit: # 1. Connect command output (which is now command) to lowpass # filter. # 2. Connect lowpass output to vclamp amplifier. # 3. Connect amplifier output to PID's command input. # 4. Connect Vm of compartment to PID's sensed input. # 5. Connect PID output to compartment's injectMsg. moose.connect(command, 'output', lowpass, 'injectIn') moose.connect(lowpass, 'output', vclamp, 'plusIn') moose.connect(vclamp, 'output', pid, 'commandIn') moose.connect(compartment, 'VmOut', pid, 'sensedIn') moose.connect(pid, 'output', compartment, 'injectMsg') command_table = moose.Table('%s/command' % (data_container.path)) moose.connect(command_table, 'requestOut', command, 'getOutputValue') inject_table = moose.Table('%s/inject' % (data_container.path)) moose.connect(inject_table, 'requestOut', compartment, 'getIm') return { 'command_tab': command_table, 'inject_tab': inject_table, 'iclamp': iclamp, 'vclamp': vclamp, 'pid': pid, 'command': command }
def setup_vclamp(compartment, name, delay1, width1, level1, gain=0.5e-5): """ Sets up a voltage clamp with 'name' on MOOSE 'compartment' object: adapted from squid.g in DEMOS (moose/genesis) Specify the 'delay1', 'width1' and 'level1' of the voltage to be applied to the compartment. Typically you need to adjust the PID 'gain' For perhaps the Davison 4-compartment mitral or the Davison granule: 0.5e-5 optimal gain - too high 0.5e-4 drives it to oscillate at high frequency, too low 0.5e-6 makes it have an initial overshoot (due to Na channels?) Returns a MOOSE table with the PID output. """ ## If /elec doesn't exists it creates /elec and returns a reference to it. ## If it does, it just returns its reference. moose.Neutral("/elec") pulsegen = moose.PulseGen("/elec/pulsegen" + name) vclamp = moose.DiffAmp("/elec/vclamp" + name) vclamp.saturation = 999.0 vclamp.gain = 1.0 lowpass = moose.RC("/elec/lowpass" + name) lowpass.R = 1.0 lowpass.C = 50e-6 # 50 microseconds tau PID = moose.PIDController("/elec/PID" + name) PID.gain = gain PID.tau_i = 20e-6 PID.tau_d = 5e-6 PID.saturation = 999.0 # All connections should be written as source.connect('',destination,'') pulsegen.connect("outputSrc", lowpass, "injectMsg") lowpass.connect("outputSrc", vclamp, "plusDest") vclamp.connect("outputSrc", PID, "commandDest") PID.connect("outputSrc", compartment, "injectMsg") compartment.connect("VmSrc", PID, "sensedDest") pulsegen.trigMode = 0 # free run pulsegen.baseLevel = -70e-3 pulsegen.firstDelay = delay1 pulsegen.firstWidth = width1 pulsegen.firstLevel = level1 pulsegen.secondDelay = 1e6 pulsegen.secondLevel = -70e-3 pulsegen.secondWidth = 0.0 vclamp_I = moose.Table("/elec/vClampITable" + name) vclamp_I.stepMode = TAB_BUF # TAB_BUF: table acts as a buffer. vclamp_I.connect("inputRequest", PID, "output") vclamp_I.useClock(PLOTCLOCK) return vclamp_I
def __init__(self, path): moose.Neutral.__init__(self, path) ''' self.pulsegen = moose.PulseGen(path+"/pulse") # holding voltage/current generator self.pulsegen.count = 2 self.pulsegen.baseLevel = -65.0e-3 self.pulsegen.firstLevel = -40.0e-3 self.pulsegen.firstWidth = 50.0e-3 self.pulsegen.firstDelay = 2.0e-3 self.pulsegen.secondDelay = 0.0 self.pulsegen.trigMode = 2 self.gate = moose.PulseGen(path+"/gate") # holding voltage/current generator self.gate.level[0] = 1.0 self.gate.delay[0] = 0.0 self.gate.width[0] = 1e3 moose.connect(self.gate, 'output', self.pulsegen, 'input') ''' self.lowpass = moose.RC(path + "/lowpass") # lowpass filter self.lowpass.R = 1.0 self.lowpass.C = 0.03 self.vclamp = moose.DiffAmp(path + "/vclamp") self.vclamp.gain = 1.0 self.vclamp.saturation = 1e10 self.iclamp = moose.DiffAmp(path + "/iclamp") self.iclamp.gain = 0.0 self.iclamp.saturation = 1e10 self.pid = moose.PIDController(path + "/pid") self.pid.gain = 0.5 self.pid.tauI = 0.02e-3 self.pid.tauD = 0.005e-3 self.pid.saturation = 1e7 # Connect voltage clamp circuitry #moose.connect(self.pulsegen, "output", self.lowpass, "injectIn") moose.connect(self.lowpass, "output", self.vclamp, "plusIn") moose.connect(self.vclamp, "output", self.pid, "commandIn") #moose.connect(compartment, "VmOut", self.pid, "sensedIn") #moose.connect(self.pid, "output", compartment, "injectMsg") addmsg1 = moose.Mstring(path + '/addmsg1') addmsg1.value = './pid output .. injectMsg' addmsg2 = moose.Mstring(path + '/addmsg2') addmsg2.value = '.. VmOut ./pid sensedIn'
def __init__(self, path, squid): self.path = path moose.Neutral(path) self.pulsegen = moose.PulseGen(path+"/pulse") # holding voltage/current generator self.pulsegen.count = 2 self.pulsegen.firstLevel = 25.0 self.pulsegen.firstWidth = 50.0 self.pulsegen.firstDelay = 2.0 self.pulsegen.secondDelay = 0.0 self.pulsegen.trigMode = 2 self.gate = moose.PulseGen(path + "/gate") # holding voltage/current generator self.gate.level[0] = 1.0 self.gate.delay[0] = 0.0 self.gate.width[0] = 1e9 moose.connect(self.gate, "output", self.pulsegen, "input") self.lowpass = moose.RC(path + "/lowpass") # lowpass filter self.lowpass.R = 1.0 self.lowpass.C = 0.03 self.vclamp = moose.DiffAmp(path + "/vclamp") self.vclamp.gain = 0.0 self.vclamp.saturation = 1e10 self.iclamp = moose.DiffAmp(path + "/iclamp") self.iclamp.gain = 0.0 self.iclamp.saturation = 1e10 self.pid = moose.PIDController(path + "/pid") self.pid.gain = 0.5 self.pid.tauI = 0.02 self.pid.tauD = 0.005 self.pid.saturation = 1e10 # Connect current clamp circuitry moose.connect(self.pulsegen, "output", self.iclamp, "plusIn") moose.connect(self.iclamp, "output", squid.C, "injectMsg") # Connect voltage clamp circuitry moose.connect(self.pulsegen, "output", self.lowpass, "injectIn") moose.connect(self.lowpass, "output", self.vclamp, "plusIn") moose.connect(self.vclamp, "output", self.pid, "commandIn") moose.connect(squid.C, "VmOut", self.pid, "sensedIn") moose.connect(self.pid, "output", squid.C, "injectMsg") current_table = moose.Table("/data/Im") moose.connect(current_table, "requestOut", squid.C, "getIm")