Skip to content

Commit f80ddff

Browse files
committed
Fixed simulation of noise for digital channels
1 parent 04f28b2 commit f80ddff

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/main/matlab/+symphonyui/+builtin/+daqs/HekaSimulationDaqController.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@
9595
% If there was no corresponding output, simulate noise.
9696
if isempty(inData)
9797
samples = Symphony.Core.TimeSpanExtensions.Samples(timeStep, inStream.SampleRate);
98-
noise = Measurement.FromArray(rand(1, samples) - 0.5, 'mV');
98+
if strncmp(char(inStream.Name), 'DIGITAL', 7)
99+
noise = Measurement.FromArray(randi(2^16-1, 1, samples), inStream.MeasurementConversionTarget);
100+
else
101+
noise = Measurement.FromArray(rand(1, samples) - 0.5, inStream.MeasurementConversionTarget);
102+
end
99103
inData = InputData(noise, inStream.SampleRate, obj.cobj.Clock.Now);
100104
end
101105

src/main/matlab/+symphonyui/+builtin/+daqs/NiSimulationDaqController.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
while outStreamEnum.MoveNext()
8686
outStream = outStreamEnum.Current;
8787

88-
if strcmp(char(outStream.Name), strrep(char(inStream.Name), 'i', 'o'))
88+
if strcmp(char(outStream.Name), strrep(char(inStream.Name), 'ai', 'ao')) || strcmp(char(outStream.Name), strrep(char(inStream.Name), 'di', 'do'))
8989
outData = output.Item(outStream);
9090
inData = InputData(outData.Data, outData.SampleRate, obj.cobj.Clock.Now);
9191
break;
@@ -95,7 +95,11 @@
9595
% If there was no corresponding output, simulate noise.
9696
if isempty(inData)
9797
samples = Symphony.Core.TimeSpanExtensions.Samples(timeStep, inStream.SampleRate);
98-
noise = Measurement.FromArray(rand(1, samples) - 0.5, 'mV');
98+
if strncmp(char(inStream.Name), 'diport', 6)
99+
noise = Measurement.FromArray(randi(2^16-1, 1, samples), inStream.MeasurementConversionTarget);
100+
else
101+
noise = Measurement.FromArray(rand(1, samples) - 0.5, inStream.MeasurementConversionTarget);
102+
end
99103
inData = InputData(noise, inStream.SampleRate, obj.cobj.Clock.Now);
100104
end
101105

0 commit comments

Comments
 (0)