Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx and State Machine

Hey all,

I am developing a State Machine in which I need to run four different tasks

1. Generating a Analog Output Voltage

2. Generating a Digital Output

3. Generating a Continious Digital Train pulse (using DAQmx CO pulse freq) -Problem is with this part

4. Counter Read Operation (using DAQmx CI cnt Edges

 

First I have Designed seperate VI's for the Tasks and everything is working fine but when I Designed a State Machine the third Task(Generation of Digital Train Pulse) is not Working. I am not able to find the problem

  My DAQ device is USB-6351, ANY help would be greatly appreciated.

I am attaching the Project File of my State Machine and separate VI which Includes code of Tasks 3 and 4

Please let me know if you need any sort of additional information from me to understand what I am doing.

Download All
0 Kudos
Message 1 of 8
(2,085 Views)

I'm not using LV2019 and can't open your code.  Can you backsave to LV2016 or earlier?  Might you be trying to use the same counter for both the generation and counting tasks?

 

 

-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
(2,070 Views)

I just checked I am using Different counters

Thanks

 

Download All
0 Kudos
Message 3 of 8
(2,065 Views)

What exactly do you mean by "not working"?  Do you get an error code & message?  What are they?   If no error message, what other troubleshooting have you tried?

 

I only looked at the code for Continuous_Train&Counter.vi.  I don't really see anything wrong with your CO task.  Your CI task ought to work too, though you'd probably be better served to use precise & repeatable hardware timing to sample your counts rather than your current scheme of software timing.

 

Your CO task is configured to output to PFI12.  That pin can serve double duty as digital port 2 line 4.  Are you configuring a digital task that uses that same pin?

 

 

-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 4 of 8
(2,050 Views)

Sorry for not clearly explaining my problem

The Problem is with the State Machine code (which is named as Main inside the QKD_v4_2015.zip file

 Continuous_Train&Counter.vi is the code which I designed for tasks 3 and 4 before designing State Machine...

I uploaded it just for your Reference..

The problem with the Sate Machine is The Digital Train pulse is not Generating, It is not showing any errors.

 

0 Kudos
Message 5 of 8
(2,040 Views)

Is the CO task the *only* thing that isn't working?  What's been your process for diagnosing and troubleshooting?

 

I'm asking these very basic questions because the code looks generally ok.  I can't vouch for the physical wiring, your other equipment, or signal compatibility though.

 

The only thing that makes me hesitate at all is that you explicitly reserve the AO task during a state that occurs *before* you set the sample rate, set the buffer size, and write to the buffer.  I'm not 100% sure what things you can change while in the "reserved" state, though I'd expect a DAQmx error (or at least a warning) if you were trying to do something that isn't allowed.

 

I make note of it partly because your CO and DO tasks get triggered by the start of the AO task, and if the AO task errors out rather than starting, I'd expect that neither CO nor DO would operate.  But I'd also expect you to see the corresponding DAQmx error, which you aren't seeing.

 

I can't guess much more unless you can do enough further troubleshooting and description to narrow down the focus for where your problem is.   Try things, take notes, report back.

 

 

-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 6 of 8
(2,036 Views)

hey Kevin,

CO task is successfully working by disabling the DAQmx Property block Before DAQmx Timing in the Intitialize sub vi.

Thank you so much for your help 🙂

 

0 Kudos
Message 7 of 8
(1,981 Views)

I'm a bit surprised that disabling that little chunk of config code fixed things.   In the latest screencap, that's the *only* place you define the pulse train's freq and duty cycle.

 

However the best fix is what would have been a better approach in the first place: define these in the call to "DAQmx Create Virtual Channel" for the CO task.

 

 

-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 8 of 8
(1,973 Views)