Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Changing reference voltage (PGA) of NI USB 6008 in Matl

Solved!
Go to solution

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

0 Kudos
Message 1 of 6
(3,888 Views)
Solution
Accepted by topic author Kia81

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

0 Kudos
Message 2 of 6
(3,873 Views)

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')

 

0 Kudos
Message 3 of 6
(3,851 Views)

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

0 Kudos
Message 4 of 6
(3,847 Views)

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]); 

 

 

0 Kudos
Message 5 of 6
(3,830 Views)

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

 

0 Kudos
Message 6 of 6
(3,463 Views)