LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Synchronously acquiring digital data

Hello Labview- Friends

 

I have a problem, which I think is quite easy to solve. However, I tried to work out, but did not manage it. I am using Labview 7.1 and want to acquire signals of a combustion engine. The vi attached works as far well, but I would like to have another feature.

 

à I acquire data by using a crank angle decoder. I start the acquisition by a digital start pulse (start trigger occurs once per revolution), and get a number of scans by an external scan clock (one per degree crank angle). I then get for example 7200 scans to make an average. I prefer to have the acquisition finite, means not using a while loop.

 

Now to my problem: I would like to get the speed of the engine at the same time. So, how can I acquire synchronously the digital pulse of the encoder (either from start trigger [50 Hz] or from sample clock [18 kHz])?

As I would like to compare the speed of the engine with analogue acquired data it needs necessarily to be synchronous.

 

Does anybody have a solution for this problem? I had already a look at some papers concerning “synchronised data acquisition” and forum entries, but I couldn’t modify any examples to my problem.

 

Thank you in advance for somebody’s help

 

Woodi

0 Kudos
Message 1 of 7
(3,471 Views)

Sorry I cant see your code since I have 7.0 on the machine I am working on but typically you can synchronize the data acquisition by using a shared trigger, set your tasks (each is its own data acquisition task) to start on a digital edge trigger, then set the source of the digital edge to the trigger line, this can be an internal source or external source.  when reading out you can multithread the read and read each as fast as possible or better read the expected number of points for each task and send the results to a second loop for processing.  This will minimize the chance of falling behind on the acquisition cycle and causing buffer overruns.

 

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 2 of 7
(3,456 Views)

Hello Paul

Thank you a lot for your reply. As I am quite new to Labview, I didn't get everything you wrote. What do you mean by “multithread reading”? Isn’t normally AIread a blocking call?

However, I keep trying…

Basically I used the “Cont Acq&Graph Voltage-Ext Clk-Dig Start.vi” from the Labview library, but deleted the while loop and changed to “finite” acquisition.

 

Greets, Woodi

0 Kudos
Message 3 of 7
(3,441 Views)
Hello Woodi,

if  get you right you need to acquire a digital puls train (giving the speed of the engine) and an analog input synchroniously. For measuring the speed, you would typically need to calculate the frequency of the mesured pulstrain. Having a look at your application it looks like you are aquiring the pulstrain with an analog input, using an external clock.
I dont know which hardware you are using, but if it is a E-Series or M-Series board, you have counters that could do the job much better. In this case you would need to synchronize an analog input task with a counter task.

Please let me know which hardware you are using and if I am right with my assuptions - I'll then try to find a suitable example for you.

regards
Ingo Schumacher
Systems Engineering Manager CEERNational Instruments Germany
0 Kudos
Message 4 of 7
(3,436 Views)

Hello Ingo

You are totally right. I need to synchronize analogue inputs with digital inputs or counter inputs. The vi attached is just the one I use for the analogue input. There I would like to add a synchronized counter task, where I can use the start trigger of the analogue acquisition to get the frequency. I need a simultaneous acquisition, because I want to compare speed of the engine with the analogue acquired data.

I am using a card which supports counters (M-series PCI-6254).

I would be really glad if you had time to have another look at my vi.

 

Greetings, Woodi

 

PS: It’s not possible to get the digital pulse by using the analogue inputs, because the trigger edges are very short (just a few ns, and I would then need a stupid high sampling rate).

0 Kudos
Message 5 of 7
(3,430 Views)

Multithreading in labview could not be any easier, just use tow loops and communicate with a synchronize object like a queue.  Look at the producer, consumer design pattern (LV 7.0 or greater), where the producer is a daq loop with no delays and runs as a blocking read (runs as fast as a read function or a timeout condition) and the consumer loop will process and present the data.  the queue is used to send the data between the loops in a fifo manner.

 

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 6 of 7
(3,425 Views)
Hello Woodi,

a counter that is running in frequency measurement mode cannot be used with an external clock. This does not make it easier to synchronize it with another process. Maybe you could live with using the counter raw data and calculate the frequency in software. In this case you may use the counter in event counting mode - and this mode supports external timing, which is the key for synchronisation.

Have a look at the attatched example, it synchronizes analog input and event counting, using a digital start trigger and the analog sample clock as shared timebase. If you are running high frequencies and using just one counter as in this example you might have to be aware of counter overflows.

regards
Ingo Schumacher
Systems Engineering Manager CEERNational Instruments Germany
0 Kudos
Message 7 of 7
(3,415 Views)