Skip to content

Commit ff068b4

Browse files
committed
Now using mV and pA instead of V and A to avoid integer overflows.
1 parent f0c6a0c commit ff068b4

File tree

5 files changed

+39
-17
lines changed

5 files changed

+39
-17
lines changed

Rig Configurations/EPhys2PhotonRig.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
function createDevices(obj)
1616
obj.addMultiClampDevice('Amplifier_Ch1', 1, 'ANALOG_OUT.0', 'ANALOG_IN.0');
17-
obj.addDevice('LED', 'ANALOG_OUT.1', 'ANALOG_IN.1'); % added analog in1 for LED 11/22/2011 GG
17+
obj.addDevice('LED', 'ANALOG_OUT.1', 'ANALOG_IN.1', 'mV'); % added analog in1 for LED 11/22/2011 GG
1818
end
1919

2020
end

Rig Configurations/EPhys2PhotonStimGLRig.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414

1515
function createDevices(obj)
1616
obj.addMultiClampDevice('Amplifier_Ch1', 1, 'ANALOG_OUT.0', 'ANALOG_IN.0');
17-
obj.addDevice('LED', 'ANALOG_OUT.1', ''); % output only
17+
obj.addDevice('LED', 'ANALOG_OUT.1', '', 'mV'); % output only
1818

1919
% Add the optical sensor. (input only)
20-
obj.addDevice('Photodiode', '', 'ANALOG_IN.1');
20+
obj.addDevice('Photodiode', '', 'ANALOG_IN.1', 'mV');
2121
end
2222

2323
end

Rig Configurations/EPhysRig.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
function createDevices(obj)
1616
obj.addMultiClampDevice('Amplifier_Ch1', 1, 'ANALOG_OUT.0', 'ANALOG_IN.0');
17-
obj.addDevice('LED', 'ANALOG_OUT.1', ''); % output only
17+
obj.addDevice('LED', 'ANALOG_OUT.1', '', 'mV'); % output only
1818
end
1919

2020
end

Rig Configurations/StimGLRig.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function createDevices(obj)
1717
obj.addMultiClampDevice('Amplifier_Ch1', 1, 'ANALOG_OUT.0', 'ANALOG_IN.0');
1818

1919
% Add the optical sensor. (input only)
20-
obj.addDevice('Photodiode', '', 'ANALOG_IN.1');
20+
obj.addDevice('Photodiode', '', 'ANALOG_IN.1', 'mV');
2121
end
2222

2323
end

RigConfiguration.m

+34-12
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,10 @@
6565

6666
function daq = createDAQ(obj)
6767
% Create a Heka DAQ controller if on Windows or a simulation controller on Mac.
68+
6869
import Symphony.Core.*;
6970

70-
import Heka.*;
71-
72-
if ~isempty(which('HekaDAQInputStream'))
71+
try
7372
import Heka.*;
7473

7574
% Register the unit converters
@@ -93,19 +92,42 @@
9392

9493
daq = HekaDAQController(hekaID, 0);
9594
daq.InitHardware();
96-
else
95+
catch ME
96+
daq = [];
97+
disp(['Could not load the Heka driver: ' ME.message]);
98+
end
99+
100+
if isempty(daq)
97101
import Symphony.SimulationDAQController.*;
98102

99-
disp('Could not load the Heka driver, using the simulation controller instead.');
100-
101-
Converters.Register('V', 'V', @(m) m);
103+
disp('Using the simulation controller instead.');
102104
daq = SimulationDAQController();
103105
daq.BeginSetup();
104106

105107
daq.SimulationRunner = Simulation(@(output,step) loopbackSimulation(obj, output, step, outStream, inStream));
106108
end
107109

108110
daq.Clock = daq;
111+
112+
% Make sure the unit conversions we need are available.
113+
if ~Converters.Test('V', 'V')
114+
Converters.Register('V', 'V', @(m) m);
115+
end
116+
if ~Converters.Test('mV', 'V')
117+
Converters.Register('mV', 'V', @(m) m * 1e-3);
118+
end
119+
if ~Converters.Test('V', 'mV')
120+
Converters.Register('V', 'mV', @(m) m * 1e3);
121+
end
122+
if ~Converters.Test('A', 'A')
123+
Converters.Register('A', 'A', @(m) m);
124+
end
125+
if ~Converters.Test('pA', 'A')
126+
Converters.Register('pA', 'A', @(m) m * 1e-12);
127+
end
128+
if ~Converters.Test('A', 'pA')
129+
Converters.Register('A', 'pA', @(m) m * 1e12);
130+
end
109131
end
110132

111133

@@ -193,15 +215,15 @@ function addStreams(obj, device, outStreamName, inStreamName)
193215
end
194216

195217

196-
function addDevice(obj, deviceName, outStreamName, inStreamName)
218+
function addDevice(obj, deviceName, outStreamName, inStreamName, units)
197219
import Symphony.Core.*;
198220
import Symphony.ExternalDevices.*;
199221

200222
if isa(obj.controller.DAQController, 'Heka.HekaDAQController') && strncmp(outStreamName, 'DIGITAL_OUT', 11)
201223
% The digital out channels for the Heka ITC share a single device.
202224
if isempty(obj.hekaDigitalOutDevice)
203-
obj.hekaDigitalOutDevice = UnitConvertingExternalDevice('Heka Digital Out', 'HEKA Instruments', obj.controller, Measurement(0, 'V'));
204-
obj.hekaDigitalOutDevice.MeasurementConversionTarget = 'V';
225+
obj.hekaDigitalOutDevice = UnitConvertingExternalDevice('Heka Digital Out', 'HEKA Instruments', obj.controller, Measurement(0, units));
226+
obj.hekaDigitalOutDevice.MeasurementConversionTarget = units;
205227
obj.hekaDigitalOutDevice.Clock = obj.controller.DAQController;
206228

207229
stream = obj.streamWithName('DIGITAL_OUT.1', true);
@@ -212,8 +234,8 @@ function addDevice(obj, deviceName, outStreamName, inStreamName)
212234
obj.hekaDigitalOutNames{end + 1} = deviceName;
213235
obj.hekaDigitalOutChannels(end + 1) = str2double(outStreamName(end));
214236
else
215-
dev = UnitConvertingExternalDevice(deviceName, 'unknown', obj.controller, Measurement(0, 'V'));
216-
dev.MeasurementConversionTarget = 'V';
237+
dev = UnitConvertingExternalDevice(deviceName, 'unknown', obj.controller, Measurement(0, units));
238+
dev.MeasurementConversionTarget = units;
217239
dev.Clock = obj.controller.DAQController;
218240

219241
obj.addStreams(dev, outStreamName, inStreamName);

0 commit comments

Comments
 (0)