LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

digital waveform array into boolean

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).

 

DigitalEdgeTrigger2.png

 

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.

0 Kudos
Message 31 of 52
(1,422 Views)

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:

vi.PNG

0 Kudos
Message 32 of 52
(1,420 Views)

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

 

 

0 Kudos
Message 33 of 52
(1,419 Views)

Problems:

 

  • You have wired your acquisition rate into the number of samples in the reshape array.  This needs to be number of samples fetched, not how fast they are being acquired.  This will cause the issue you saw with the output being a constant TRUE, since it will pad the waveform with a bunch of FALSE values, resulting in at least one false trigger per loop iteration.  You can fix this by querying the waveform itself for the number of samples in it and using that.  Since you are fetching everything available, this value could change from iteration to iteration.
  • Per you question, what does the i>3 do in my code example?  Why is it there?  When you figure this out, you will answer your question.

 

0 Kudos
Message 34 of 52
(1,412 Views)

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.

0 Kudos
Message 35 of 52
(1,397 Views)

Hint: My code is an example to make sure the algorithm works as expected.  How many sets of fake data does it have?

0 Kudos
Message 36 of 52
(1,380 Views)

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.Smiley Wink

 

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?

0 Kudos
Message 37 of 52
(1,366 Views)

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.

0 Kudos
Message 38 of 52
(1,359 Views)

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?

0 Kudos
Message 39 of 52
(1,345 Views)

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:

 

  1. You set up the analog acquisition to be continuous.  This means that it will be taking data all the time, so the triggering by the digital loop is immaterial.  You might as well have it free running.  If you want it triggered by the digital loop, you should set this up in hardware (use a digital input on the DAQ board for a trigger) and fetch after every trigger.  Use the DAQ Assistant to generate this set of code for you, separate it out into initialization, acquisition, and finalization like you did before, then implement it.
  2. You still have a DAQ Assistant inside a loop to get your temperatures.  You should separate out its components as you did the analog waveform.  Otherwise it will really slow you down.  You may consider doing it a little less often and putting it in a separate loop.  Temperatures typically do not change very fast.

Good luck!

 

Message 40 of 52
(1,333 Views)