1- # electronics.py ---
2- #
1+ # electronics.py ---
2+ #
33# Filename: electronics.py
4- # Description:
4+ # Description:
55# Author: Subhasis Ray
6- # Maintainer:
7- # Created: Wed Feb 22 00:53:38 2012 (+0530)
8- # Version:
9- # Last-Updated: Tue Jul 10 10:28:40 2012 (+0530)
10- # By: subha
11- # Update #: 221
12- # URL:
13- # Keywords:
14- # Compatibility:
15- #
16- #
6+ # Maintainer: Dilawar Singh
177
18- # Commentary:
19- #
20- #
21- #
22- #
23-
24- # Change log:
25- #
26- # 2012-02-22 23:22:30 (+0530) Subha - the circuitry put in a class.
27- #
28-
29- # Code:
30-
31- import numpy
8+ import numpy as np
329import moose
3310
34- class ClampCircuit (moose . Neutral ):
11+ class ClampCircuit (object ):
3512 """Container for a Voltage-Clamp/Current clamp circuit."""
13+
3614 defaults = {
3715 'level1' : 25.0 ,
3816 'width1' : 50.0 ,
@@ -41,48 +19,59 @@ class ClampCircuit(moose.Neutral):
4119 'trigMode' : 0 ,
4220 'delay3' : 1e9
4321 }
44- def __init__ (self , path , compartment ):
45- moose .Neutral .__init__ (self , path )
22+ def __init__ (self , path , squid ):
23+ self .path = path
24+ moose .Neutral (path )
4625 self .pulsegen = moose .PulseGen (path + "/pulse" ) # holding voltage/current generator
4726 self .pulsegen .count = 2
4827 self .pulsegen .firstLevel = 25.0
4928 self .pulsegen .firstWidth = 50.0
5029 self .pulsegen .firstDelay = 2.0
5130 self .pulsegen .secondDelay = 0.0
5231 self .pulsegen .trigMode = 2
53- self .gate = moose .PulseGen (path + "/gate" ) # holding voltage/current generator
32+ self .gate = moose .PulseGen (path + "/gate" ) # holding voltage/current generator
5433 self .gate .level [0 ] = 1.0
5534 self .gate .delay [0 ] = 0.0
5635 self .gate .width [0 ] = 1e9
57- moose .connect (self .gate , ' output' , self .pulsegen , ' input' )
58- self .lowpass = moose .RC (path + "/lowpass" ) # lowpass filter
36+ moose .connect (self .gate , " output" , self .pulsegen , " input" )
37+ self .lowpass = moose .RC (path + "/lowpass" ) # lowpass filter
5938 self .lowpass .R = 1.0
6039 self .lowpass .C = 0.03
61- self .vclamp = moose .DiffAmp (path + "/vclamp" )
40+ self .vclamp = moose .DiffAmp (path + "/vclamp" )
6241 self .vclamp .gain = 0.0
6342 self .vclamp .saturation = 1e10
64- self .iclamp = moose .DiffAmp (path + "/iclamp" )
43+ self .iclamp = moose .DiffAmp (path + "/iclamp" )
6544 self .iclamp .gain = 0.0
6645 self .iclamp .saturation = 1e10
67- self .pid = moose .PIDController (path + "/pid" )
46+ self .pid = moose .PIDController (path + "/pid" )
6847 self .pid .gain = 0.5
6948 self .pid .tauI = 0.02
7049 self .pid .tauD = 0.005
7150 self .pid .saturation = 1e10
7251 # Connect current clamp circuitry
7352 moose .connect (self .pulsegen , "output" , self .iclamp , "plusIn" )
74- moose .connect (self .iclamp , "output" , compartment , "injectMsg" )
53+ moose .connect (self .iclamp , "output" , squid . C , "injectMsg" )
7554 # Connect voltage clamp circuitry
7655 moose .connect (self .pulsegen , "output" , self .lowpass , "injectIn" )
7756 moose .connect (self .lowpass , "output" , self .vclamp , "plusIn" )
7857 moose .connect (self .vclamp , "output" , self .pid , "commandIn" )
79- moose .connect (compartment , "VmOut" , self .pid , "sensedIn" )
80- moose .connect (self .pid , "output" , compartment , "injectMsg" )
58+ moose .connect (squid . C , "VmOut" , self .pid , "sensedIn" )
59+ moose .connect (self .pid , "output" , squid . C , "injectMsg" )
8160 current_table = moose .Table ("/data/Im" )
82- moose .connect (current_table , "requestOut" , compartment , "getIm" )
61+ moose .connect (current_table , "requestOut" , squid . C , "getIm" )
8362
84- def configure_pulses (self , baseLevel = 0.0 , firstLevel = 0.1 , firstDelay = 5.0 , firstWidth = 40.0 , secondLevel = 0.0 , secondDelay = 1e6 , secondWidth = 0.0 , singlePulse = True ):
85- """Set up the pulse generator."""
63+ def configure_pulses (
64+ self ,
65+ baseLevel = 0.0 ,
66+ firstLevel = 0.1 ,
67+ firstDelay = 5.0 ,
68+ firstWidth = 40.0 ,
69+ secondLevel = 0.0 ,
70+ secondDelay = 1e6 ,
71+ secondWidth = 0.0 ,
72+ singlePulse = True ,
73+ ):
74+ """Set up the pulse generator."""
8675 self .pulsegen .baseLevel = baseLevel
8776 self .pulsegen .firstLevel = firstLevel
8877 self .pulsegen .firstWidth = firstWidth
@@ -91,10 +80,10 @@ def configure_pulses(self, baseLevel=0.0, firstLevel=0.1, firstDelay=5.0, firstW
9180 self .pulsegen .secondDelay = secondDelay
9281 self .pulsegen .secondWidth = secondWidth
9382 if singlePulse :
94- self .pulsegen .trigMode = 1
83+ self .pulsegen .trigMode = 1
9584 else :
9685 self .pulsegen .trigMode = 0
97-
86+
9887 def do_voltage_clamp (self ):
9988 """Switch to voltage clamp circuitry. After this the simdt may
10089 need to be changed for correct performance."""
@@ -103,14 +92,10 @@ def do_voltage_clamp(self):
10392 self .pid .gain = 0.5
10493 self .pid .tauD = 0.005
10594 self .pid .tauI = 0.02
106-
95+
10796 def do_current_clamp (self ):
10897 """Switch to current clamp circuitry. After this the simdt may
10998 need to be changed for correct performance."""
11099 self .iclamp .gain = 1.0
111100 self .vclamp .gain = 0.0
112101 self .pid .gain = 0.0
113-
114-
115- #
116- # electronics.py ends here
0 commit comments