Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Repeating Digital write

Hi,

I'm trying to write the same sequence of data, stored in an array, a (user) selectable number of times. The problem I'm having is that sometimes the data isn't being sent correctly. My hardware is a USB 6221, running Labview 8.6.

I've cut down the final vi to make it a bit easier to follow. The attached vi trys to do the following:

 

1. Starts a counter to act as the sample clock, and sets up the digital write to use this sample clock.

2. Takes the data from the array (loaded via the front panel) and re-shapes it for the digital write.

3. Use a sequence to start the clock before the first digital write.

4. Write the same data again.

5. Clear the tasks.

 

What happens is that sometimes the second write doesn't make it to the oscilloscope! I've checked the 'number of samples written' output from both digital writes and this is ok. I've also added other delays just in case I'm missing something. I'm monitoring the output of pin 0 of port 0 so with the sequence 1,0,1,0 I should see two pulses for each write, four in total. What I see is two, three or four pulses.

 

 

The plan is for the user to select how many pulses are sent out, so the second write will be in a loop, when I get it working. The actual program is a bit more complex then this one as I need to control the time of the high and low periods, so I can't use a finite number of pulses.

 

Thanks,

Richard

0 Kudos
Message 1 of 5
(3,419 Views)

Update:

Spotted an error in 3 above, digital write should start before the clock. Now this is changed I always get two pulses (from the first write) and nothing from the second, but still get the correct numbers from 'samples written'.

New vi attached.

0 Kudos
Message 2 of 5
(3,413 Views)

Just to help, attached are two screen shots from the oscilloscope showing the problem. correct.jpg shows the 8 pulses on the top trace, and the sample clock on the bottom. wrong.jpg is the output from the same problem but only shows 6 pulses, and the time the sample clock runs for is shorter. (I don't know if that's related). Also attached is the vi that I used to get the screen shots. As before, the digital write vi says it's sent out the correct number of bytes.

Richard

Download All
0 Kudos
Message 3 of 5
(3,396 Views)

Hi Richard,

 

Have you seen the examle in the LabVIEW Example Finder called "Correlated Dig Write With Counter.vi" ?  This example demonstrates how to output a correlated digital waveform using a counter as a clock.  It is very similar to your application.  However, there is some checking in the example to make sure the DAQmx Task is done before it is cleared.

 

Best regards,

 

Tony Gibbs

Applications Engineer

NIUK

0 Kudos
Message 4 of 5
(3,334 Views)

Tony,

Thanks for the reply. I've seen that example and tried to use the 'wait until done' vi but it still didn't work as expected. In the end I just put a simple delay at the end before stopping the tasks. This works but doesn't look very good!

Regards,

Richard

0 Kudos
Message 5 of 5
(3,316 Views)