Can I set a session parameter to a variable?

I have a tank of fluid of which I would like to control the temperature. I read a temperature from a thermocouple through a background analog input channel.
inputSession = daq.createSession('ni');
inputSession.DurationInSeconds = 1;
inputSession.Rate = 2;
inputSession.IsContinuous = 1;
inputSession.NotifyWhenDataAvailableExceeds = 2;
slot1 = addAnalogInputChannel(inputSession,'cDAQ3Mod1',0,'Thermocouple');
slot1(1).ThermocoupleType = 'T';
lh = addlistener(inputSession,'DataAvailable',@listenerFunction);
startBackground(inputSession);
The temperature can be controlled by sending a PWM signal to a heater. I control the heater by adjusting the 'DutyCycle' of a background counter output channel.
ctrSession = daq.createSession('ni');
ctrSession.IsContinuous = 1;
slot2 = addCounterOutputChannel(ctrSession,'cDAQ3Mod2',0,'PulseGeneration');
slot2.Frequency = 1;
ctrSession.Channels(1).DutyCycle = 0.2;
startBackground(ctrSession);
I would like to dynamically update the duty cycle of the background counter channel. I do this by performing calculations in the @listenerFunction. I also plot the temperature on a set of axes using the same @listenerFunction. When I try to update the the duty cycle directly from the @listenerFunction it causes terrible lag in the plot function.
Is there any way for me to set the duty cycle parameter of the channel to a variable (global or not)?
Thanks!

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Data Acquisition Toolbox 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by