Signal Conditioning

cancel
Showing results for 
Search instead for 
Did you mean: 

Using Measurement Studio for VB.NET to Scan from SCXI

Is it possible to use Measurement Studio 2003 and VB.NET to scan channels from an SCXI 1125?  The only example code I could find was for VB 6.  I know that DAQ for VB 6 is nothing like DAQmx for Measurement Studio for .NET.  I'm using a PCI-6030E to read from an SCXI 1125. 
 
Source for example code or manuals would be greatly appreciated!
 
If it is anything like using a M series card then would this be correct (assuming correct channel string)?
 
Dev 1, SCXI 0, Slot 1, Channels 0-7

' Read from device 1

Try

'Create a new task

myTask =

New Task("aiTask")

'Create a virtual channel

myTask.AIChannels.CreateVoltageChannel("ob1!sc0!md1!n0:n7", "", _

CType(-1, AITerminalConfiguration), 0, 5, AIVoltageUnits.Volts)

'Verify the Task

myTask.Control(TaskAction.Verify)

reader =

New AnalogMultiChannelReader(myTask.Stream)

'Set the loop rate and enable the timer

data0 = reader.ReadMultiSample(totalSamples)

myTask.Dispose()

Catch exception As DaqException

'Dispose the Task and Disable the Timer

myTask.Dispose()

MessageBox.Show(exception.Message)

End Try

Message Edited by SCXI and MS 2k3-VB.NET on 09-13-2005 10:18 AM

Programming Data Acquisition and Control in Measurement Studio and Labwindows/CVI
0 Kudos
Message 1 of 6
(3,939 Views)
Hello,
Sure you can acquire data from an SCXI module using NI-DAQmx and VB.net.  The naming convention is just a little different with NI-DAQmx.  To find the name of the physical channel of an SCXI module, follow these steps:  1) Open Measurement and Automation Explorer (MAX).  2) Expand Devices and interfaces and NI-DAQmx Devices.  3) Right-click on the SCXI chassis and choose Properties.  On the Modules tab, the column for Device Identifier is how you id the module.  So if you had a module with a device identifier "SC1Mod1" and you wanted to acquire data from channel 0 of that module, the physical channel string you would use is:  "SC1Mod1/ai0", and if you wanted channels 0 through 7, it would be this:  "SC1Mod1/ai0:7".  Hope this helps!
-Alan A.
0 Kudos
Message 2 of 6
(3,925 Views)
And the code is the same other than that?  If so that will be great!
 
What about setting the gain and voltage scale programatically?  Am I limited to doing that in MAX or can I have the program do it?
 
We use LabVIEW and SCXI almost exclusively out here.  I want to write a VB application that is very custom.  Channels may be different from one test to the next, PWM or AO needs may be different from one test to the next.  Set points, etc.  I want to have a configuration file that handles these parameters so that one program can do any range of tests. 
 
Thanks!
Programming Data Acquisition and Control in Measurement Studio and Labwindows/CVI
0 Kudos
Message 3 of 6
(3,923 Views)
Nevermind.  I found an example that tells me everything I need to know.  Thanks!
Programming Data Acquisition and Control in Measurement Studio and Labwindows/CVI
0 Kudos
Message 4 of 6
(3,912 Views)
Hello,
For the sake of anyone else who might read this thread, could you please re-post and attach the program you found to be helpful?  Thanks:)
-Alan A
0 Kudos
Message 5 of 6
(3,909 Views)
I'll post the code I pulled out of it mixed with my code because it is more simplistic.  The example I used came with the examples package with Measurement Studio.  I must say I was pretty intimidated intially by DAQmx, but now that I know what I am doing DAQmx is GREAT!  I had attached the file and pasted the code.  If you have any questions, respond to this message and I will recieve an email.
 
Try
 myTask = New Task("thermoTask")
 Dim myChannel As AIChannel
 Dim autoZeroMode As AIAutoZeroMode
 myChannel = myTask.AIChannels.CreateThermocoupleChannel("SC1Mod1/ai0:1", "", 50, 100, _
  AIThermocoupleType.K, AITemperatureUnits.DegreesF)
 myChannel.AutoZeroMode = AIAutoZeroMode.None
 myTask.Timing.ConfigureSampleClock("", Convert.ToDouble(33000), _
  SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, 100)
 reader = New AnalogMultiChannelReader(myTask.Stream)
 DataArray = reader.ReadMultiSample(100)
Catch exception As DaqException
 MessageBox.Show(exception.Message)
 myTask.Dispose()
End Try       
For g = 0 To 1
 Sum(g) = 0
Next
For h = 0 To 1
 For g = 0 To NumSamples - 1
  Sum(h) = Sum(h) + DataArray(h, g)
 Next
Next
For h = 0 To 1
 Average(h, 0) = Sum(h) / NumSamples
Next
thrComputer.Value = Average(0, 0)
thrOffice.Value = Average(1, 0)
wfgTemperature.PlotYAppendMultiple(Average)
 
 
Programming Data Acquisition and Control in Measurement Studio and Labwindows/CVI
0 Kudos
Message 6 of 6
(3,906 Views)