From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Output frequency to a port mentioned in MAX

Solved!
Go to solution

Hi,

 

I am trying to output ca. 100 KHz on a PIF port using NI 6351. I used example from NI example bank and it's working fine with the following code.

 

		DAQmxErrChk (DAQmxCreateTask("",&gTaskHandle));
		DAQmxErrChk (DAQmxCreateCOPulseChanFreq(gTaskHandle, aChannel, aVirtualAddress, DAQmx_Val_Hz, aIdle, 0.0, aFreq, aDuty)); 
		DAQmxErrChk (DAQmxCfgImplicitTiming(gTaskHandle, DAQmx_Val_ContSamps, 1000));

 In the above example, I am creating a COPulseChannel and aChannel represents its physical address (for e.g. Dev1/ctr2) and aVirtualAddress is the one which I can assign to this physical address for future use.

 

My question is:

How can I create a virtual channel in MAX and use its name here with a name say "myFrequencyChannel" and then write a function to output Frequency to this channel?

Motivation:

This was possible till now for all channels like AI/AO/DI/DO, where I defined all channels with virtual names in MAX and then simply performed tasks by forwarding their names (only) to my functions. So the user need not remember always physical channel but just virtual channel names.

 

Thanks in advance.

 

Regards

RB

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

Hi RB,

 

You can use a MAX defined virtual channel in CVI  using the function

DAQmxAddGlobalChansToTask (gTaskHandle, "My_Virtual_Channel_Name");  

 

I hope this answers your questions

 

Best Regards 

 

______________
Florian Abry
Inside Sales Engineer, NI Germany
0 Kudos
Message 2 of 8
(3,757 Views)

Thanks for replying. But after adding channel how can I output frequency on this channel using:

DAQmxErrChk (DAQmxCreateCOPulseChanFreq(gTaskHandle, aChannel, aVirtualAddress, DAQmx_Val_Hz, aIdle, 0.0, aFreq, aDuty)); 

 

I must give aChannel again, although the channel has already been added to the task.

 

Regards

RB

 

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

Hi,

 

I think I misunderstood your questions. I though you wanted to import a Virtual Channel from MAX. 

 As background info: You use the function DAQmxAddGlobalChansToTask when you want to import a global virtual channel from max and DAQmxCreateCOPulseChanFreq when you want to confugure it all programmatically. aVirtualChannel in your example in the name you want to give to the created channel. According to the help, you can also let this field empty. 

 

Long story short, you use either DAQmxAddGlobalChansToTask to import a global channel from MAX or  DAQmxCreateCOPulseChanFreq to document your task programmaticaly. Then you can start your task using.

 

DAQmxStartTask (gTaskHandle);

 

 I still have doubt concerning my understanding of your question. Please let me know if that is answering it.

 

Best regards 

______________
Florian Abry
Inside Sales Engineer, NI Germany
0 Kudos
Message 4 of 8
(3,739 Views)

Yes you have framed my question better than I could do.

 

Anyway, this was something I was always doing for my AI/AO/DI/DO channels already decrated in MAX. DAQmxAddGlobalChansToTas, start task using DAQmxStartTask and then read or write ports. But in case of PFI port, how can I give frequency at the PFI port? The function that I have come accross is DAQmxCreateCOPulseChanFreq and it expect user to create channel programatically (and not the one declared in MAX).

 

Regards

RB

 


0 Kudos
Message 5 of 8
(3,735 Views)

Hi,

 

in the MAX Global Channel for Frequency Measurment, you can find the following options:

 

Virtual Channel.png

 

with Time high and Time Low you can create the same signal than with Frequency + Duty Cycle. Then call the Global Virtual Channel as it is in CVI and it should work.

 

Best Regardss 

______________
Florian Abry
Inside Sales Engineer, NI Germany
0 Kudos
Message 6 of 8
(3,731 Views)

Hello Florian,

 

Almost the same thing I wish to do. I configure my channel as Impulsausgabekanal with a virtual name say "MyChannel". It has a specific High-/Low Dauer. Now when I access this channel from CVI, I should be able to change its high and low Dauer. Here I do not know which function shall I use if I want to run my task with the same channel (by adding it using DAQmxAddGlobalChannelToTask) but with different high/Low dauer?

 

Regards

RB

0 Kudos
Message 7 of 8
(3,721 Views)
Solution
Accepted by dotNet_to_LabW

Hi,

 

That should be doable throught the channel attributes. You can read or overwrite the attributes of your channel (like Properties in LabVIEW). Two of those attributes are high and low times:

 

DAQmxSetChanAttribute (gTaskHandle, "", DAQmx_CO_Pulse_HighTime, 0.1);  //high time = 100ms
DAQmxSetChanAttribute (gTaskHandle, "", DAQmx_CO_Pulse_LowTime, 0.2);   //low time = 200ms

 

 in addition I join a screenshot of the function panel:

pulse.png

 

Was that what you were trying to achieve?

 

Best regards 

______________
Florian Abry
Inside Sales Engineer, NI Germany
Message 8 of 8
(3,714 Views)