Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

PCIe-6535 logic family

Solved!
Go to solution
Hi,  I’m having trouble configuring the NI PCIe-6535 logic family. Btw. I’m using DAQmx 8.8 in Matlab R2007b.   Configuring the logic family seems to work fine when I use following code: 

%% Create digital output task taskh_o=libpointer('uint32Ptr',0); taskName=''; [err,taskName,taskh_o] = calllib('MyDAQmx','DAQmxCreateTask',taskName,taskh_o); taskh_o=libpointer('uint32Ptr',taskh_o); %% create digital output channel nameToAssignToLines = ''; [err,b,c] = calllib('MyDAQmx','DAQmxCreateDOChan',get(taskh_o,'Value'),'/Dev1/port0',nameToAssignToLines,DAQmx_Val_ChanForAllLines); % [int32, string, string] = DAQmxCreateDOChan(uint32, string, string, int32); % int32 DAQmxCreateDOChan (TaskHandle taskHandle, const char lines[], const char nameToAssignToLines[], int32 lineGrouping); %% set logic family logicFamily = DAQmx_Val_2point5V; [err,b] = calllib('MyDAQmx','DAQmxSetDOLogicFamily',get(taskh_o,'Value'),'/Dev1/port0',logicFamily); % [int32, string] = DAQmxSetDOLogicFamily(uint32, string, int32); % int32 __CFUNC DAQmxSetDOLogicFamily(TaskHandle taskHandle, const char channel[], int32 data);

 

 
 However, when I use separate lines to define a channel instead of a complete port, I get problems:  

%% create digital output channel nameToAssignToLines = ''; outputLines = '/Dev1/line0, /Dev1/line2, /Dev1/line3' [err,b,c] = calllib('MyDAQmx','DAQmxCreateDOChan',get(taskh_o,'Value'),outputLines,nameToAssignToLines,DAQmx_Val_ChanForAllLines); % [int32, string, string] = DAQmxCreateDOChan(uint32, string, string, int32); % int32 DAQmxCreateDOChan (TaskHandle taskHandle, const char lines[], const char nameToAssignToLines[], int32 lineGrouping); %% set logic family logicFamily = DAQmx_Val_2point5V; [err,b] = calllib('MyDAQmx','DAQmxSetDOLogicFamily',get(taskh_o,'Value'),outputLines,logicFamily); %% [int32, string] = DAQmxSetDOLogicFamily(uint32, string, int32); %% int32 DAQmxSetDOLogicFamily(TaskHandle taskHandle, const char channel[], int32 data);

 

 
 Error -200641: property cannot be set separately for each line. This error speaks for itself, however I want to change the logic family of all the lines to a common value, but I don’t have a clue of how to achieve this. So does anybody have any suggestions? Thanks very much!
0 Kudos
Message 1 of 10
(5,563 Views)

Hello,

 

 

When specifing a line, you also have to specify the port to which the line belongs.

 

 Your line:

outputLines = '/Dev1/line0, /Dev1/line2, /Dev1/line3'
 Will have to become (assuming you use the lines of Port0):
outputLines = '/Dev1/Port0/line0, /Dev1/Port0/line2, /Dev1/Port0/line3'

 

 

 

Best regards,
Joeri

National Instruments
Servicesg
0 Kudos
Message 2 of 10
(5,510 Views)

Hi Joeri,

 

I finally found some time to try you suggestion. However, I still get the same error message as in my previous post. 

But, when I have just one line in my output task (eg. outputLines = '/Dev1/Port0/line0') it does work fine.

 

Unfortunately, when I want to have multiple lines in the output task (eg. outputLines = '/Dev1/Port0/line0, /Dev1/Port0/line2, /Dev1/Port0/line3') it does not work.

 

When I try to specify the lines as a port (eg. outputLines = '/Dev1/Port0') for the DAQmxSetDOLogicFamily function, I get following error:

 

"-200486: Specified channel is not in the task"
 

Any idea what I could do to solve this issue?

Thanks very much!

0 Kudos
Message 3 of 10
(5,437 Views)

Hello,

 

 

At first sight I cannot say you are doing anything wrong.

But the error you mention is saying that you want to change a property of one or more channels which is not defined yet. So there must be something missing.

As your are developing in a non National Instruments environment, we cannot confirm if your are using the right syntax. 

 

I tried the examples delivered with NI-DAQmx for the C programming environments adding the "DAQmxSetDOLogicFamily" function myself without any problem.

 

To initialize multiple consecutive  channels, you can also use following syntax which will address all 8 channels of Port0 in this case.

Maybe worth a try.

 

/Dev1/Port0/line0:7

 

 

 

 Last thing I would like to ask.

Are you using The MathWorks®, Inc.’s Data Acquisition Toolbox for MATLAB® software or the NI-DAQmx Tools for Data Acquisition with The Mathworks, Inc. MATLAB® Software? 

 

That last one is a free library to facilitate to work with National Instruments data acquisition hardware from MATLAB® software.

If you don't know that library. please download it (it's free)  and have a look at the included code examples.

It also gives you the possibility to open the NI-DAQmx Help from within MATLAB®.

 

If you are using The MathWorks®, Inc.’s Data Acquisition Toolbox for MATLAB® software, it may be possible that the DAQmxSetDOLogicFamily property function is not supported within the toolbox.  The MathWorks® Support should be able to tell you that.

Best regards,
Joeri

National Instruments
Servicesg
0 Kudos
Message 4 of 10
(5,421 Views)

Hi Joeri,

 

I finally found some time to get back to this issue again, however so far without much luck.

 

I tried to install the NI-DAXmx tools, but this is giving me an error when I launch Matlab, so I uninstalled it again. I'm using Matlab R2007b.

 

Could you perhaps provide me a C programming example that works with any number of channels (consecutive and non-consecutive channels) using the 'DAQmxSetDOLogicFamily' function?

Hopefully this will help me to sort the problem out.

 

Thanks very much! 

 

0 Kudos
Message 5 of 10
(5,296 Views)

Hello,

 

 

The examples and documentation are by default also installed when installing the NI-DAQmx driver.
Easiest to access them is using your Start Menu structure:

For a Windows XP: Start > All Programs > National Instruments > NI-DAQ > Text-Based Code Support

 

Here you will find the "NI-DAQmx C Reference Help" and shortcuts to the examples.

 

 

Best regards,
Joeri

National Instruments
Servicesg
0 Kudos
Message 6 of 10
(5,273 Views)

Hi Joeri,

 

I already know about of the C examples that come with the NI-DAQmx installation. I used these as a starting point for my Matlab code.

However, none of the examples use the 'DAQmxSetDOLogicFamily' function, which is giving me problems. 

 

So could you provide me a simple example that uses the 'DAQmxSetDOLogicFamily' function with multiple channels?

 

I appreciate your help!

0 Kudos
Message 7 of 10
(5,271 Views)
Solution
Accepted by topic author asicDude

Hi asicDude,

 

The easiest solution is to pass an empty string for the "channel" parameter of DAQmxSetDOLogicFamily(). This tells NI-DAQmx to set the property on all channels in the task.

 

Why doesn't it work when you specify the lines separately? Functions for setting DAQmx channel attributes normally take a virtual channel name for the "channel" parameter. Only a few of these functions (such as DAQmxSetDOTristate()) also accept physical channel names. This is to handle the case where a single virtual channel contains multiple physical channels (multiple lines).

 

The virtual channel name is set based on the "nameToAssignToLines" parameter on DAQmxCreateDOChan(). When you pass an empty string for this parameter, the virtual channel name is set based the physical channel name. If the virtual channel only contains one physical channel, then the virtual and physical channel names end up being the same (e.g. "Dev1/port0"). But if the virtual channel contains multiple physical channels (e.g. "Dev1/port0/line0,Dev1/port0/line2:3"), the virtual channel name is the first physical channel name followed by ellipses (e.g. "Dev1/port0/line0...").

 

If you need to set the property on specific channels but not others, you have a few options. You could hardcode "Dev1/port0/line0..." for the "channel" parameter. You could also query the channel names using DAQmxGetTaskChannels(). The best approach would be to choose your own virtual channel names by passing something other than an empty string (even something like "myChan") as the "nameToAssignToLines" parameter on the create channel function. Then pass the same string for the "channel" property on DAQmxSetDOLogicFamily().

 

Brad

---
Brad Keryan
NI R&D
Message 8 of 10
(5,252 Views)

Hey asicDude,

 

I am a little curious as to why it matters which channels you are trying to set the voltage levels on? You can only have one voltage level per board with the PCIe-6535's (same for 6536's and 6537's). As it mentions in the Help for the 6535/6/7's:

"The NI 6535/6536/6537 logic families support either 2.5 V Logic or 3.3 V Logic. The device uses the same logic family for both digital generation and acquisition. The configured logic family sets the voltage levels used for all data, clocks, triggers, and events. The NI 6535/6536/6537 specifications list the actual voltage levels defined by these logic families."

 

When you say that it works in the first line of code in your first post, did you check the output voltage level on data lines or ports that you did not set, and are they different, or are they the same voltage level?

 

Regards,

DJ L.

Message Edited by DJ L. on 08-21-2009 04:25 PM
0 Kudos
Message 9 of 10
(5,247 Views)

Hi Brad,

 

Choosing my own virtual channel name did the trick. It's working fine now.

Many thanks for your detailed explanation!

 

DJ L.

I'm aware the logic level is a global setting. I was just getting some errors related to channels, which were not in the task.

 

Cheers!

0 Kudos
Message 10 of 10
(5,223 Views)