11-23-2017 10:46 AM
Hello,
I am using PXI 4462. The name of my channel is 'Dev1/ai0'.
I do know by default the following program reads the data with DC coupling(Just for testing, I use the signal generator to give voltage input to channel Dev1/ai0 using different DC offsets). But for my applications I would like to read this data with AC coupling for this channel:Dev1/ai0.
I have gone through the documentation of nidaqmx python package which says about nidaqmx.constants.Coupling such as Coupling.AC=10045;Coupling.DC=10050,Coupling.GND=10066. But apparently I could not succeed in implementing it in my code.
How and where can I say/input this information in my code.
The code is as follows:
with nidaqmx.Task() as task:
task.ai_channels.add_ai_voltage_chan('Dev1/ai0')
task.timing.cfg_samp_clk_timing(Samples_Per_Sec=50000, source="", active_edge=Edge.RISING,sample_mode=AcquisitionType.FINITE,
samps_per_chan=50000)
data=task.read(samps_per_chan=50000)
Thank You.
Solved! Go to Solution.
11-27-2017 04:43 PM
Hi Swapnil,
What commands have you tried?
Have you tried something like this?
Task.ai_channel.ai_coupling = nidaqmx.constants.Coupling.AC
11-28-2017 01:52 PM
Hi Jacob,
Thanks for your inputs.
I did try using AIChannel like,
AIChannel.ai_coupling = nidaqmx.constants.Coupling.AC (But, it did not work)
The alternative that you have proposed did not work for me(I get an attribute error).
By the way, I believe in your answer you mean to say 'task.ai_channel.ai_coupling' and not 'Task.ai_channel.ai_coupling''.
After going through the documentation of nidaqmx and also the source code I do not see 'ai_channel' attribute in Task (and so the attribute error is justifiable).
Swapnil
11-29-2017 03:04 PM
Swapnil,
Sorry I did mean task not Task. I did some more digging and I think this might work:
with nidaqmx.Task() as task:
chan = task.ai_channels.add_ai_voltage_chan("4462/ai0")
chan.ai_coupling = constants.Coupling.AC
data = task.read()
print(data)
Let me know if this works for you.
Thanks!
12-01-2017 04:13 AM
Hi Jacob,
The solution suggested by you "chan" works perfectly fine for me.
I think I was making mistake for using the right syntax, to assign properties defined in a specific 'class' in python.
Thanks again for your help.
Swapnil