03-18-2020 03:38 AM
Hi guys,
i am using cDAQ 9189 and want to measure voltage and current (to calculate the electric work) on different electric motors. I made a VI using NI 9225 and NI 9227 and it seems to be working (VI_01.vi). But i need to add motors and don't have another NI 9225. So i am forced to use NI 9219, which only can do 50 S/s.
So I am going to have two different rates for voltage and current (1613 Hz and 50 Hz), but i need have the same amout of samples synchronised in time.
Question: What can I do? My idea is to divide 1613 with 32 and build an average of those 32 samples and build an average, but is this physically correct? I am not sure...
Or is there any elegant solution how to do that?
Thank you very much for your help!
Jani
Solved! Go to Solution.
03-18-2020 04:13 AM
Could you just sample both at 50Hz? Skim reading the manual my understanding is that the 9219 is a 100S/s/chan module so you could sample at 100Hz.
Your way of averaging the samples from the faster module would work and would give you more accurate measurements for that module at the expense of slightly more complicated code. I suspect that this is happening in the hardware filter of the 9219 anyway. Don't quote me on that as others are much more knowledgeable on the hardware side of NI than me.
Either way I suggest you share the sample clock between the two modules otherwise they will be timed by their own individual clocks and you will get drift between the two cards. This will especially be an issue if you intend to continue reading the samples from all cards in the same loop as eventually you are likely to get a buffer overflow on one of the cards.
You have to specify this manualy, see below.
Another comment on your code. Look up producer consumer design patterns. I would strongly recommend that you only read the samples in your data acquisition loop and ship all the data to a consumer loop via a queue. At the moment you are risking your data processing and file management taking too long and causing a buffer overflow.
03-18-2020 04:58 AM
Hi Jani,
as your module doesn't support you cannot follow Niatross' suggestion.
But you can set your faster module to read at a multiple of 50Hz like 25kHz. Then read blocks of 2500 samples and average them to just 5 samples…
I recommend to read both modules in their own loops as their timebase may/can differ by a small amount, and so provide problems when reading them in the same loop over long time.
03-18-2020 05:18 AM
GerdW, I am guessing you mean it doesn't support the sharing of it's sample clock? Good catch. I haven't used these modules before. Thanks
03-18-2020 06:00 AM
Hi Gerd,
thank you for helping me. It's a great idea to do that with a multiple... 🙂
Thanks for the advice, I will do it in separate loops.
Jani
03-18-2020 06:04 AM
To get really tight hardware-level sync:
1. Configure the 9225 to sample at some multiple of 50 Hz such as the 2500 Hz suggested by GerdW. You will start this task *last*.
2. Configure a chassis counter for pulse generation, specifying the 9225 sample clock as its source of Ticks. Define a total of 50 Ticks for high and low combined to give a "divide by 50" clock.
3. Configure your 9219 to use the output of the chassis counter as its sample clock.
This method will keep the sample timing in lockstep. It may be necessary to do some further compensation for the inherent signal delay of the 9225 (see the manual), but I'm not certain about that.
To investigate, you can feed in a very slow square wave (1 Hz or less) to both and see whether the 1st transition happens at the same place in time or whether its shifted according to the delay of the 9225's Delta-Sigma converter. Once you know if and how much, it's pretty simple to compensate.
-Kevin P
03-18-2020 06:06 AM
Hi Niatross,
thank you very much.
Jani
03-19-2020 08:15 AM
Hi Kevin, thank you for helping me.
I am trying to set it like you suggested, but I am not really coming forward.
I set the rate of 9227 to 2500 and 9219 to 100. The channels run in different loops, the queue seems to be working as well.
But... I don't know what do you exactly mean by You will start this task *last*.
Also in the second step I am not sure what to do - I found CO Pulse Generation and defined 50 ticks for high and low.
But how can I set the sample clock as my source of ticks and what is my counter? I feel like i am missing something.
I am happy for every help.
Jani
03-19-2020 12:32 PM
I made some *partial* mods in place in your posted code. The task configs and starts should be in good shape now with lockstep hardware sync. I didn't touch any of the code in your reading and processing loops.
I left a few comments here and there and did a little wire-neatening in the areas I worked on. Helpful tip: I *highly* recommend taking the time to keep your wires neat & straight as much as possible. On every new install of LabVIEW, I always go into Tools->Options->Block Diagram and turn *OFF* automatic wire routing.
-Kevin P
03-20-2020 03:19 AM
Hi Kevin,
thank you for your help!!!
I am getting a few errors and I don't know how to handle them.
The first: Error -200983 occurred at Property Node DAQmx Timing (arg 2) in VI_03 modKP (1).vi