LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

digital waveform array into boolean

Hi just an update - I have modified my digital loop to this :

 

24314iDCB0EAECFB1A1DEB

 

Although the program runs as soon as the encoder pulses the whole program stops it does not continue on to the analogue loop or write the data to text file and I am now wondering if I have wired my program incorrectly.

0 Kudos
Message 11 of 52
(1,519 Views)

You separated the digital and analog acquisitions, but did not put them into independent loops.  You also need a producer/consumer type relation between the digital and analog loops.  Currently, the digital loop runs, then the analog loop runs, then it all exits.  You want the digital loop to run continuously, the analog loop to run on demand (consumer of "flag") and the file loop to run on demand (consumer of "data").

 

Remove the error and reference wires connecting the the digital loop to the analog loop.  Instead of exiting the digital loop when you get a TRUE result, enqueue a "Read" command to a queue which communicates with the analog loop. When your stop button is hit, stop the digital loop and enqueue and "Exit" command to the analog loop.   In the analog loop, have two cases for the output of the queue - Read and Exit.

 

You can add more loops or more channels to each loop, as needed.

Message 12 of 52
(1,519 Views)

Hi DFGRay  thanks for your reply. I have tried to follow exactly what you wrote but have found it a little difficult. I understand the concept but couldn't really undersatnd what you mean by enquene a Read or Exit. Nevertheless I have attached the modified version according to your instruction.

 

Please can you tell me if this is what you were on about - I have one error as can be noted by the broken wire in the digital loop to the queue function. The data types are incorrect but I was unsure how set a boolean as the data type for the obtain queue to the digital loop (i used a boolen function in a cluster as can be seen but this provides a cluster as the data type). I appologise if I contiune to ask for help this is the first time I have used the queues function but do appreciate the help. I have also attached my vi as reference.

 

24362i1107BC8FCA536112

0 Kudos
Message 13 of 52
(1,502 Views)

Use a boolean constant as the data input to initialize the queue.  In the digital acquisition loop, use the output of the Array OR to feed the queue (just wire it from the inside terminal of the case selector).  In the analog loop, you actually do not need the inner case structure around the acquire VI.  The queue will only run when it has data, giving you the behavior you want.  This should make things work for you.

0 Kudos
Message 14 of 52
(1,494 Views)

Modifying the vi as you stated, the vi now runs but the digital loop seems to run on its own without the encoder pulsing with no output to the digital waveform graph as well. The digital loop runs continously which is what we want but does not respond to the encoder and the 720 pulse indicator in the loop just increases. Also the analogue signals are not acquiring and this is possibly because the digital loop is not responding to the encoder. The encoder and analogue systems are correctly wired as checked with MAX.

 

Is it also possible to include the 720 counter data from the digital loop along with the two voltage channels in the analogue loop into the write to text file function that is in the consumer loop connected to the analogue producer loop?

There is also two stop buttons one for the digital loop and one for the analogue loop - would you recommend using a local variable to stop both loops with one stop button?

 

Modified vi as per previous message:

 

24372iBF4E314BF2978919

0 Kudos
Message 15 of 52
(1,487 Views)

Given your original design, the 720 pulse counter should be in the same frame as the analog acquisition in the analog loop.  Currently, it increments every time you get digital data, whether it contains the pulses you want or not.

 

Stopping all three of your loops with a single button is pretty simple, given your current design.  Do the following:

 

  1. Delete the stop button and wire the top error wire of the analog loop directly to the loop terminator.
  2. In the Error case on the analog loop, wire the case selector to the error output so you will get an error if the queue errors.
  3. Rename stop2 to stop.

Good luck.

 

Message 16 of 52
(1,476 Views)

Hi DFGray

 

I have managed to get my program to respond to counter pulses and the analogue loop responds to when the shaft is turned. However when the shaft stop turning i.e. encoder not pulsing, the analogue loop continues to iterate. I first assumed that it was the queue catching up to the encoders pulses but this even occurs when only a few encoder pulses (<10) have occured - the analogue loop continues to interate. Why would this occur?

 

Also I have wired the stop button as you suggested in your previous post but this does not seem to work - the stop button only stops the digital loop and the analogue continues to iterate. Many thanks

 

vi.PNG

0 Kudos
Message 17 of 52
(1,440 Views)

I cannot see anything fundamentally wrong with your code.  My guess is that you are sending too many analog acquisition requests and they get way behind.  You can debug this in one of two ways:

 

  1. Put a probe on the queue reference just before the dequeue in the analog loop.  It will tell you how many elements the queue contains.  If you have an older version of LabVIEW you may have to make a custom probe to do this.
  2. Temporarily add a Get Queue Status primitive just before your dequeue in the analog loop.  Look at the number of elements.

You correctly deduced that this issue will cause both of your problems.  Are you sure the logic you are using to fire the analog loop is correct?  If so, is the analog loop running fast enough to keep up?  You can use the millisecond timer to time things.  If you need more resolution than that, check out the high performance timers in this post.

 

Message 18 of 52
(1,433 Views)

Hi, I have investigated my program further and have found that the problem lies within the digital acquisition. Once a pulse occurs and it provides a true (or 1) value when a second pulse occurs a False (0) is provided - and with further pulses it depends on which of those values the final encoder pulse lands on for example if the last pulse provides a 1 then the analogue loop continues to pulse. If the last pulse provides a 0 the analogue loops does not acquire data.

 

This makes me believe that even when the pusling is occuring the analogue loop is technically not responding per pulse and continues at its own set rate and only relies on a 1 being presented at the queued loop in the digital loop.

 

I have tried to adjust the sampling properties of the digital loop but cannot get a single pulse to provide its 1 then return to 0 (which currently happens with two pulses).

 

Is it possible to get a digital pulse to return to a 0 after providing a pulse? Many thanks for the invesitgation/probing questions.

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

Getting the pulse to return to zero depends on your data source, not your data acquisition.  You could always append a zero to the end of the digital waveform you acquire, if that would help.  However, you may be better off changing the algorithm for triggering your analog loop.

0 Kudos
Message 20 of 52
(1,416 Views)