Jump to content
  • 0

Unity - Win 11 - USB-1208FS - C# connection for trigger


LordValdrick

Question

Hello community,

It's my first time working with this hardware.

I'm using it to send triggers to an accquisition board.

I've seen it connecting with python and matlab, but I'm trying to use C# because it's for a specific environment.

I used a connection code that is in this link of Digilent: https://digilent.com/reference/software/universal-library/windows/start

So far I haven't been able to detect the USB-1208FS board I'm using.

I created a MccDaq.MccBoard and tried to connect to any BoardNum, but for all number [0-99] I'm not getting any BoardName.

Does anyone know how any other resources or experience with this?

Thanks in advance!

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Below is my get-board number function. It takes a device name string, such as '1208FS', to search for the device. Once it finds a device name that contains '1208FS', it determines if 'Plus' is in the name and, if so, sets the global variable PACKETSIZE to 32. Otherwise, it's 31. It is crucial to size the buffer as a multiple of PACKETSIZE times channel count. I have also attached my test program below that uses this function. 

 

       public static int GetBoardNum(string dev)
        {

            MccDaq.DaqDeviceManager.IgnoreInstaCal();
            MccDaq.DaqDeviceDescriptor[] inventory = MccDaq.DaqDeviceManager.GetDaqDeviceInventory(MccDaq.DaqDeviceInterface.Any);
            int DevicesFound = inventory.Length;
            if (DevicesFound > 0)
            {
                for (int boardNum = 0; boardNum < DevicesFound; boardNum++)
                {

                    try
                    {

                        if (inventory[boardNum].ProductName.Contains(dev))
                        {
                            MccDaq.MccBoard daqBoard = MccDaq.DaqDeviceManager.CreateDaqDevice(boardNum, inventory[boardNum]);
                            if (daqBoard.BoardName.Contains("Plus"))
                                PACKETSIZE = 32;
                            else
                                PACKETSIZE = 31;

                            return boardNum;
                        }
                    }
                    catch (ULException ule)
                    {
                        Console.WriteLine("Error occurred: " + ule.Message);
                    }
                }
            }
            return -1;
        }

USB_1208FS_CONT_EXAMPLE.cs

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...