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.
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.
08-09-2012 11:07 AM
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
Solved! Go to Solution.
08-10-2012 06:13 AM
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
08-14-2012 02:30 AM
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
08-14-2012 03:01 AM - edited 08-14-2012 03:01 AM
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
08-14-2012 03:33 AM
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
08-14-2012 03:51 AM
Hi,
in the MAX Global Channel for Frequency Measurment, you can find the following options:
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
08-21-2012 12:52 AM
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
08-21-2012 09:39 AM
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:
Was that what you were trying to achieve?
Best regards