07-17-2017 09:36 AM - edited 07-17-2017 09:49 AM
Hi, everyone:
First time poster here. I’m new to LabVIEW and was wondering if someone could tell me if the code I wrote is doing what it's supposed to do.
What I’m trying to do: I have a cDAQ-9178 chassis with 5 NI modules installed in the following slots:
The NI 9472 outputs a voltage that selects one of four relay groups. The other four modules record data. The relays are part of a multiplexer that selects a subset of sensors. I was asked to provide an effective sampling frequency of 10 Hz for each of the four channels. Therefore the system runs at 40 Hz. Ideally, I would have all 5 modules in sync, with the NI 9472 (Voltage out) leading the measurements by ~4 ms (the time it takes the relays to change states and stabilize). However, I was unable to do this. If I put the measurement components in the relay-control loop, everything slows down to about 1 Hz. Also, my understanding is that without the FGPA module, perfect timing of the NI 9472 is impossible (at least for what I need it to do). Therefore, I settled on a slightly less ideal approach:
I think the attached VI achieves this goal. However, it's hard to know if everything is doing what I think it’s doing. So my concerns are the following:
Thanks in advance
njspeer
07-18-2017 08:57 AM - edited 07-18-2017 09:11 AM
Hello njspee,
attached an idea, not fully tested.
07-18-2017 10:00 AM
Thanks, Duffy2007.
I am unable to open your VI with my copy of LabVIEW 2015. Is there anyway to save it as an older version?
Thanks,
njspeer
07-18-2017 10:31 AM
Hello njspeer
07-19-2017 02:23 PM
Thank you very much, Alexander.
I'm still trying to make sense of your VI.
I was unaware of the 9237 input delay. Thanks for bringing that to my attention. I have a few (maybe nieve) questions. My first question is regarding the synchronization: My understanding is that in your VI the 9205, 9216, 9472 and 9216 are all using the ai sample clock, but the 9237 is using its internal clock. If that is correct, is there any way to get the 9237 on the same clock? This application needs to be able to run for a long time without any drift.
Thanks,
Nathan
07-19-2017 02:51 PM
Hello njspeer ,
i have added a property so the 9237 clock should be used from the other moduls. I think this i correct, but i never tested it over a long time.
07-21-2017 01:39 PM - edited 07-21-2017 01:53 PM
Thanks for the help, Alexander.
Your example made me aware of several things I had missed. I’ve implemented most of the differences from your code. I still have a couple questions:
Thanks again,
Nathan
07-21-2017 03:42 PM
Hello njspeer ,
1. Yes your modification is ok. The importand thing is that the 9237 has an internal clock, because it is an DSA modul with a delta sigma ADC and thats the reason, why i used this clock.
2. 3. I used the sample clock so the DO is also synchronized to the inputs.In your code the DO run asynchron to the inputs. You must set 50KHz and 1250 samples for strain and 2Khz and 50 samples for AI and DI then the loop should run with 25ms.
4. This was because the DAQmx driver makes the timing of the loop and with this i can influence the timing behaviour. Normally i use factor 1/10 example 1Khz 100 samples, then the loop runs with 100 ms and you get in every loop an array with 100 elements. You can delete this.
07-26-2017 09:24 AM
Thanks so much for your help, Duffy2007.
I was able to implement everything except getting the 9472 on the same clock. When I try, I get buffer errors. However, I don't think putting the 9472 on the same clock will be beneficial; since the 9472 signal still has to be generated by LabVIEW, the actual 40 Hz Boolean signal will not stay in synch— even if it were possible to sync it to an underlying 2kHz clock from the NI 9237 that the other analog modules are using, the relay group select functionality would not stay in synch. I think the ultimate solution would have to be through the FGPA LabVIEW module, which I currently do not have.
Since I am measuring the relay-group voltage on the NI 9421, I can split everything up post-measurement. The 9472 running out of sync will cause a few missing data points here and there, but should not be a huge deal. I will either replace them with NaN or an interpolated value.
Attached is a copy of my final version in case anyone else wants to use it as an example.
Attached is my current version.
Thanks,
Nathan
07-26-2017 11:54 PM
Hello njspeer ,
please remove the wait function inside of the while loop, because the DAQmx driver makes the timing of the loop.
Use a queue to separate the produce (DAQmx) from the consumer (File I/O, Charts, ...), if writing the file takes longer, because the file gets bigger, then the aquisition can run into an error, while the samples could not be read from the buffer.
You are using the iteration count from the while loop, this count has no overflow so it will stop at the maximum of the i32.