Jump to content

DAQmx Task - Scanning the same channel multiple times


Recommended Posts

This is a question I've wondered about for a long time...

During continuous acquisition is there an easy way to scan from the same channel multiple times within a task set up in MAX before switching to the next channel? By default, channels within a task are scanned one at a time and this process continues - acquire one point, switch to the next channel, acquire one point, and continue through the list.

Where the time relationship between channels is not important, sometimes it makes sense to acquire several samples from one channel before switching to the next. Chapter 4 in the M series user manual discusses this under Multi-Channel Scanning Considerations > Avoid Scanning Faster Than Necessary.

Back in September 2009 an NI engineer came up with a workable solution, but you can't use MAX to configure the task because he configures the channels using FOR loops to create a channel for every sample for every channel.

http://decibel.ni.com/content/docs/DOC-6901

I've had an application running for a while where I commit the cardinal sin of starting and stopping tasks during acquisition. So rather than have one task in MAX configured with all the channels, I've got multiple tasks, each with one channel configured. This allows me to control how the channels are scanned.

I just feel like I'm missing something. There has to be an easier and more efficient way of doing this. Any ideas or experience with this?

Eric

Link to comment

Can you describe your application in a bit more detail?

If you are scanning digital channels, may be you could use change detection on the channels?

How about setting up the channels that don't need to be scanned multiple times in one task and the other channels in separate tasks?

Neville.

Edited by Neville D
Link to comment

How about setting up the channels that don't need to be scanned multiple times in one task and the other channels in separate tasks?

That's one idea. However, I'm still starting and stopping tasks to accomplish this.

I'm using an old SCXI system for all analog measurements - thermocouples, 4-wire RTDs, current inputs. I average measured samples to increase accuracy, especially on the 4-wire RTDs. The RTDs happen to be connected to a mechanically multiplexed module. The NI manual suggests scanning multiple samples from one channel before switching to the next channel to avoid wearing out the mechanical multiplexer. The channel switching is actually audible. Imagine switching a mechanical multiplexer 100 times/second - it would wear out quickly.

I've seen this recommended scanning method mentioned multiple times in NI documentation, but there doesn't seem to be any obvious and convenient way to implement it using channels configured in MAX without starting/stopping tasks. I'm just hoping I'm missing something.

Maybe this is further incentive to stop using MAX...

post-10503-0-56126500-1301356727_thumb.j

Link to comment

I'm using an old SCXI system for all analog measurements - thermocouples, 4-wire RTDs, current inputs. I average measured samples to increase accuracy, especially on the 4-wire RTDs. The RTDs happen to be connected to a mechanically multiplexed module. The NI manual suggests scanning multiple samples from one channel before switching to the next channel to avoid wearing out the mechanical multiplexer. The channel switching is actually audible. Imagine switching a mechanical multiplexer 100 times/second - it would wear out quickly.

Wow, I remember that hardware from LV 3.1 days... My best guess is they are recommanding you keep switching tasks of 1 channel each. This could be perfectly fine if your monitoring and updates involves seconds (versus milliseconds) and your channel count is low. It wouldn't be my preferred method, however that may be the answer if that's the hardware you've got to work with.

Tim

Link to comment

That's one idea. However, I'm still starting and stopping tasks to accomplish this.

I'm using an old SCXI system for all analog measurements - thermocouples, 4-wire RTDs, current inputs. I average measured samples to increase accuracy, especially on the 4-wire RTDs. The RTDs happen to be connected to a mechanically multiplexed module. The NI manual suggests scanning multiple samples from one channel before switching to the next channel to avoid wearing out the mechanical multiplexer. The channel switching is actually audible. Imagine switching a mechanical multiplexer 100 times/second - it would wear out quickly.

I've seen this recommended scanning method mentioned multiple times in NI documentation, but there doesn't seem to be any obvious and convenient way to implement it using channels configured in MAX without starting/stopping tasks. I'm just hoping I'm missing something.

Maybe this is further incentive to stop using MAX...

I'm still not clear as to what you are trying to accomplish/improve. Maybe a screenshot of the specific part of your code would help.

Reading all those temperature channels means your sample rate can be very slow without affecting accuracy. So what if you have to start and stop the task? You will not be running the loops at kHz speeds any way, so the few ms when you don't have data when the task is being set up are not that important, considering your loop should be running around once a second or slower.

And why bother with MAX? Just configure the channels as you need in your code itself. You don't really need MAX except when trouble shooting initial wiring etc. You can also save your channel configuration generated in the code to MAX if you need.

Split the "slow" and fast channels into two or more separate tasks, read them in their respective software timed loops (can be either while or timed loops), write generated data to a Q to process in a separate loop and your done. Maybe a stop button to stop and clean up when finished.

N.

Link to comment

Wow, I remember that hardware from LV 3.1 days...

Ha ha! I thought vintage was in these days...

Neville,

Thanks for your insight/ideas. Splitting the tasks seems like a good idea. The application works, that's the important thing. For my own education I was wondering if there was a really convenient way to make the hardware scan channels differently. At this point it seems like I know all the options I have to work with.

Eric

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.