LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Daqmx Tasks on CRio not clearing?

Solved!
Go to solution

Hello

 

I'm a noob in Labview programming and I'm trying to write a simple VI that runs directly on a Crio 9040 and NI9475 cards (mod3 and mod4). 

I'm trying to write a VI which generates 4 Counter Outputs (daqmx), from which I can control the freq and PWM on the fly. Basically my code is working, but I believe that the task doesn't get cleared after pressing the stop button. 

 

Why I believe this? 

Setting up the front panel like: 

control Counter 1 : mod3/ctr0           And       CO Pulse Terminal : Mod3/PFI0

control Counter 1 : mod3/ ctr1          And       CO Pulse Terminal : Mod3/PFI1

control Counter 1 : mod3/ ctr2          And       CO Pulse Terminal : Mod3/PFI2

control Counter 1 : mod3/ctr3           And       CO Pulse Terminal : Mod3/PFI3

Results in a correct working program. 
I stop the program with the stop button (front panel)

When I change for example CO Pulse Terminal to Mod4/PFI0, and run the VI (deploy on Crio), I see LED from Mod4/PFI0 AND the LED from Mod3/PFI0 blinking (together with the other LEDS)

Therefore it looks like 'FIRST' taks isn't cleared... 

After experimenting, I would reset the Crio (power down/power up) and run the VI again. This is resulting in a good behavior of the program, for example with the settings: 

control Counter 1 : mod3/ctr0           And       CO Pulse Terminal : Mod3/PFI4

control Counter 1 : mod3/ ctr1          And       CO Pulse Terminal : Mod3/PFI5

control Counter 1 : mod3/ ctr2          And       CO Pulse Terminal : Mod3/PFI6

control Counter 1 : mod3/ctr3           And       CO Pulse Terminal : Mod3/PFI7

Only LEDS 4, 5, 6 and 7 are blinking. 

 

Normally I would only use four 'daqmx create channel', daqmx timing, daqmx start, daqmx is task done, daqmx clear task.
In an attempt to fix the strange behavior, I added daqmx create task, daqmx stop task, daqmx control task. 

 

Can anyone help me with fixing this?

Thank you a million times! 

p.s. I tried documenting this post as good as possible, if I miss something, please let me know. 

 

Kristof 

Download All
0 Kudos
Message 1 of 10
(2,567 Views)

Hi Kristof,

 

Adding a "DAQmx Clear Task" before you create a task ensures that previous task settings are discarded:

DAQmx Create.png

See if this helps.

--------------------------------------------------------------------------------------------------------------------------
Help the forum when you get help. Click the "Solution?" icon on the reply that answers your
question. Give "Kudos" to replies that help.
--------------------------------------------------------------------------------------------------------------------------
0 Kudos
Message 2 of 10
(2,533 Views)
Solution
Accepted by topic author foxer0101

Hi 

 

I tried implementing this as shown on the picture and this doens't help. 

 

I implemented it, ran the VI with PFI0, PFI1, PFI2, PFI3 as terminal. I stopped the vi with my front panel stop button and after this I ran the VI with PFI5, PFI1, PFI2, PFI3 as terminal. 

 

After doing this the LEDS of PFI0, PFI1, PFI2, PFI3 AND PFI5 were blinking. 

 

Frustrating... 

 

Kristof 

0 Kudos
Message 3 of 10
(2,487 Views)
Solution
Accepted by topic author foxer0101

I don't know your specific device, but it sure sounds like you've bumped into a characteristic behavior known as "lazy uncommit".  You'll find more info using it as a search term, but here's a few good places to start:

 

Link 1,    Link 2,    Link 3,    Link 4

 

I don't think this behavior is considered "common knowledge."  I've been doing LabVIEW-based DAQ for more than two decades and only learned of it sometime in the last handful of years.

 

In your case, it's probably gonna be simplest to place a call to "DAQmx Reset Device" at the end of your code to remove any signal routes that got set up by your app.

 

 

-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).
Message 4 of 10
(2,471 Views)

Hi!

 

Wow, thanks for pointing me in the right direction! 
I'm trying to get this solved, but Tristating doesn't word for Mod4/PFI3. 

 

I'm also getting some additional 50103 code when I try to use mod3/PFI0:mod3/PFI3 AND mod4/PFI0:mod4/PFI3 toghetter to output a frequency. I make one task per NI 9475 module, containing 4 counter outputs.  Is labview confusing mod4/ctr0 with mod3/ctr0 or does this still have to do with the fouting of the PFI lines? 

 

I'll try some other things tomorrow. Thank you already

 

p.s. I've attached my VI. It's not great, obvious. 

0 Kudos
Message 5 of 10
(2,456 Views)

I have only modest familiarity with the cDAQ family of devices and even less with cRIO.

 

Nonetheless, from what can see on the spec sheets, your 9475 modules do not have internal counters of their own.   They just act as a signal path that connects to the internal counters of the *chassis*.

 

Your 9040 chassis/controller has only 4 internal counters, that's why you can't generate 8 independent outputs simultaneously.

 

I don't have any specific insight about tristating with your hardware.  Have you tried the device reset option instead?

 

 

-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).
Message 6 of 10
(2,428 Views)

Hi Kevin 

 

You are of great help to me! Thanks. 

 

The device reset works perfectly. I got 4 frequencies/PWMs with Counter Output up and running and now I understand why I can't expand to 8 channels. It looked like I was really accessing THE mod3/ctr0 , but I was only accessing ctr0 from the Crio....
Mmmm, any advice on how I could expand my channel count. For now, I want to avoid using the FPGA because of the steep learning curve. 

 

Thank you so much, I really appreciate it! 

 

Kristof 

 

0 Kudos
Message 7 of 10
(2,425 Views)

I must say: avoid programming the FPGA instead of using daqmx. 

0 Kudos
Message 8 of 10
(2,422 Views)
Solution
Accepted by topic author foxer0101

In my quick search, the only cRIO counter/timer device I found is the 9361.  Unfortunately, it's only an input module meant for counter-based measurements.  It doesn't seem to support counter-based outputs.

 

So I'm afraid I don't know a simple *and* inexpensive way to expand your channel count.  It seems like you'll need another 4-counter chassis.  But it'd also take extra work if you need to keep signals sync'ed across 2 different chassis.

 

 

-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).
Message 9 of 10
(2,404 Views)

Hi

Getting a second Crio 9040 is not possible and would only expand my PWM outputs to 8, but I got into using the FPGA and adopted this code: https://www.ni.com/nl-be/support/documentation/supplemental/07/pulse-width-modulation-example-daq-pe... to work on my Crio 9040. 

 

I'm up and running now. 

 

Thanks 

 

Kristof 

Message 10 of 10
(2,379 Views)