Switch Hardware and Software

cancel
Showing results for 
Search instead for 
Did you mean: 

Decode channel count from "scan list"

Solved!
Go to solution
Is there a way to decode the channel count from a scan list?  The NI example (niSwitch Thermocouple Measurements.vi) that I am using, requires entry of both "scan list" and "number of channels".
0 Kudos
Message 1 of 5
(6,963 Views)

Hello,

 

Accessing the number of channels from the scan list may prove to be difficult due to the fact that there are several different methods that define connections, disconnections, triggering and timing of the scan. e.g. channel1->channel2, ~channel1->channel2, ch0->com0 & ch9->com1, ch0->com0 && ch9->com, ch0:7->com0. For example, parsing the string to extract this number would require comparing the channel names and characters then implementing logic to determine the channel count. Therefore, the most convenient approach would be to enter a value for the number of channels.

Best regards,

 

Ali M

Applications Engineer

National Instruments

Message Edited by Ali M on 04-26-2010 06:33 PM
0 Kudos
Message 2 of 5
(6,937 Views)
Solution
Accepted by ddemara

Hello Ddemara,

 

If you're muxing through a bunch of thermocouple channels, the scan list will not be complex, so we could easily write some code to determine the number of channels.  Our code would need to do the following:

1)Start a counter with value 0.

2)Iterate through the user-defined scan list and add 1 to the counter each time you find a comma.  The last element won't have a comma, so we'll need to add 1 to the value at the end.

3)Find each instance of a colon (':'), then find the two numbers on either side of the colon, subtract those two numbers, and then add them to the counter value.  We don't need to add one to the end value here because we've already included the first element in the series

4)The value of the counter at this point is the number of channels in the scan list.

 

If you have any questions setting this up, post up. Have a great day!

 

FYI: The channel count in the example you mentioned allows us to fetch data from the DMM such that the first array element is always the thermocouple.  If the channel count is wrong, indexing fetched element 0 will result in plugging the wrong value into the CJC input of the thermocouple scaling vi.

-John Sullivan
Problem Solver
0 Kudos
Message 3 of 5
(6,930 Views)
In step 2, above, I mentioned incrementing the counter at each comma ',' but obviously we need to increment at each semicolon ';'
-John Sullivan
Problem Solver
0 Kudos
Message 4 of 5
(6,927 Views)

 thanks john!

0 Kudos
Message 5 of 5
(6,522 Views)