LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to repeat triggering a sampling sequence?

Hello all,
   How can I implement a repeatly trigger function? I have a encoder and i want to use its z-index output to trigger the sampling sequence. The trigger signal is once per rev. What should I include in the loop? I searched labview samples but didn't find the one I need.
   And same question about the counter counting using DAQ-STC, can I count the master timebase between every two z-index?
 
Thanks
 
Feilong
 
0 Kudos
Message 1 of 7
(2,899 Views)
feilong,

What type of data are you taking?  Triggering with the z-index is very feasible.  To help you more I would need to know what you are doing with it.  Is it Analog voltage, are you reading a digital line, are you reading another encoder?

If you want RPM (I think that is what you were asking for in your second comment), set up a counter input->freq task on the z-channel.  That number times 60 is your goal.

Best of luck, try to get back with me so I can help more,
~milq
0 Kudos
Message 2 of 7
(2,895 Views)
Hello milq,
Thank you very much for your response.
I need to sample some anolog voltage signals every crankshaft degree, which is indicated by encoder pulse(our encoder has 360 TTL pulse per rev) as external sampling clock. I wish to use same encoder z-signal (TTL, once per rev) to trigger the above sampling sequence. thus the sampling process could be started at fixed angle once every rev. by this way, I don't need to worry about the accumulated degree error caused missing encoder pulse.
Thus I repeat to use the trigger signal.
If possible, I also would like to use a counter to measure the time interval during every two successive encoder pulse (1 deg interval) thus I could work out the instantaneous crankshaft speed. it will have variation during a whole rev. \
Hope you could understand better my situation now.
looking for your reply.
thanks
 
feilong
   
0 Kudos
Message 3 of 7
(2,884 Views)
This sounds very much like something I had to do a while ago (actually, it is eerie how similar it sounds).

Regardless, I stripped down an app that I had, it is attached.

Hopefully this can be a good start to what you are working towards.

~milq
Message 4 of 7
(2,878 Views)

Hello Milq,

  I did spend some time to get a higher version labview to open your vi.

  I read it and have a few questions.

  1. The basic algorithm is to use PFI0 (connect to z index signal of encoder output) to trigger the 360 gauge measurements of ai1 (PFI5 is the external sampling clock, connect to 1 pulse per degree pin of encoder output) and this will happen every 10 ms. the frequency measurement is also taken as every time the gauge measurement is triggered as they are in same loop. Is my understanding right?

  2.  Which terminal are you measuring the frequency, ctr0 or PFI0? As the ctr0 is used to setup the frequency task but later you specify the PFI0 to be the frequency measurement terminal. So how do they work?

Thank you very much for taking time on my question. look forward to your answer

 

Feilong

  

0 Kudos
Message 5 of 7
(2,857 Views)
Feilong,

I do not have the code right in front of me . . . . but, here is the idea.

The Z-Index line does two things:
a) A counter task configured for Freq monitors this line and reports the freq of the index (this gives you RPM)
b) This line serves as a trigger for the AI Measurements

The A (or B) line serves as a sample clock with each pulse representing one measurement of the analog line that you configure.

I am not sure how stripped down the code I gave you was (I do not have LV on this comp).  The 360 constant on the left should feed in to the read vi in the loop (if it does not already).

The code loops once per cycle.  So each array of data coming out represents an entire 360-degree sweep.  The timer is there because LabVIEW likes the user to tell it to wait (for processor allocation reasons).  The only nonobvious thing going on here is the fact that I am not actually using a counter to count angular position.  After thinking about it for a second, and coming on here, I decided it was unnecessary to have that information, as it would always be the same, from cycle to cycle.  So I generate my own angle array for purposes of analysis.

ctr0 (on my card, a PCI 6289) is an internal logic device.  It is designed such that the lines going to and from it are programmable.  By specifying it the way I did, I am telling LV to use the ctr0 device, and to pipe it out to the terminal of my choosing (in this case PFI0).  The frequency counter task updates once per cycle too (which is convenient because that is the same rate as the AI needs updating).  One weird thing with this code is that a full cycle is 360 degrees, and you trigger off of a certain point on that cycle.  Which means that you want to either collect 359 points and get every cycle, or you want to collect 360 points, and get every other cycle (or even less frequent than that, if you are going really fast).

Is that better?

Best of luck,
~milq

Message Edited by Milqman on 04-27-2007 06:04 PM

0 Kudos
Message 6 of 7
(2,855 Views)

Thanks Milq,

   I guess the reason about the 'missing rev' you mentioned when sample 360 points, may be the problem of last A signal pulse before next z pulse comes or the first A sample pulse after the z pulse passed when you set to sample 360 pioints. in the case of last A signal pulse before next Z, that pulse causes to sample 360th point and LV engine may not have enough time to finish all the vi before it gets ready to be triggered by the coming z pulse. Especially the stop task vi inside the loop takes some time to finish and the overhead of read.vi runs every time.

And same may happen to the first A pulse after just being triggered. If the start task vi takes too long time to finish, then you miss this A pulse. So the 360th data you sampled is actually the first 1 data of next rev. Thus next z pulse will be missed as it pasts already when you sample the 360th data.

and when you sample 359 data rather than 360 per rev, the LV engine has a little more time to finish the start or stop task vi. 

I think the another way might be to use two triggers, one is the sampling trigger by A signal and read 1 data per trigger, also counting angle. And z signal trigger another process, which just check the angle counting or reset it if the angle counting appears missing teeth. Because you are continunously sampling data triggered by each A signal so you don't miss any data. But this will introduce a lot more overhead time thus require the LV engine runs very fast.   

Does labview support triggering a process rather than a read.vi? such as a case only executes when a trigger happen. as we use it a lot in dSpace programming, which is useful for this encoder case.

looking forware to hearing your opinion.

Feilong

 

0 Kudos
Message 7 of 7
(2,848 Views)