07-26-2017 08:52 AM
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:
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:
...... 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.
Solved! Go to Solution.
07-26-2017 10:27 AM
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.
07-27-2017 02:58 AM - edited 07-27-2017 02:59 AM
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.
07-27-2017 06:37 AM - edited 07-27-2017 06:53 AM
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.
07-27-2017 08:05 AM
I was picturing something like this
07-27-2017 09:44 AM
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.
07-27-2017 09:59 AM
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.
07-28-2017 01:11 PM
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.
07-28-2017 06:06 PM
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.
07-31-2017 04:09 AM
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:
Name = T2, T3, T4
Physical Channel = ao0, ao1, ao2
Scale = 1, 1, 1
Max = 5, 5, 5
Min = -5, -5, -5
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.