LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

syncing 3 pulse trains

I have a need to sync 3 pulse trains. These pulses are typically 50ms in duration; one of them is a clock signal, another is a load/latch type signal, & the 3rd is a data signal which can be a random on/off pulse train. The pulses of the clock are 25ms, the data pulses are 50ms & the latch/load signal is active low & stays low the duration of the pulse train, which is 10 data pulses long.

Before, I had the PCI-6514 & observed random out of sync behaviour between the 3 signals sent out simultaneously from the 6514. I was told this was due to software timing.
I now have a M-series PCI-6221 & can do hardware timing.

Attached is a test VI using 2 pulse trains (one is delayed 50ms w.r.t the other). I get a resource error when I run. Also I have a few questions that I wrote inside the block diagram. I'm not sure why it doesn't work ?

Is there a better way of setting this up ? Should I be using counters or digital lines ? Do I have enough counters for 3 seperate pulse trains ?

Any help would be greatly appreciated.

Thanks,
ak



0 Kudos
Message 1 of 8
(3,469 Views)

I've upgraded my VI & use a counter to act as the sample clock for 2 seperate port 0 lines each with it's own digital waveform.
But I get a resource conflict error - can anyone help me understand why ??

ak

0 Kudos
Message 2 of 8
(3,466 Views)
There are a handful of things going on here.

1) When you wire "Time" down from your CO Pulse Time Channel, to your Digital outs, they are expecting a rate.  There is a units problem there (sec vs. 1/sec).

2) I appears as though you are writing to the digital channels before you start the channels.  You have them configured to output continuously, but you never stop them.

3) It appears as though "Low Time" is not wired, I have never used that block before but if the default is 0, you aren't doing much with it.

4) When/if the VIs execution gets that far, the "DAQmx Task is Done" blocks will just keep on executing because there is no stop condition wired to them.

Where does your "Resource Error" show up, which task/s does it flag?

There are a number of other things that could be going quirky with that app, perhaps starting from that (or another example) again after knowing what you want to do now and learning what you have learned would be a useful exercise.

Best of luck,
~milq
0 Kudos
Message 3 of 8
(3,454 Views)
In addition to the things milqman pointed out, here is where the resource conflict comes from:

The board can only perform one hardware-timed digital output task at a time.  If you've got 2 bits to create, you'll need to interleave the waveforms so that you can create them both with a single task.

I really don't know my way around digital waveforms, so maybe there's some neat function available to perform the merge.  I've done it using boolean arrays or numeric bit patterns, and it's a bit of a challenge to get the merge exactly right for all possible circumstances.

Then again, in your specific case, the two bits seem to need a very consistent timing relationship, and that should make the merge algorithm more straightforward. 

-Kevin P.
ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 4 of 8
(3,448 Views)

Thanks milqman, I've corrected items 1 & 3. For #2, my understanding is that the DAQmx Write vi just sends the data into a buffer - it's the Start Task vi that takes the buffer contents & sends them to the appropriate location. For #3, inside the while loop, the tasks are stopped if there's an error or the stop button is pressed. Attached is the corrected version.

Kevin,  I hope I can use 2 tasks concurrently. My vi is a stripped down version of the NI example : Multi-Function Synch Dig Read Write with Counter.vi that seems to handle 3 tasks at the same time. So I'm guessing it's possible.
I mean all I want to do is to output 2 bit patterns at the same time from 2 different digital lines - there has to be a way to do this I'm sure !

ak

0 Kudos
Message 5 of 8
(3,437 Views)
The specific problem with your 2 buffered digital tasks is that they are both buffered (hardware timed) digital output tasks.  You can only have 1 buffered digital output task at a time.  Along with that task, you may also have 1 buffered digital input task, 1 or 2 buffered counter tasks, 1 buffered analog input task, and 1 buffered analog output task.

So, yes, the board can handle many tasks simultaneously, such as the 3 found in the example you mentioned.  But it cannot handle 2 separate buffered digital output tasks.  (Nor could it handle 2 buffered digital input tasks, or 2 buffered analog output, or 2 buffered analog input).

You can, however, create a single digital output task where you define the channel to contain multiple bits.  I think your board allows up to a maximum of 8 bits for the hw-timed digital port.  In fact, the default value for 'SCLOCK channel' that was in your latest post already does this with the channel string "Dev1/port0/line4:7', referring to the 4 bits ranging from 4 through 7.

-Kevin P.
ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 6 of 8
(3,429 Views)

OK - I understand I need to have only 1task that encompasses 2 channels.
But now I'm not sure how to use different timing on the 2 channels & can I have a write for each channel ? When I did that I got a buffer error. (version F)
So I used 1 write & a 1D array of digital waveforms - now I get a different buffer error (version E).

Could you please post an example - modifiying my vi or an jpg of yours ?

ak


Download All
0 Kudos
Message 7 of 8
(3,412 Views)
I'm not near a LabVIEW PC and can't look at your attachments or create an example now.   Here's what comments I can offer in the meantime:
 
1. A simple example regarding how to control unique timing for the two bits.  Consider trying to generate 2 square waves, one at 3 Hz the other at 4 Hz.  How can you do this with 2 DO bits?
 
Well, you first need to think carefully about the timing relationship.  You need a basic unit of time that divides evenly into both 1/3 second and into 1/4 second.  You further must divide this by at least 2 because there are 2 digital states per cycle.   I end up with 1/24th second.  The pulse that cycles every 1/3 second will have a sequence of 4 low states, 4 high states, 4 low, 4 high, etc.  The cycle repeats after 8 values == 8/24ths second == 1/3 second = 3 Hz.  The 4 Hz pulse will go 3 low, 3 high, 3 low, 3 high.  It repeats every 6 values == 6/24ths second == 1/4 second = 4Hz.
 
So here's what one second of this 2-bit digital buffer could look like:
00
00
00
10
11
11
01
01
00
10
10
10
01
01
01
11
10
10
00
00
01
11
11
11
then cycle back to beginning
 
2. I don't think you can have a separate Write for each channel.  I think you must first merge the data for the two bits as I illustrated above and then perform a single Write that defines both at once.  However, I've never really explored this to *try* to find a way, so I could be wrong.
 
-Kevin P.
 
ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 8 of 8
(3,408 Views)