11-15-2016 05:41 AM - edited 11-15-2016 05:44 AM
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
11-16-2016 06:24 AM
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
11-17-2016 07:43 AM - edited 11-17-2016 07:43 AM
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
11-18-2016 02:56 AM
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
11-20-2016 10:00 AM - edited 11-20-2016 10:02 AM
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
11-21-2016 02:53 AM
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.
11-22-2016 02:04 AM - edited 11-22-2016 02:05 AM
@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!
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).
11-22-2016 02:38 AM
@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 🙂
11-26-2016 10:50 AM
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
11-30-2016 02:18 AM
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.