03-24-2011 10:08 AM - edited 03-24-2011 10:15 AM
Hi,
i am looking for solution to change the reference voltage of Ni usb6008 in MATLAB.
Refering to the manual, the reference voltage can be changed by setting PGA (progammable-gain amplifier).There is a short description in the manual, which cann't help me ("The PGA gainis automatically calculated based on the voltage range selected in the measurement application.)
Does anybody know, how can I change the PGA in MATLAB?
Input Voltage Range is set to [-10 10] and i want to change it to [-1 1] to have a better resolution for small voltage. The InputType is differential
Solved! Go to Solution.
03-25-2011 09:17 AM
Hi Kia
you can change the reference voltage by adding following function to your C code:
int32 DAQmxCreateAIVoltageChan (TaskHandle taskHandle, const char physicalChannel[], const char nameToAssignToChannel[], int32 terminalConfig, float64 minVal, float64 maxVal, int32 units, const char customScaleName[]);
With the parameters minVal and maxVal you can set your voltage manually.
Of course I am available for further callbacks.
Best regards
Stefan
03-26-2011 05:04 AM
Hi Stefan,
thank you very much for your nice answer. Well i can test your code Monday when i am back in my office agian.
i am not a Matlab professional user and i would like to ask you if i can put your code in a m-file or does it just work in a C-code? because i am using m-files (m -script, see below) to read data from usb6008
if (~isempty(daqfind))
stop(daqfind)
end
duration = 1; %1 second acquisition
RptNr=0;
AI = analoginput('nidaq','Dev1');
chan = addchannel(AI,0);
set(AI,'SampleRate',10000)
set(AI,'InputType','Differential');
ActualRate = get(AI,'SampleRate');
set(AI,'SamplesPerTrigger',duration*ActualRate)
Delay=ActualRate*-2e-2;
set(AI,'Timeout',5)
set(AI,'TriggerChannel',chan)
set(AI,'TriggerType','Software')
set(AI,'TriggerCondition','Rising')
set(AI,'TriggerConditionValue',0.01)
set(AI,'TriggerDelay',Delay)
set(AI,'TriggerRepeat',RptNr)
set(AI,'TriggerDelayUnits','Samples')
03-26-2011 05:58 AM
hi Kia
yes it is possible including c-functions to your m-file with the help of a mex-function. look for mex-functions in the matlab-help.
look also for examples in the help. there are some instructions how to build a mex-file.
i hope i could help you.
best regards
stefan
03-28-2011 05:33 AM
hi Stefan,
thank you for your answer,
i found a easier way to set the reference voltage by adding following line in my matlab skript
set(AI.Channel,'InputRange',[minValue maxValue]);
03-31-2014 11:09 AM
Hi, your suggested method did not work with me.
Can any one provide a ,m file for matlab where the DAQ NI-6008 can be selected?
If so I really appreciate it.
Regrads to all