09-13-2012 02:50 PM
(Windows XP, LabWindows/CVI 10, PCIe-6361).
I set up a DAQmx data acquisition task in MAX, with the voltage range set for each channel, but the user wants the option to change the voltage range in the program. So I put in:
//some stuff
x = new max or min value
bMax = 1 if setting Max, 0 if setting Min.
//stop task
status = DAQmxStopTask (Level1_Task_p->DAQTask_Handle);
//update value
status = DAQmxSetChanAttribute (Level1_Task_p->DAQTask_Handle,
ChannelInfo[channel].ChannelName,
(bMax) ? DAQmx_AI_Max : DAQmx_AI_Min,
x,
1);
//confirm value
status = DAQmxGetChanAttribute (Level1_Task_p->DAQTask_Handle,
ChannelInfo[channel].ChannelName,
(bMax) ? DAQmx_AI_Max : DAQmx_AI_Min,
&x,
1);
//some other stuff
......
//restart task
status = DAQmxStartTask (Level1_Task_p->DAQTask_Handle);
It stops the task, sets the max or min value of the channel (you can only set one at at a time) to the value of "x", confirms the coerced value by reading it back, and restarts the task.
The problem is that it can only set the voltage range heigher, never lower. I have the max and min nominally set to +5 and -5 V. If I enter 10 for the value, it reads back as 10. If I then set it to 1, it reads back as 10. Any ideas would be appreciated.
09-14-2012 05:26 PM
Hi pblase,
You should be able to achieve this functionality by clearing the task and creating a new task with the new amplifier settings and starting that task. This would be a solution as long as the amplifier settings are not being changed very quickly, like in this case when the user decides to change the amplification setting manually.