10-04-2011 12:41 AM
Hi,
I have written a C# exe program to communicate with USB TC01 using NI-DAQmx 9.1.
However .I am going to deploy the exe file in the factory testsystems with is using NI-DAQmx 8.0.
I did not install NI-DAQmx 9.1 on these system as it is going to cause alot of problem with the legacy production software that
uses NI-DAQMX8.0
Is there any way to write the code that i do not need to install NI-DAQmx9.1 on a PC to make the exe run ?
07-06-2015 11:53 AM
It is amazing the disconnect between how easy the marketing claims temerature data aq is with the USB-TC01 and how easy it actually is.
I can't find a single example of how to interface with the device from a .NET program. All that can be seen are old threads with no answers, or threads with snarky replies like 'you started another thread on this already'.
There are literally more VB6 answers available than .NET. That's been a dead language for 10 years.
It can't be logical that we need to use either a 1.3 gig install of NI-DAQmx or 'no drivers needed'. There has to be some in-between.
Looks to me like NI is interested in Labview support only.
07-06-2015 12:22 PM
@edhubbell wrote:
It is amazing the disconnect between how easy the marketing claims temerature data aq is with the USB-TC01 and how easy it actually is.
I can't find a single example of how to interface with the device from a .NET program. All that can be seen are old threads with no answers, or threads with snarky replies like 'you started another thread on this already'.
There are literally more VB6 answers available than .NET. That's been a dead language for 10 years.
It can't be logical that we need to use either a 1.3 gig install of NI-DAQmx or 'no drivers needed'. There has to be some in-between.
Looks to me like NI is interested in Labview support only.
Do you have a specific question? Seems more like a collection of disconnected statements....
The OP apparently had no problems using .NET with this device, the question was about deployment. For an example, a quick google search finds e.g. this link and many more.
So you are complaining about the size of DAQmx and somehow conclude that NI is only interested in LabVIEW support? That statement makes no sense, since LabVIEW requires DAQmx as well.
The TC01 does work instantly to record temperature after plugging it in for the first time and that's all that is claimed in the sales literature.
07-07-2015 12:50 PM
I want to know how to easily comminicate with an NI USB-TC01 from .NET without having to install a 1.3G driver package. For all the bluster and billowing of the marketing language surrounding this product, you'd think that NI would make that easy. Instead, they make it hard.
If my post seemed like a series of disconnected statements, it was probably due to frustration after spending the better part of a work day on this problem. Trying to find some documentation for something that should be easy left me somewhat wordless.
If I were the engineer sourcing the equipment on this project, I'd buy a different controller. NI-DAQmx is waaaay too big to be the best solution to this problem. It is a USB device. That means it is supposed to be easy. Maybe it will be for the next guy/gal.
Lest you think me just a clueless ranty coder - Here's a class I hacked together that you can use to connect to a NI USB-TC01. But I'd buy a different controller if you still have the option.
Option Explicit On
' NOTE - Option strict is off so we can dynamically link to the NI .dll file
Option Strict Off
Imports NLog
Imports System.Activator
Imports System.Reflection
Imports System.Reflection.MethodBase
''' <summary>
''' Interface to get temperatures from a connected National Instruments USB-TC01
''' </summary>
Public Class TemperatureMeasurementDevice_NI_USB_TC01
' The interface and documentation for working with the NI USB-TC01 is one of the most appalling experiences I've ever had. Full stop.
' It seems it would be simple based on all the marketing speak on the page (No driver needed! Instant measurements!), but that's marketing.
' The truth is that NI really, really wants you to use LabView. If you want to use something else to communicate with your UNIVERSAL (hint)
' serial bus thermocouple, you are s.o.l.
'
' They also want you to install the entire NI-DAQmx software package, which clocks in at about 1.3 gigs. This seems a tad excessive, since NI
' obviously is able to read the thermocouple with drivers that are stored on the device itself. So that's how we do it.
'
' We grabbed the digSensAsmu.dll from the thermocouple device and add a reference to it. We looked at that .DLL using ILSpy to get a look at what methods they
' exposed that we could use. Those look something like this:
'
' public unsafe uint OpenSession(uint serialNum, [MarshalAs(UnmanagedType.U1)] bool simulate)
' public void CloseSession(uint sessionHandle, [MarshalAs(UnmanagedType.U1)] bool simulate)
' public unsafe double ReadTemp(uint sessionHandle, int tcType, ushort cjcConfig, [MarshalAs(UnmanagedType.U1)] bool simulate)
' (Not sure what cjcConfig should be, but have only seen it called with a 1)
' public unsafe double ReadCJCTemp(uint sessionHandle, [MarshalAs(UnmanagedType.U1)] bool simulate)
' public int getNumberOfDevices()
' public uint GetSerialNumberAtIndex(int index)
' public List<uint> GetSerialNumberList()
' public unsafe uint getOldestCompatibleFirmware(uint sessionHandle, [MarshalAs(UnmanagedType.U1)] bool simulate)
' public unsafe uint getFirmwareVersion(uint sessionHandle, [MarshalAs(UnmanagedType.U1)] bool simulate)
' public unsafe int isDeviceFirmwareCompatible(uint sessionHandle, [MarshalAs(UnmanagedType.U1)] bool simulate)
'
' Then we took a look at singleTempLogger.exe using JetBrains dotPeak so we could see HOW those methods were used. This was also allowed
' us to see how methods were called. It also let us to figure out what the hell to use for the tcType integer, which was a mystery.
'
' ed@gsdware
Inherits TemperatureMeasurementDevice_Base
Implements ITemperatureMeasurementDevice
Private serialNum As UInteger
Private tcType As tcTypes
Private assembly As Assembly
Private tDigSensDevices_type As Type
Private tDigSensDevices As Object
Private Enum tcTypes
B = 10047
E = 10055
J = 10072
K = 10073
N = 10077
R = 10082
S = 10085
T = 10086
defaultTcType = -1
End Enum
Public Function GetTemperature() As Double Implements ITemperatureMeasurementDevice.GetTemperature
Dim sTemperature As Double = -1
Try
logger.Info("entering {0}.{1}", GetCurrentMethod().DeclaringType.Name, GetCurrentMethod().Name)
Dim sessionHandle As UInteger = tDigSensDevices.OpenSession(serialNum, False)
sTemperature = tDigSensDevices.ReadTemp(sessionHandle, Convert.ToInt32(tcType), 1, False)
tDigSensDevices.CloseSession(sessionHandle, False)
Return sTemperature
Catch ex As Exception
logger.Error(ex)
Throw
Finally
logger.Info("exiting {0}.{1}", GetCurrentMethod().DeclaringType.Name, GetCurrentMethod().Name)
End Try
End Function
''' <summary>
''' Shows serial numbers of all attached NI USB-TC01 devices.
''' </summary>
''' <remarks>Necessary because the device serial numbers according to the dll don't actually match the numbers that are printed on the back of the device, next to S/N.</remarks>
Public Sub ShowAllSerialNumbers()
Dim sMessage As String = ""
Dim iSerialNumber As Integer = -1
Try
logger.Info("entering {0}.{1}", GetCurrentMethod().DeclaringType.Name, GetCurrentMethod().Name)
' There is documentation somewhere that suggests the limit is 4 devices, so that's how many we'll check.
For iIndex As Integer = 0 To 4
Try
iSerialNumber = tDigSensDevices.GetSerialNumberAtIndex(iIndex)
sMessage &= String.Format("index: {0} serial number: {1}{2}", iIndex.ToString, iSerialNumber.ToString, vbCrLf)
Catch ex As Exception
' Ignore exceptions - they just mean that you called GetSerialNumberAtIndex with an index that doesn't exist
End Try
Next
If iSerialNumber = -1 Then
sMessage = "No devices found"
End If
MsgBox(sMessage, MsgBoxStyle.OkOnly, "USB-TC01 Serial Numbers")
Catch ex As Exception
logger.Error(ex)
Finally
logger.Info("exiting {0}.{1}", GetCurrentMethod().DeclaringType.Name, GetCurrentMethod().Name)
End Try
End Sub
''' <summary>
''' Instantiate based on TemperatureMeasurementDeviceSettings
''' </summary>
''' <param name="TemperatureMeasurementDeviceSettings"></param>
''' <remarks></remarks>
Public Sub New(TemperatureMeasurementDeviceSettings As TemperatureMeasurementDeviceSettings)
Try
logger.Info("entering {0}.{1}", GetCurrentMethod().DeclaringType.Name, GetCurrentMethod().Name)
serialNum = TemperatureMeasurementDeviceSettings.SerialNumber
' We could add something here that allows you to specify the thermocouple type in the settings file, but every thermocouple I've ever seen is K. So let's assume K and move on.
tcType = tcTypes.K
assembly = assembly.Load("digSensAsmu")
tDigSensDevices_type = assembly.GetType("nDigSensAsm.tDigSensDevices")
tDigSensDevices = Activator.CreateInstance(tDigSensDevices_type, New Object() {False})
Catch ex As Exception
logger.Error(ex)
Finally
logger.Info("exiting {0}.{1}", GetCurrentMethod().DeclaringType.Name, GetCurrentMethod().Name)
End Try
End Sub
''' <summary>
''' Instantiate based on just the serial number. Note that the serial number seems to have NO relation to the one that is actually printed on the device. Thanks, NI.
''' </summary>
''' <param name="SerialNumber"></param>
''' <remarks>useful for creating a fake instance so you can call the ShowAllSerialNumbers sub</remarks>
Public Sub New(SerialNumber As UInteger)
Try
logger.Info("entering {0}.{1}", GetCurrentMethod().DeclaringType.Name, GetCurrentMethod().Name)
serialNum = SerialNumber
' We could add something here that allows you to specify the thermocouple type in the settings file, but every thermocouple I've ever seen is K. So let's assume K and move on.
tcType = tcTypes.K
assembly = assembly.Load("digSensAsmu")
tDigSensDevices_type = assembly.GetType("nDigSensAsm.tDigSensDevices")
tDigSensDevices = Activator.CreateInstance(tDigSensDevices_type, New Object() {False})
Catch ex As Exception
logger.Error(ex)
Finally
logger.Info("exiting {0}.{1}", GetCurrentMethod().DeclaringType.Name, GetCurrentMethod().Name)
End Try
End Sub
Public Sub ShowConfigMessageBox() Implements ITemperatureMeasurementDevice.ShowConfigMessageBox
MsgBox("SerialNumber: " & serialNum.ToString)
End Sub
End Class
05-04-2016 03:35 PM
The main goal is that I want to write a program reading the temperature from TC01. From your link about Measurement Studio of Visual C# for TC01, is there Measurement Studio of VB.net, not C#. If yes, do you know how I can get it. I have VB.net but I don't see this part.
Thanks,
lblKL
05-05-2016 07:24 PM
@lblKL wrote:The main goal is that I want to write a program reading the temperature from TC01. From your link about Measurement Studio of Visual C# for TC01, is there Measurement Studio of VB.net, not C#. If yes, do you know how I can get it. I have VB.net but I don't see this part.
Thanks,
lblKL
http://www.ni.com/mstudio/ It isn't free.
05-09-2016 03:14 PM
Hi,
Read the pdf in the link below. There's a good example on how to use DAQmx and a TC01.
You really don't need Measurement Studio, just DAQmx.
The code is in C#, but it should be very easy to convert it over to VB
Curt
05-10-2016 08:28 AM
My post above is in VB (not C#) and doesn't require the use of DAQmx. It uses the .DLL that is contained on the TC01 unit (as it is also a flash drive). So no heavy NI installs needed.
Curt_C is correct that converting from C# to VB.NET should be easy. There are several resources online that allow for this. Just google c# to vs and you'll find them.
~Ed