LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

cannot realize Producer / Consumer Build

Solved!
Go to solution

Dear Ladies and Gentlemen,

 

i have another issue with my code. Since a couple of days i'm trying to separate my 1D array of waveform, grabbing one waveform (e.q. this, wich is generated from hardware input channel one) aaaannnd separate this into its parts.

Now an easy task i thought, but i'm a loss right now. In one second my "display array" shows one voltage value + one dt value, like i expect this. One sample / grab from Queue results exactly one pair of waveform components. In an other second i got two voltage values + 2nd waveform component. what the hell... i wanted to grab pairs of waveform components and save them column next to column in a .txt file, either per "save on demand"-case or the whole values at the end after stoping the consumer loop.

 

if i'm following examples and forum.vi's, e.q. saving arrays of random numbers into a file one-rowed, two-rowed, one-columned, two-columned, whatever... it works, but with my "live" waveform data i got that artefacts, i dont know where they come from

 

In that attached .jpg's u can see my consumer loop at the top and my producer loop at the bottom. there are several trys to write my data in a file, don't get irritated by this. aaaaand i already pushed "ctrl+u" ^^

the problem is, i cannot trust my data so far, as long as do not get the right process: sample waveform data > put that in queue > grab that > seperate that > and got exactly one sample of component data

 

at this state, like it is now, i don't know which value is doubled in my txt-file and which is not

 codecode

 

wrong casewrong case

 

right caseright case

so does anybody know, how i could overcome with that 😃 ?

to complete my question, i will attache all jpg.s and the Vi's (main: IQ_Diagramm_rev_4.vi and subVI: Fail_or_Stop)

 

thank you very much

0 Kudos
Message 21 of 25
(647 Views)
Solution
Accepted by topic author Zottel

HI,

remove "Wait (ms)" from producer loop. You do not need to sync the loop, the DAQmx Read function does this.

Instead wire a integer constant with 1 to the "number of samples" input of DAQmx read function. Whenever 1 sample is acquired the function returns this one sample in the Y array. If you wire 10 to "number of samples" the DAQmx read function waits until 10 samples are acquired and returns 1 waveform with 10 elements in Y array.

 

Message 22 of 25
(639 Views)

As Ulib says, you don't need, and shouldn't use, a wait in the producer. It also looks like you've set it to 1 sec worth of signals, or is it 1 sample? (i can't look at the code right now, just looking at the picture)
Anyway, if you set the sample to 100Hz (10ms) and the read to 1 sample, it'll wait until it can read that sample, effectively causing it to spin at 100 Hz automatically.

Also, the "Stop or failure" can be replaced with a simple OR, atleast if you're on LV2011+ 🙂

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 23 of 25
(634 Views)

@UliB wrote:

HI,

remove "Wait (ms)" from producer loop. You do not need to sync the loop, the DAQmx Read function does this.

Instead wire a integer constant with 1 to the "number of samples" input of DAQmx read function. Whenever 1 sample is acquired the function returns this one sample in the Y array. If you wire 10 to "number of samples" the DAQmx read function waits until 10 samples are acquired and returns 1 waveform with 10 elements in Y array.

 


oh my god, reeeeeeaaaaally thank you very much,

 

it works 😃 i'm able to save the data without such artefacts, right now. Nice hint!, i would never have looking for that misbehaviour at this spot, since i've read in forums&contexthelp before: "if u are continious sampling, set the [samples per channel] of daqmx-read to -1 or leave it empty, because the vi will get the value automatically"

 

0 Kudos
Message 24 of 25
(627 Views)

@Yamaeda wrote:

As Ulib says, you don't need, and shouldn't use, a wait in the producer. It also looks like you've set it to 1 sec worth of signals, or is it 1 sample? (i can't look at the code right now, just looking at the picture)
Anyway, if you set the sample to 100Hz (10ms) and the read to 1 sample, it'll wait until it can read that sample, effectively causing it to spin at 100 Hz automatically.

Also, the "Stop or failure" can be replaced with a simple OR, atleast if you're on LV2011+ 🙂

/Y


Many thanks for your reply @Yamaeda. The 1 is just a value for VI-timeout. 😃

I really appreciate the tips you guys are giving here!

p.s.:

I'm using Labview15.0(64bit) on my notebook, wherefrom i'm always writing this shared posts and

I'm using Labview9.0(32bit) on that offline-WwindowsXP-desktop right next to the proper microwave measuring system

 

0 Kudos
Message 25 of 25
(621 Views)