Hello Dani,
Choosing the right architecture for your application depends a lot on what you are trying to accomplish. You mentioned that you wanted to calculate the phase difference between two sensors, so the next question would be this: what do you want to do with the data once you have got it? Do you want to display the phase difference? Do you need to keep historical information or do you only want to know the current phase difference? Do you need to store this data to a file after you have calculated it? All these factors will help you choose the right framework for your program. In general, the producer/consumer architecture is best suited for applications where the acquisition is high throughput (high speed or high channel count) and requires a great deal of processing capability. By placing the data acquisition in the producer loop and the processing in the consumer loop, we allow independent software timing, which means that the data acquisition can occur as fast as it needs to and the data can be queued for later processing. However, if you are acquiring at lower rates this architecture may not be necessary.
In regards to your sensors, I have a couple questions about what you are trying to accomplish. In your first post you mention that you are acquiring position from two sensors (one linear and one angular). However, you have also mentioned that you are trying to measure the phase difference between the two sensors. I am wondering how you want to determine phase difference since one of the encoders is angular (measures rotational angle) and one is linear (measures linear distance)? Do you mean that you would like to measure the phase difference between the A and B signals on the two encoders? If so, you would not be able to use the position task to perform this action because the position tasks merely look at the difference between the A & B signals and do not necessarily consider the phase of the difference (they assume a 90 degree phase shift).
This tutorial about encoders explains the concept in more detail. If this is the type of operation you are trying to perform, you may want to consider another method for taking your measurement. Either using multiple counters to compare the A & B signals on each encoder, or using an analog input channel to acquire the raw voltage are possibilities for this type of operation. If you could provide some more details about exactly what you are trying to measure, I might be able to provide a more detailed recommendation about how to proceed.
Matt Anderson
Hardware Services Marketing Manager
National Instruments