LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

digital waveform array into boolean

Hi

 

I have an shaft encoder which provides 720 pulses per rev and everytime it pulses I want it to acquire two voltage inputs. I also have 4 thermocouples of which I have no problem acquiring data from at the same time. I have attached my block diagram. I have wired the pulses to a digitial in so that ideally when the value is TRUE it opens the case structure to allow the voltage data to be acquired. I also require the number of pulses hence the use of the shift register (this works fine).

 

In the digitals daq assistance properties I have set for continous samples to read at 100 samples for 1K, it can read those pulses in the properties when the shaft is turned. Since because of the continous sample reading the output of the daq assistance is digital array of waveform is there any conversion to the boolean on the case structure (where the broken wire is)? I am using a compact daq cDAQ 9174 with 9205, 9211, 9263 and 9401 banks.

 

I cannot set the daq properties to be 1 sample on demand since this is too slow to read data in. Many thanks for your help in advance.

 

Notay

24050i9AC5BB945F6470DF

0 Kudos
Message 1 of 52
(5,772 Views)

Use an Array OR function to convert the array to a single boolean (assumes you want a TRUE if a single element of the array is TRUE).

 

Note that you can expand the index array function you currently use for Laser Strength so that you can get Fluorescence out of it, as well.  You don't need the bottom DDT to Array converter (which does exactly what the top one does) and extra index array.

 

0 Kudos
Message 2 of 52
(5,759 Views)

Hi

 

Many thanks for your reply. I am correct I think you were refferring to an 'Or Array Elements' function - I tried this but it did not work still as can be seen below. Or have I missed something crucial to add?

Also thanks for the note I did not know you could expand - makes the diagram look a little easier to see.

24084iDFE7C401089C9A33

0 Kudos
Message 3 of 52
(5,747 Views)

You can use a consumer producer set of loops. One takes data and the other produces data. That way when you are taking data set when a condition is met the producer loop does not slow down. This is exactly what this type of architecture is for. Not only that depending on how fast your counter is counting pulses you may end up missing data collection the way you are currently doing it today. Look at the examples for producer and consumer. I think that would set you up for sucess in the future no matter how big your program grows.

Tim
GHSP
Message 4 of 52
(5,743 Views)

 


@DFGray wrote:

Use an Array OR function to convert the array to a single boolean (assumes you want a TRUE if a single element of the array is TRUE).


Only after the 1D array of digital waveforms is converted to a Boolean array... Smiley Wink

 

 

To OP: Since you have a 1D array of digital waveforms you need to convert each one to a Boolean array so you can use Boolean functions. This is done using the Digital To Boolean Array VI. Something like this:

 

Message 5 of 52
(5,736 Views)

I really should wake up before I reply to these things.  Note that you can use a conditional FOR loop and exit once you get a TRUE.  You will also want an Array OR on the output of the FOR loop, or you can use a shift register initialized to FALSE and OR it to the output of the Array OR.

 

24132i9FC7DFF85D625C3F

Message 6 of 52
(5,726 Views)

Hi many thansks to all of you for your reply. I does seem to work as expected for small shaft speeds i.e. hand turned since I get error -200279. I used the conditional loop method as proposed by DFGray.

 

However I believe the way forward for faster speeds is possible the producer consumer loop as proposed earlier. I have never used this architecture before but I am assuming that I place all daq assistances in the producer loop which is fine - I do not know whether my daq assistances for the voltage inputs (laser/fluorscence) would also be placed in that producer loop - I would be grateful if you could explain which is the best way to implement this architecture?

0 Kudos
Message 7 of 52
(5,703 Views)

If you want it to be fast you will eventually need to get rid of the DAQ assistances. You are going to need to break everything down into the core components so that you only read the channel that you want. The daq assistant opens, reads and close every time.

 

 

You will need to have the analog read for the voltage input in one loop and ship the data to the cunsumer loop to do calculations, plotting, array miniplulations etc... The producer loop should only read data. This will make your loops fast and off load all of the work to a different thread. Look at the examples that shipped with LabVIEW and come back when you have something to show and I would be happy to help you make your program work.

Tim
GHSP
Message 8 of 52
(5,698 Views)

Given what you are trying to do, I would probably put the digital acquisition in one loop.  When it determines you need to read the analog parameters, it fires an asychronous call (queue - my preference, user event, or occurrence) which wakes up a second loop containing the analog acquisition.  Your "analysis" is pretty minimal, so you can keep it in the analog loop.

 

You should definitely get rid of the DAQ Assistant blocks.  Convert them to subVIs, copy and paste them into your code, then move the initialization and finalization parts outside your loop.  This will really speed things up.

 

Look up the examples of how to use producer/consumer loops for more hints.  Let us know if you need more help.

Message 9 of 52
(5,729 Views)

Hi

 

I have looked into the producer/consumer loop design and have tried to implement it for my work. I removed the daq assistants and used the core daqmx modules. The digital read for the pulse is in one while loop with the conditional for loop from the previous post reply, the analogue read for the 2 voltage signals is another loop which usings the queue architecture. It has errors in the program at the conditional for loop (such as "For loop:conditional terminal is not wired" and "For loop: N is not wired and there are no indexing inputs") and I am wondering whether the conditional for loop is still valid.

 

24312i1083704852228391

I have simple set the vi to write the data to the files for the moment rather than any post data manipulation. I understand the queuing concept but do not understand if I have written the program correctly and how I can add the other channels such as the 4 thermocouples (on 4 separate channels) and an additional pulse line to measure shaft speed. The previous program that I had could do them all but obviously at very slow speed. I have attached my vi. I really appreciate you help.Smiley Happy

 

0 Kudos
Message 10 of 52
(5,645 Views)