Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Control DAQ Pinouts using an Array which connects to Physical Channel Node on DAQmx

Solved!
Go to solution

Hello, 

 

I was trying to work out a way to manipulate several DAQ module pinouts using an index array or a script (.txt) file mechanism which will enable different pinouts to be switched on and off during simulation. I was hoping that this could be achieved by passing it through a text file but I haven't been able to find any examples in the forum or online on how to achieve this. Therefore, instead I have tried to use a Physical Channel Array but again this provides restraints as to what DAQ module pinouts I actually want on and off. Does any one have an example or an idea of what I am looking to achieve that will be compatible with DAQmx functions.

 

The idea I started with is below: 

 

Building an Array to Virtual Channel.PNG 

I soon realised that my current design is really only useful for selecting one pin out using the Enum control from the front panel, so that's not really what I'm looking to achieve. I wish to pass several pinouts to one DAQmx Create Virtual Channel and have the capability of switching on and off those pinouts to a specific binary configuration.   

 

I'm already aware of the NI-DAQmx syntax for specifying physical channel strings (i.e. Dev0/ai0:4) but this would provide limited capability in terms of changing the strings during the simulation run.

 

In NI Max, the test panel option provides Boolean step ups for the the digital output configuration: 

00000000

00000001

00000010

00000011

00000100

...... etc etc

 

So surely this could also be achieved with Analogue Outputs in LabVIEW too and would save a considerable amount of block diagram space. So this type of formatting would be a win win really. I just want to place the hardware through as many possible simulated configurations using the AO pins and then record the configurations into an excel spreadsheet (.xls) file. I'm not sure if my idea is something that is possible in LabVIEW, with the idea of conserving block diagram space and mainpulating several pinouts going into the node of one DAQmx Create Virtual Channel. 


Would appreciate your thoughts and insights with this. 

 

Happy to answer any further questions if I wasn't clear on anything. 

 

Many Thanks

 

0 Kudos
Message 1 of 20
(3,921 Views)

Put the DAQmx Create Virtual Channel in a FOR loop and autoindex on the array of channels.  Use a shift register to update the task as each channel is added.  You will also want to use a DAQmx Create Task before the loop to initialize the shift register.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 20
(3,898 Views)

Hi Crossrulz, 

 

Thanks once again for your input and suggestions. I've tried to follow your advice by placing the array of channels outside the for loop. 

 

I attempted to connect the array of channels directly to the physical channel node without the Index Array block and that was causing a break to the terminal. 

 

Is there anything I need to add to the physical channel array in order for it to be compatible with the physical channel node? 

 

Once I have the solution I will make sure to post it up again as usual. I think a template for this may prove useful to many beginner DAQ hardware users trying to program with LabVIEW. 

 

 

AutoindexandShiftregister.PNG

 

Many Thanks

0 Kudos
Message 3 of 20
(3,872 Views)

Hi again, 

 

I've been working out some possible solutions for what you've mentioned. 

 

I used the Highlight Execution tab which confirmed that a sequence can be passed using the constant array.

 

But what I really want to achieve is running a different sequence after the task has completed during the simulation without having to reconfigure the parameters all over again.

 

What I really mean is I want: 

 

0: On or Off

1: On or Off

2: On or Off

3: On or Off 

4: On or Off

5: On or Off

6: On or Off

7: On or Off

 

So what type of function block would allow me to call the sequence format per iteration. 

 

Capture.PNG 

0 Kudos
Message 4 of 20
(3,862 Views)
Solution
Accepted by topic author neunited

I was picturing something like this


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 20
(3,854 Views)

Thanks Crossrulz, 

 

Your never fail to pour your fountain of knowledge. Please find the updated VI attached with Crossrulz suggestions enclosed. 

 

I suppose the only other question I have is can this Boolean control be automated and passed with countless possibilities. Rather than having to reconfigure the LED's every time the simulation has ended? I just want to know whether it's actually possible to achieve, whereby you can choose the configuration in advance and it will run and pass those combinations.  

PinoutsUsingArrayControl.PNG

0 Kudos
Message 6 of 20
(3,844 Views)
Solution
Accepted by topic author neunited

neunited wrote:  I suppose the only other question I have is can this Boolean control be automated and passed with countless possibilities. Rather than having to reconfigure the LED's every time the simulation has ended?

You can create/manipulate that boolean array however you need to.  The possibilities are endless.  I just used the control for an example.

 

In my applications, I just use a list of channels based on a file of some sort, usually a configuration (ini) file.  This eliminates the need for the boolean array and case structure.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 7 of 20
(3,841 Views)

Hi CrossRulz, 

 

I've spent a lot of today researching configuration (ini) files, and I had not heard of them before. I'm really glad you mention this point as that is exactly what I was looking for.  

 

Unfortunately, I haven't found any examples on their compatibility with DAQmx functions. I was trying to write the program above into a ini file so that I can understand how the scripting would need to be formatted. 

 

Would it be possible for you to illustrate an example of how this can be achieved using ini in a similar fashion. 

 

Initially my impression was that I could pass a bunch Boolean through the Build Path function to determine what channels are ON and OFF. However, I was struggling to interpret how that idea can be converted into ini format. 

 

I'll keep researching in the mean time.

 

Many Thanks

0 Kudos
Message 8 of 20
(3,817 Views)

Away from my computer right now.  But what I do is have a section for each input channel.  Keys will include Name, Physical Channel, Scale, Max, and Min.  So this let's me configure each channel.  My read config VI searches all of the sections and then makes a cluster (or an object in my latest version) for each channel.  I then add all of the channels using a FOR loop like was already shown. 


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 20
(3,813 Views)

Hi Crossrulz, 

 

I'm working on the ini file that you discussed and I'm starting to get the hang of how they work. 

 

I'm just making a small program at the moment trying to ascertain how it will connect to DAQmx. 

 

My ini file reads as: 

 

[Section 1] 

Name = T2, T3, T4

Physical Channel = ao0, ao1, ao2

 

[Section 2] 

Scale = 1, 1, 1

Max = 5, 5, 5

Min = -5, -5, -5

 

Block Diagram File Config.PNGFront Panel Result File Config.PNG

My first question would be is the formatting of my ini code in the correct format, I suppose my debugging query can be answered once I understand where the DAQmx functions come into play. 

 

Many Thanks

0 Kudos
Message 10 of 20
(3,802 Views)