10-12-2010 08:30 AM
I implemented a more complete algorithm, and it appears to work correctly. It will generate a maximum of one trigger for each input digital line of data. You can change this so it will output a trigger for every pulse change (move the case statement into the FOR loop and run it directly from the output of the exclusive OR).
The extra enqueue at the end of the producer loop is to make sure the consumer loop processing everything before it exits. If you put the release queue after the producer loop, this will not be true.
Hope this helps.
10-13-2010 09:03 AM
Hi DFGray, thanks for your reply. I have wired my code up as yours but I get an Error 1 at the dequeue function - I think it is referring to the release queue in the analogue loop:
10-13-2010 09:07 AM
Forgot to add to that previous post:
You added a greater than function (>3) from the digital loop iteration - do I need this in my code?
I removed the release queue at the end of the digital trigger loop. I have attached my code for your reference. Thanks
10-13-2010 10:14 AM
Problems:
10-14-2010 09:15 AM
Hi I wired a DWDT Digital Size function between the digital waveform from the DAQmx read and the DWDT digital to boolean array and wired the number of samples to the reshape array as recommended - but still get the same error message. Any idea?
Also regarding your final bullet point, I am little confused when looking at your program since you have it to stop your program after the 4th iteration but it is also wired into the last case structure in the trigger loop - if I were to remove it then what would I wire as a case selector but if I were to keep it what use would it be to stop the trigger loop after the 4th iteration since I would not be getting any more triggering action - so this is where I am confused.
10-15-2010 09:08 AM
Hint: My code is an example to make sure the algorithm works as expected. How many sets of fake data does it have?
10-18-2010 08:13 AM
Hi
If I am correct you are running a 2d array which is 11x5 in size and has 4 true constants. each true constant iterates the trigger loop for the analogue. once four iterations have occured, no matter if more true constants are supplied in the set, the triggering loop stops since the loop iteration is zero indexed and exceeds the comarison hence the a true is fired to the stop button. I do like these probing questions since it allows me to learn - so thanks.
I have narrowed down my error in the program down to the final dequeue function at the end of the analogue loop but do not understand why it occurs since apart from the comparison function to stop the digital loop (of which I still am not entirely sure if I need)- any ideas on the error - is it a cause of the comparison?
10-19-2010 08:03 AM
The >3 comparison essentially turns the WHILE loop into a FOR loop. I had five sets of fake data and this loops through it five times. You should replace the comparison with a stop button, as you originally had, otherwise you will only get five iterations of your digital loop.
I am unsure what your other problem is. Please post your current code and I will have a look.
10-21-2010 09:09 AM
Hi
Changing the comparision to a stop function resolved the error and now the program does give a trigger for each pulse (whether that pulse provides a 1 or 0).
However when I turn the shaft one full rev I get about 1000 triggers instead of 720 as specified by the encoder. I have checked this in MAX and I get 720 there as expected. I see this since I have put a get queue status at the end of the triggering case structure. The logic seems correct - what would cause this?
10-22-2010 09:30 AM
My suspicion would be something weird going on in the digital input. I would confirm that your data is correct along the entire path (use breakpoints to stop the loop and probes or indicators and look at the entire set of data, including the beginnings and ends). I do not see any errors in the code (although without running it, it is hard to debug).
I did notice that your analog loop has a couple of issues:
Good luck!