LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Square Waveform to DIO Port?

Newbie question: I am trying to use "Square Waveform.vi" to generate a waveform to send to Port A using "Write to Digital Line.vi," and am running into multiple obstacles.

My goal is to use one of the waveform generators (and its built-in phase, frequency, and duty cycle inputs) to write the I/O line high or low. According to KnowledgeBase document 20A9CHYF "What Happens When I Wire a Waveform Data Type to a Numeric or an Array of Numerics," I should be able to plop this output into a numeric function like "Greater?" and get a single boolean output (which I can use to write to the port). However, as can be seen in the attached "Skitter.vi," my output is, instead, an array of booleans, and the port doesn't want to see that.

I
've tried making use of "Get Waveform Attribute.vi" and "Get Waveform Components.vi" to try to get the most recent Y value, but I apparently need to know the index for the array, which I can't seem to determine.

As can be seen in "Skitter.vi," I've also tried using "Square Wave PtByPt.vi," hoping that it might be easier since it definitely outputs a single double instead of an array. But I can't get it to run. I'm not sure if I have the "time" input wired correctly.

In any case, this seems to be getting more and more complicated, so I'm wondering if I'm missing some much more simple approach. (Or if I'm going to have to create a digital I/O square wave generator from scratch.) Any thoughts?
0 Kudos
Message 1 of 6
(3,286 Views)
You should be able to use the Get Waveform Components VI in conjunction with the Index Array to get the Index you need. It is most likely index 0 (default). This will then give you the needed numeric. If the boolean is then an issue simply use a conversion function to take the boolean to a decimal number.
0 Kudos
Message 2 of 6
(3,286 Views)
I've put in the two functions as you've suggested, but the problem seems to be that "Square Waveform.vi" is not generating a waveform. As can be seen in the attached "Skitter.vi," my only inputs are frequency and duty cycle. Am I missing something here?

Also, if I use the Index Array function using the default index of 0, won't I just always get the first Y value in the array (i.e. the initial value, which won't change)?

Note that I *have* been able to work around the problem by using the "Square Wave PtByPt.vi" (I just needed to divide the output of the millisecond clock by 1000), but I'm curious why "Square Waveform.vi" isn't working (since I'm sure I'll need it--or something like it--in the future.

Thanks!
0 Kudos
Message 3 of 6
(3,286 Views)
Is it just one line you are writing high and low? I will look at your code to attempt to get you the right answer. You can also email me at john.shoust@ni.com if it's more convenient.
0 Kudos
Message 4 of 6
(3,286 Views)
I think part of the issue is that the function wants to put out an array of elements but all you want is a 1 then a 0, 1 then 0, etc... Working with the single point is probably the way to go. In addition you could probably create your own 1 and 0 generator if needed.
0 Kudos
Message 6 of 6
(3,286 Views)
Scott;

The approach you take will depend on what type of DAQ board you are using there.

If you are using one of the Digital boards of the 653x family, you can do pattern output generation and specify the digital values that will be output on the ports.

If you are using one of the MIO DAQ boards, you will need to update the digital lines by Software calls, meaning that the timing will be held by Software, and you can't expect good accuracy of it.

Regardless the board and approach chosen, you can't work with floating point numbers to generate the waveform. You will either use integer numbers if you are working with the 653x board, or boolean values if you are using the MIO boards.

Hope this helps.
Filipe A.
Applications Engineer
National Instruments
0 Kudos
Message 5 of 6
(3,286 Views)