07-12-2016 04:34 PM
Hi,
I have a Labview VI that uses "Analog 2D I16 Nchan Nsamps" DAQ function to acquire continously samples with an external sample clock and an external trigger.
I want to do this in python (using pyDAQmx).
I tried, configuring the timing and AIchannel just like in labview, but with AnalogReadF64 only it gives "ADC conversion attempted before the prior conversion was complete".
I've seen the ANSI C example "ContAcq-ExtClk-DigStart.c" that uses "RegisterEveryNSamplesEvent", but I want to be sure that I have to use it.
--> What is the equivalent of "Analog 2D I16 Nchan Nsamps" in pyDAQmx ? Is that with "RegisterEveryNSamplesEvent" or not ?
Many thanks,
Solved! Go to Solution.
07-13-2016 09:59 AM
Hi mp_INRS_1650,
You're on the right track. Overall, it looks like the DAQmxReadAnalogF64 is the pyDAQmx function with analogous functionality to a multiple channel, multiple sample read. I'm not sure exactly how pyDAQmx goes about buffered (multi-sample) acquisition, but this example from their site shows the basic architecture of a multiple channel acquisition:
https://pythonhosted.org/PyDAQmx/examples/multi_channel_analog_input.html
07-13-2016 11:01 AM - edited 07-13-2016 11:01 AM
Hi,
Thank you so much for your response.
So ReadAnalogF64 seems to be the equivalent ?
I've also seen the example of multichannel Analog Input Output in pyDAQmx
But even if I do have 2 channels, I am trying to make, for now, one channel work (1 channel, N sample).
But I have this error "ADC conversion attempted before the prior conversion was complete", which indicates that the query of the data in the buffer is going too fast, isn't it ?
Seems strange since I've just copied what my labview VI does...
07-13-2016 04:04 PM
The one/multiple channels is a hardware limitation. If you can make the measurement work with one analog input channel, awesome. If you have two sensors/daq devices you'll definitely have to use multiple channels in software to fully interpret the measurement.
That buffer error is interesting; it sounds like your buffer probably just isn't large enough, but it could also be that it is adequately sized and being queried too quickly. I would look into increasing your buffer size and see what happens. What is your sampling rate and current buffer size?
07-15-2016 03:28 PM
Hello Matt
My rate is 4e6, my buffer_size also. But increasing the buffer size does not solve the problem.
I've tried with RegisterEvery Nsamples, but it raises errors, especially because "DAQmx_Val_Acquired_Into_Buffer" stays at '1' I suppose.
Also, I'm not totally copying what the Labview code does : it sets the "Start.Delay" in DAQmx trigger to 5e-6 seconds (with an external AD clock), but when I try to do the same in my code I get the error : "Trigger delay is not available using an external AD clock". Why Labview can do it while I can't ?
Max
07-18-2016 10:40 AM
Could you look into using any of the examples in C that ship with LabVIEW? I can verify the functionality of those since they are actually written here at NI, but no problem if you are committed to coding in Python. As far as I can tell, PyDAQmx essentially enables you to call into the C .dlls using Python syntax. Can you get any of the other examples on the PyDAQmx site to run (e.g. Analog or Digital Output)?
Because this is a third-party add-on, it is not directly supported here and I can't speak to the uses of different functions in PyDAQmx. Give the other examples they provide a try and hopefully that will add to your understanding of how the functions work and interface with the ANSI C code that ships with NI software products.
07-18-2016 11:28 AM
Hello Matt,
I indeed inspired a lot from C examples.
I've just found out that I MUST NOT use "DAQmxCfgSampClkTiming" function, but rather set each properties separately :
using "DAQmxSetSampTimingType" for instance, etc.
And it worked.
So the answer of my original question : yes, ReadAnalogF64 can do the job of "Analog 2D I16 Nchan Nsamps"
Thank you very much for your help !