05-11-2007 05:08 PM
05-14-2007 01:55 PM
Hi Carlos,
Thank you for posting to the NI forums. There is an example program that installs with the DAQmx driver that synchronizes analog input with digital input. It can be found by opening the LabVIEW Example Finder and navigating to Hardware Input and Output >> DAQmx >> Synchronization >> Multi-Function >> Multi-Function-Synch AI-Read Dig Chan.vi.
Using this example, you can set the sample rate for both the analog and digital inputs to 200 Hz.
I hope this helps – please post back if you have any further questions.
Ed W.
Applications Engineer
National Instruments
05-17-2007 03:17 PM
05-19-2007 03:04 PM
Hi,
Since you’re using “On Demand” mode for your acquisition, all of the timing will be done in software. Therefore, the 600 ms delays that you’re seeing are expected.
Also, I am a little unclear about your application. You mentioned that you’re using an encoder/decoder, but are you using any digital I/O? If you’re just using the analog inputs, you could perform hardware-timed retriggerable analog acquisition using an external digital trigger. There are numerous Knowledge Base entries and example programs.
How Can I Perform a Retriggerable Acquisition?
Make sure to check out the related links as well. Post back if you have further questions.
Ed W.
Applications Engineer
National Instruments
05-25-2007 04:44 PM
05-29-2007 02:38 PM
05-30-2007 02:56 PM
05-31-2007 12:35 PM
Hello Carlos.
Thanks for that explanation and your code. The issue is much clearer to me now. I still believe that Ed's example provides a great starting point for your program.
The issue that we are going to see as this application progresses is that there is no way for all of the digital inputs to be synchronized with the analog input since the digital information will be read in series. However, if you follow the framework that has been built, you can start the reading of the analog inputs and the reading of the digital input at the same time. So, right when you read the analog data, you will be writing the first 2 commands to the encoder. If you wish to read the low byte in sync with the analog data, you could write the first 2 commands to the encoder before you start both read tasks. The other consideration is that if the 7 steps of encoder communication take longer than the rate at which you wish to acquire your analog samples, your program will become out of sync.
The second point of consideration is that the timing considerations that this program brings will probably require the use of a producer/consumer architecture. Place the acquisition tasks in the producer and the processing code in the consumer loop. Then, you can use queues to pass data from the producer loop to the consumer loop processing the data only when you have time (ie, the processor is not busy acquiring).
Let me know if this helps you with your program. We will be happy to help you further in any way we can.
Brian Fleissner
Applications Engineer
National Instruments
05-31-2007 01:18 PM
06-01-2007 11:32 AM - edited 06-01-2007 11:32 AM
Hello Carlos.
I have modified the example that has been the center of discussion to reflect your application needs a bit better. Since we have the need to only acquire one sample at a time, we will want to use Hardware Timed, Single Point Mode. If we set this to 200 Hz, then the loop will execute about every 5 ms. Then, I placed a digital task in parallel, which will also execute at the 200 Hz frequency as a result of it being in the same loop as the analog input read. All you need to do now is set up a series of digital write and read VI's that will perform the communication necessary to get the information from the encoder in less than 5 ms. Please note that this execution will be based on software timing so please minimize the number of programs running in the background when you run this application.
Let me know if there is anything else we can do for you!
Brian F
Applications Engineer
National Instruments
Message Edited by Brian F. on 06-01-2007 11:33 AM