Jump to content
  • 0

USB-1608GX VB.NET Analog Input Integration


kushal.nargundkar

Question

Hello I'm trying to use the sample code in the UL Examples for Analog Input scanning named "DaqInScan03.NET" but I'm getting an error "Invalid Digital Port Number". I'm running Windows 11 64 bit & I had to do a 1-way upgrade to open the solution file.

Is there a difference between the 32-bit driver & 64- bit driver? We used to use MCC almost a decade ago & I have a solution file which is using 'MCCAnalog' class but my suspicion is it was written for the 32-bit driver & I'm using a 64-bit driver. The existing class is also giving me the same error when I'm using breakpoints to see the ulstat value

Link to comment
Share on other sites

21 answers to this question

Recommended Posts

  • 0
2 hours ago, JRys said:

The DaqInScan functionality is not a supported feature on the USB-1608G series, and there's no difference if you build your program for x86 or x64.

Ok. I used another solution file which you gave before & that worked.

Now when I am trying to read the values from the buffer, my raw data is remaining zeros but I dont have any errors. Attached is my file.

 image.thumb.png.6fbee8cfe7d7dabc8ec0d9aea6f0eebc.png

What am I doing wrong?

MCCAnalog.vb

Link to comment
Share on other sites

  • 0

Make sure the buffer size is at least 256 times the number of channels. This is because the packet size is a minimum of 256 per channel for your device. If you're using a smaller number it may be the problem.  Also, because your scan options are continuous+background+scaleddata, you must use MccService.ScaledWinBufAlloxEX to allocate the buffer. 

Link to comment
Share on other sites

  • 0
13 hours ago, JRys said:

Make sure the buffer size is at least 256 times the number of channels. This is because the packet size is a minimum of 256 per channel for your device. If you're using a smaller number it may be the problem.  Also, because your scan options are continuous+background+scaleddata, you must use MccService.ScaledWinBufAlloxEX to allocate the buffer. 

Thank you for your response. In the original code it was set to ScanOptions.Background Or ScanOptions.Continuous Or scanOptions. That also didn't work. So I looked at the sample code & tried plus. I'll check the buffer size. 

Link to comment
Share on other sites

  • 0

Hello John.

I have a follow up question on this. It seems like there is a limitation to the size of the buffer that I'm acquiring the data. It is set to around 25000. Is there a way around this? Can I change to something much higher from somewhere?

Numpoints at 25000 makes the midscanpoint to 12500 & anything higher than that doesnt work.

Link to comment
Share on other sites

  • 0

I'm not getting the limitation you spoke about. I just ran a successful test using a buffer whose size was 102400 times 8 channels. If your scan options include ScaledData, ensure that you allocate the buffer with ScaledWinBufAllocEx and you're transferring the data from the driver buffer to your array using ScaledWinBufToArray.

Best regards,
John

Link to comment
Share on other sites

  • 0

Hello John,

What is the difference between the ScaledWinbuftoArray & WinBuftoArray?

Previous code was using WinBuf & now I'm using Scaled version. My actual sinusoidal signal is 5Vpp & my raw data coming in from Windows buffer fluctuates between [-2.5,2.5]. If the USB-1608GX is a 16-bit DAQ device, I'd have expected the raw data to be 5/65536 or 5/2^16 & then I'd have to scale it to real world values. Does it not work that way?

Link to comment
Share on other sites

  • 0

Hello,

The AInScan function uses scan option enumerations to control how it behaves, for example Background + Continuous. When you also include ScaledData, you are saying you want the driver to return voltage data instead of A/D counts. ScaledData requires you to use ScaledWinBufAllocEx to declare the buffer and ScaledWinBufToArray to transfer the voltage data to your array declare as a double. If you want A/D counts, leave out the enumeration and use WinBufAllocEx and WinBufToArray. The counts returned are 0 to 65535 where zero is (-)range and 65535 is (+)range. 

Best regards,

John

Link to comment
Share on other sites

  • 0

When I switch to WinBufToArray, my rawdata array is all zeros. Hence I had to switch to ScaledWinBuf. But my rest of the code expects it to be A/D counts.

What should I keep in mind to make WinBuf to work? I am changing the ScaledWinBufAllocEx to WinBufAllocEx.

I noticed that it Winbuf outputs a 2D array where as Scaled outputs a 1D array.

Link to comment
Share on other sites

  • 0

Hello,

First, you want to make sure your code uses WinBufAllocEx, WinBufToArray and your scan options do not include ScaledData. Next, make sure you have valid signals connected to the inputs and the inputs are in the correct mode (differential or single-ended). Unconnected open channels can drift to -10 volts, which is zero counts.

Best regards,
John

Link to comment
Share on other sites

  • 0

I currently have only 1 channel on which I've connected my 5Vpp signal. When i use ScaledWinBuf function, I get data which is in volts but the exact same code when i replace it with only the WinBuf function & changing the ADDataV to be Double(,) instead of Double() it gives me all 0's. Do you have a minute to do a remote session to look at my code live so that i can show you what is going on?

Link to comment
Share on other sites

  • 0

And yes my code uses WinBufAllocEx, WinBufToArray and scan options do not include ScaledData. 

Would there be a difference of input signals for the 2 functions? Like if my signal in whichever mode whether differential or single ended works for Scaled, would it not work for WinBuf?

When you say valid signals, how do you define what is valid?

Link to comment
Share on other sites

  • 0

It's critical to have the inputs set to the correct mode because the input signals have a different wiring scheme depending on how it's set. My advice is to use single ended mode, wire the channels to ground and verify your code returns 32767 +/- a few counts.

I'm sorry, but remote sessions are not possible.

I've attached a VB module that reads the first four channels without using ScaledData.

Module1.vb

Link to comment
Share on other sites

  • 0

Thank you John,

I used your code & wired the High(1) to AGND(3) & left the LOW(2) as it was. I saw that the values were still 0. When I reverted back & made a small change in the code

image.png.b8593bf088869363c6f4bbf8e5e30d95.png

I was able to see the count values.

image.png.525d8eb2fbe0fc0027c4a4d9c0c97fbe.png

I only have AIN1 connected, rest are unconnected.

I think I can use that but don't know why when connected to ground it still reads 0.

Link to comment
Share on other sites

  • 0

Hello John,

I'm trying to get dual channel system working with 2 USB 1608 connected to my PC. When I try to start the DAQ, I get error message saying "Invalid Board Number". I'm using 0 & 1 as the 2 boards. I can see in InstaCal both boards are connected & working properly with correct board numbers. When I have only 1 connected of either devices, it works as expected but when I connect both, I get that message. What am I doing wrong? Do you have any sample code that I can test with more than 1 board connected?

Link to comment
Share on other sites

  • 0

Hello,

The example code I sent uses a function called GetBoardNum. If you need to call it more than once, remove the MccDaq.DaqDeviceManager.IgnoreInstaCal because it must be the first MCC function that is called and it is called only once. For example:

MccDaq.DaqDeviceManager.IgnoreInstaCal()

Board1 - GetBoardNum("1608")

Board1 = GetBoardNumber("1808"

If you have two devices with the same name, you must change the search method to look for the serial number and not the name. The serial number property is UniqueID. For example:

 Function GetBoardNum(ByVal devString As String) As Integer
        Dim inventory() As MccDaq.DaqDeviceDescriptor
        Dim BoardNum As Integer
        Dim NumOfDevices As Integer = 0

        inventory = MccDaq.DaqDeviceManager.GetDaqDeviceInventory(DaqDeviceInterface.Any)
        NumOfDevices = inventory.Length()
        If NumOfDevices > 0 Then
            For BoardNum = 0 To NumOfDevices

                If inventory(BoardNum).UniqueID.Contains(devString) Then
                    Dim daqBoard As MccDaq.MccBoard = MccDaq.DaqDeviceManager.CreateDaqDevice(BoardNum, inventory(BoardNum))
                    Console.WriteLine("Product Name:    {0}", inventory(BoardNum).ProductName)
                    Console.WriteLine("Device Type # :  {0}", inventory(BoardNum).ProductID)
                    Console.WriteLine("Serial # :       {0}", inventory(BoardNum).UniqueID)

                    Return BoardNum
                End If

            Next BoardNum
        End If
        Return -1
    End Function

End Module
 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...