Register   |   Login

Print

[Technical Inquiry] Setting the USB4711 Configuration from VB

Setting the USB4711 Configuration from VB

I have 4 USB4711A devices running under various VB.net programs for acquiring data in a mill. With the old SDK under XP I can set up the device dynamically from the program. I want to upgrade to DAQNavi so that the programs can run under WIN7 and beyond. I don't see a way to set up the device from the program with the new DAQNavi software.
I need to set the Connection type and the Value range by code at run-time as I could in the previous XP version of the the software. I've noticed in the Multimeter program that this is done, i.e. the Value ranges are set.
Can you please give me some examples of this?
If it is a matter of using API's, can you give me direction to the correct API's and/or the Registry locations for accessing the parameters? I can't load BIODAQ.DLL into the references under Visual Studio.

Another question that could be the solution.  
There is a function called LoadProfile.

Visual Basic (Declaration)   
Public Function LoadProfile(ByVal fileName As String) As ErrorCode

Visual Basic (Usage)
Dim instance As DaqCtrlBase
Dim myProfile As String = "c:\my_demo_profile"
instance.LoadProfile(myProfile)

From the USB4711 setup in the My Computer Device Manager, I exported the *.XML setup file.
Using the .LoadProfile function, I tried calling in the above *.XML setup file. I received an error saying that the format was wrong.
What is the correct format and how is this file generated?

TOP

So,The FAQcovers the export and import.
It says "This is the ONLY way to save the configuration"
The format is not documented for editing or creating outside of the Navigator

The VB examples do not have a console version, which in C# you'd find the examples that go through referencing the API directly (as opposed to the forms component). In that regard VB.net is not a first-class language in the examples.

You can cross-translate the C# console example into VB.net.
Then examine the DAQNavi documentation. they have a section about setting 'valueranges' and 'signaltypes' from code.
Attachment: Your usergroup does not have permission to access attachments

TOP

LoadProfile Method

THANK YOU for the point-in-right-direction.


What is the LoadProfile function that is in the VB example used for?

[ Last edited by GregGiles at 2017-9-16 00:39 ]

TOP

VB.Net Code for setting Ranges and Signal Type on USB-4711A

I was able to use the DAQNAVI VB.NET functions to set the range and connection type.


From Navigator Reference:
********************************
Dim instance As AiCtrlBase
Dim value() As AiChannel

value = instance.Channels

Dim instance As AiChannel
Dim value As ValueRange

instance.ValueRange = value

value = instance.ValueRange


Dim instance As AiChannel
Dim value As AiSignalType

instance.SignalType= value

value = instance.SignalType
********************************

VB Code example (as is):

        'sRangeSpec is a string that contains the desired range i.e "To2pt5"
        Dim channels As AiChannel() = AIInstnce.Channels
        ' Set value range.
        'V_Neg5To5
        'V_Neg2pt5To2pt5
        'V_Neg1pt25To1pt25
        'mV_Neg625To625
        'V_Neg10To10
        Dim iRngePtr As Integer = 0
        Dim ranges As ValueRange() = AIInstnce.Features.ValueRanges

        iRngePtr = Array.FindIndex(ranges, (Function(c As ValueRange) c.ToString.Contains(sRangeSpec)))
        If iRngePtr = -1 Then iRngePtr = 0

        'set all the channels to nominal
        For iI As Integer = 0 To channels.Count - 1
            channels(iI).SignalType = AiSignalType.SingleEnded
            channels(iI).ValueRange = ranges(0)
        Next

        If Setup.iReadConnection = 1 Then 'differential
            For iI As Integer = Setup.iReadChannel To (Setup.iReadChannel + Setup.iNumberofChannels * 2) - 1 Step 2
                channels(iI).SignalType = AiSignalType.Differential
                channels(iI).ValueRange = ranges(iRngePtr)
            Next
        Else 'single-ended
            For iI As Int16 = Setup.iReadChannel To Setup.iReadChannel + Setup.iNumberofChannels - 1
                channels(iI).ValueRange = ranges(iRngePtr)
            Next
        End If

        'V_0To10
        'V_0To5
        'V_Neg10To10
        'V_Neg5To5
        'setup the output channels
        Dim ochannels() As AoChannel = AOInstnce.Channels
        If Setup.sAnalogOutRange = "" Then Exit Sub
        If Not Setup.sAnalogOutRange.ToString.Contains("/") Then Exit Sub
        ranges = AOInstnce.Features.ValueRanges
        'massage the range to match the desired RangeSpec
        sRangeSpec = Setup.sAnalogOutRange.ToString.Replace("/", "To")
        sRangeSpec = sRangeSpec.Replace("0.", "")
        sRangeSpec = sRangeSpec.Replace(".0", "")
        sRangeSpec = sRangeSpec.Replace("V", "")
        sRangeSpec = sRangeSpec.Replace(" ", "")
        'find the desired range
        iRngePtr = Array.FindIndex(ranges, (Function(c As ValueRange) c.ToString.Contains(sRangeSpec)))
        If iRngePtr = -1 Then iRngePtr = 0
        Try
            ochannels(Setup.iAnalogOutChannel).ValueRange = ranges(iRngePtr)
        Catch
            Beep()
        End Try

TOP

Quick search in Advantech Support Portal