04-08-2012 07:21 PM
I am using cDAQ 9174 and NI 9401 to access the counters. I wrote a vi that successfully measured the period fo the tick marks on an encoder wheel. The vi measures 15 periods, writes them to an array, and then finds the average value.
Now, I want to use TWO counters, and measure the average period of TWO encoders simulataneously, and then add some other calculations to control the drive motors etc.
So, I was advise to try Producer/Consumer architecture, and I developed the attached vi.
Here are a few questions for which I'd appreciate some feedback.
1.) I have THREE STOP functions on the front panel, one for each WHILE loop. How do I consolidate these to become a single STOP for the whole vi?
2.) On the DAQmx Create Channel, I have selected "Low frequency with one counter" because originally, the vi was for only one counter. Is this OK when I have two counters operating in the same vi?
3.) Lastly, the way the averaging is done here, the values are averaged 0 through15, then 1through 16, then 2 through 17 etc. I would prefer to average 0-15, and then 16-30, and then, 31-45 etc. Can you tell me how to adjust the way the averages are calculated? Maybe this has to do with the way we have the shift registers configured? Or, should I use a FOR loop, and iterate 15 times?
Any other comments are more than welcome!!!
Thanks a lot for your help.
Dave
Solved! Go to Solution.
04-10-2012 05:28 PM
Hi dav2010
In relation to your issue, I have some answers for your questions:
I don’t think you need to have a producer/consumer format for this application, I would rather have only one while loop with both counter tasks in it.
Regards,
04-10-2012 05:52 PM
Hi STeve,
Thanks for the input. Can you add some details to the suggestion about "you need to have only one button and have local variables in the other loops." How does that work? I don't understand what you mean by that? Put local variables ...where and how?? When I eliminate any of the existing STOPs, I get this error:
"Th conditional terminal is not wired to anything and must be wired to a boolean data source such as a button or the result of a comparison." Can you show me what you mean? Which loop would the single STOP reside in, and how do you make a WHILE loop error free without a wired STOP in place?
If I put both counters in the same loop, will that work? How do I understand the order of execution? For example, I want the vi to period values simultaneously and independently, for two encoder wheels. I want the vi to calculate an average value of the 15 periods, and then allow me to compare/calculate etc.
Thanks,
Dave
04-10-2012 05:59 PM
Hi!
This picture shows what I meant by using only one stop button and a local valiable linked to it.
Then, if you want separate measurements, so use one while loop to each counter, and forget that last advice from me
Regards,
04-10-2012 09:09 PM
So, now that I was able to offer a little more clarity about my goal with the vi, do you agree that the producer/consumer architecture is a good choice?
Thanks,
Dave
04-12-2012 01:01 PM
Hi Dav,
You can try to do it first without the producer consumer, I think you won’t need it, because it seems that you are not going really fast, if you do it without the producer consumer and you see that you are missing counts, you can go back to the original design, but I’ll say that you’ll be ok without it.
Regards,
04-12-2012 06:13 PM
Thanks, Steve. What I found out is that with my new encoder, 120 per revolution, the WHILE loop structure I was using cannot keep up; the previous encoder that I was using had only 4 ticks per revolution. So, now, I want to count ticks in a fixed time interval, e.g. 100 ms repeatedly. Is there a way to configure this so that I can get the ticks passed every 100ms, for example? Alternatively, I could fix the number of ticks, e.g. 30 ticks, and ask the VI to output the time it took to do 30 ticks. Can either of these be done conveniently?
Thanks,
Dave
04-13-2012 08:50 PM
Hi dav,
I would like to recommend you to open this manual, and go to page 7-5, the method shown there (Buffered Edge Counting) is what you need.
You will find examples for this in the NI Example Finder installed in your computer.
Regards,
11-13-2012 10:11 PM
Hi STeve, I'd like to revisit this manual that you recommended and look again at Buffered Edge Counting, but, the link no longer works. Can you help me find this manual again? This manual was very helpful to me a few months ago when you first suggested it.
Thanks,
Dave