LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

ChanPerLine vs. ChanForAllLines

Hello,

 

I have writen a program. Know I am at the point where I create a digital input. I tried to understand the command DQXmxCreateDIChan. I use PCIe-6343.

There is one point I can not interpret and this is the line grouping. I read the help description but didn't understand that either. Can someone explain to me what these two option means concrete?

ChanPerLine

ChanForAllLines

 

Best regards

 

 

 

0 Kudos
Message 1 of 11
(3,729 Views)

As you don't state which documentation you already read and what exactly you do not understand in there, i try my best:

ChanPerLine means that you configure a single channel inside the DAQmx Task for a single line (pin) of your digital device. The datatype of that channel is usually a scalar boolean value (TRUE or FALSE).

As a result, dealing with multiple lines inside a task (e.g. Port0/Line0, Port0/Line3) requires you to deal with data arrays, most likely boolean arrays (1D for single value per channel, 2D for multiple values per channel).

 

Picking ChanForAllLines means that you have a single channel inside your DAQmx Task to handle multiple lines.

As a result, you can use binary values (e.g. U8) to read/write values to the whole lines at once. Each line represents a single bit here, the order is identical to the order you represented the lines to the channel.

Example: Port0/Line0, Port0/Line3 means that bit 0 represents Line0, bit 1 Line3.

A value of

0: all lines FALSE (low).

1: Line0 is TRUE, rest FALSE

2: Line3 is TRUE, rest FALSE

3: Line0 and Line3 is TRUE, rest false

....

 

Swapping the order of lines results in swapping of bits.

Example: Port0/Line3, Port0/Line0

0: all lines FALSE

1: Line3 is TRUE, rest FALSE

2: Line0 is TRUE, rest FALSE

...

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 11
(3,702 Views)

Ok thank you.

 

I use this for change detection but I do not know how I can use ChanForAllLines for these. So from my lines only 2 should have the change detection. 

So how must I write my "Change Detection Timing" that I can use such a binary pattern that says that only Port0/Line0 and Port0/Line1 should get watched. 

 

I created a digital input Port0/Line0:1. Now it works like this. The change detection works on two pins who are side by side Port0/Line0:1. Then I said das both channels should get watched. When a rising edge comes both lines should react when a falling edge comes only line 1 should react. But in the future my program gets more of these change detection and know I do not know how I can say which channel should react at which edge. I heard the this works over a binary pattern but I have no idea how I program that.

As example: 

I would like to watch Port0/Line0, Port0/Line5, Port0/Line6, Port0/Line10

Port0/Line0: rising egde

Port0/Line5: falling egde

Port0/Line6: both egdes

Port0/Line10: rising egde

 

Is such a thing possible or must I set my timing on both edges and when one of the channel reacts I read the Data from all the pins and find out which data I would like to have. 

At the moment I can only use pins who are side by side. 

 

Best regards

 

0 Kudos
Message 3 of 11
(3,686 Views)

Just reading the documentation (so no actual testing), you should use

DAQmxCfgChangeDetectionTiming

and define all rising/falling edge combinations as timing sources.

 

Remember that the task shares the timing for all channels. So you will get a data point for each line everytime one of the selected timing lines has an appropriate change.

It is the task of your software to make sure that no buffer overflows (read fast enough) and to discard values from lines you do not need. Configuring ChanForAllLines means that you can use binary operations to mask irrelevant lines.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 4 of 11
(3,674 Views)

Ok thank you. That is the problem. I do not know how I use such a binary operation to mask these line I would like to use. Now I use pins side by side. That can I realise with port0/line0:3 (four pins). But later it can be that I use pins who are not side by side. And there I can use such a binary mask but I do not know how I can write such a line or if this is even possible. The same is for the DAQmxCfgChangeDetectionTiming. Now I write in the falling and rising section the name of the line. I can do that because I have only one line für each section but later I will have some more and now I would like to know how I can use the binary operation also here. To be exactly what I must write in these two section that I can use my detection for more line. What do you mean with "timing sources"?

 

I have the problem, that I do not exactly know how I should write these two lines with binary operations. 😕

 

Best regards

0 Kudos
Message 5 of 11
(3,662 Views)

Binary masking can be done by using bitwise operations like AND, OR, XOR, ...

You can find these operations in the boolean palette. They also work on numeric values.

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 6 of 11
(3,654 Views)

@Norbert: the principle is correct, but please remember we are in the CVI board here: no palette is present in C language and 'boolean' itself is a different concept! Smiley Wink

Masks can be built up by using OR operator ( | ) on the appropriate values (0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 represent the eight bits of the lower byte in a word).



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 7 of 11
(3,651 Views)

@RobertoBozzolo wrote:

@Norbert: the principle is correct, but please remember we are in the CVI board here: no palette is present in C language [...]


Correct. Sorry about the confusion; dealing too much with LV 🙂

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 8 of 11
(3,647 Views)

Is it possible to show me a concrete example (whole line of the code) how I use the change detection for more than one channel (pin) who are not side by side (with binaray mask)? I have no idea how it looks like.

I need an example how I can create more than than one digital input (pin) who are not side by side with the binary pattern and how I write the line for DAQmxCfgChangeDetectionTiming with the binary pattern. 

At the moment we spoke about how it works --> binary pattern. But I tried it in the code an nothing works. So I think I do it wrong, so can you show me an example if it is possible? 🙂

 

Best regards

0 Kudos
Message 9 of 11
(3,632 Views)

I recommend you to show us what you already tried. Also, what does "side-by-side" mean for you?

For digital devices, we have lines and ports. Some users do not know the term line, so the synonym "pin" is also often used. However, i am not aware of any synonym for port.

I recommend you to read the documentation for the DAQmx trigger functions as these include the information i think you are looking for.

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 10 of 11
(3,618 Views)