From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Alternating digital waveform on 2 lines

Solved!
Go to solution

I send two on/off waveforms as an output to port0/line0 and port0/line1 using a PCIe-6363/BNC-2110 to modulate two lasers.
Please see the attached .vi.
Before you run the LabVIEW program one can choose the alternating frequency.
That works pretty fine, you can easily connect an Oscilloscope to the outputs and see the alternating digital waves.
My problem here is, that as soon as I hit the stop button the program stops (obviously) but keeps one of the last modulation outputs on.
I want to alter the program that when I hit the stop-button both outputs switch to 0 (off - basically switching the laser modulation off).

Whatever I do here, e.g. adding some if-condition, adding an additional DAQmx write behind the loop, etc.... gives me 1) an error (like: 200557, 200587) and 2) never sets the modulation to 0 (off).
Maybe someone here has an idea how to solve that?

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

What I'd probably do here is that after exiting the loop due to the stop button, I'd clear the existing task and redefine a new one with the same DO channels.  Only this time, don't call DAQmx Timing thus leaving the task in immediate, on-demand mode.    All you need is DAQmx Create Channel followed by DAQmx Write (with auto start set True) to drive the outputs OFF.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 2 of 8
(3,878 Views)

Thanks for the reply.

Yeah, I know, it sounds like an obvious solution but it doesn't work.

Gives error 200287:

"Possible reason(s):
Attempted to write to an invalid combination of position and offset. The position and offset specified a sample prior to the first sample generated (sample 0). Make sure any negative write offset specified will select a valid sample when combined with the write position.

Property: RelativeTo
Requested Value: Current Write Position

Property: Offset
Requested Value: 0

Task Name: _unnamedTask<4>"

See attached. I tried already several other solutions but I mostly get the 200287 error. And if I manage to somehow avoid any error the program does not set the modulation to OFF.

0 Kudos
Message 3 of 8
(3,870 Views)

Just want to add:

Only adding the "clear task" or "end task" gives already the error 200287.

0 Kudos
Message 4 of 8
(3,866 Views)

The -200287 error is happening while you iterate in the loop.  Put debug probes on the error cluster and different points and you'll see that error *before* you exit the loop and attempt to do the immediate, on-demand Write.

 

You should clear the original task outside the loop before making a new one for the on-demand Write.

 

There are other problems with the way you repeatedly loop & write that are probably responsible for the other errors you've been seeing.   Why are you configuring a finite acquisition but then writing to it continuously?

 

Below is a snippet that ran without error on a very similar board (PCIe-6341).  It does a finite generation of the samples you defined in your array then sets the digital outputs low.  It won't be the last piece of code you need for your overall app, but it will illustrate a way to avoid the errors that have you hung up.

 

 

-Kevin P

 

finite do.png

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
Message 5 of 8
(3,858 Views)

Thanks again.

However, that is still not what I want to do.
Your solution works for me too: I run the program and after the 10 finite samples the modulation stops and as soon as I hit the stop button the both values switch to OFF. That's nice.
But that only works for a finite amount of samples. If I switch to continuous sample mode I get immediately an error 200292, saying my buffer size is not correct. And I do not know before I run the program how often I need the modulation.

 

The problem is: I want a continuous digital ON/OFF modulation on two port lines where I can adjust the frequency(before I start the program) as long as until I hit the stop button. And as soon as I hit stop the modulation should switch both values to OFF.

0 Kudos
Message 6 of 8
(3,833 Views)
Solution
Accepted by topic author ben3000

Make any progress with mods?   Below is another snippet that works more like what you're looking for, if I understood correctly.  (I switched from using a digital waveform to regular arrays b/c I'm more used to that simpler form).

 

 

-Kevin P

 

continuous regenerating do.png

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
Message 7 of 8
(3,818 Views)

Thanks for the snippet. That seems to work for me too.

One minor change I had to do: I had to change the digital write to U32. With U8 I've got an error. Anyway: Awesome! Thanks again.
Please find attached a snippet and the program. It might help others.
screenShotTestModuV3.png

0 Kudos
Message 8 of 8
(3,807 Views)