Jump to content
  • 0

Need Help with BTH-1208LS bluetooth connection


Markzan

Question

Dear All

I am having trouble with the device BTH-1208LS and Windows10

I can read input data with the USB cable connected, but no via Bluetooth.

The device is acquired correctly by InstaCal but when I try to acquire data I've got always this error :

BTHCONNECTIONFAILED (Verify the Bluetooth connection.)

but the bluetooth works well and the device is connected. I have also disabled antivirus and all the programs that could interfere with the connection.

Thank you very much for taking the time to resolve this question

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

Hello Marco,

For Bluetooth to work, the device must be on battery power or a USB power supply. If you have it plugged into the USB port on a computer, it will operate as a normal USB device. Assuming it's on battery power and the device is paired, InstaCal should locate it so that it can be added to the board list. I just tried mine with Windows 10 and it worked as directed - page 8 in the following user manual: https://www.mccdaq.com/pdfs/manuals/BTH-1208LS.pdf. I used a USB 5.0 dongle for Bluetooth and it didn't require any changes to my antivirus. 

As for the BTHCONNECTIONFAIILED, does it occur with our software or with your program code?

Best regards,

John

 

Link to comment
Share on other sites

  • 0

Hello John

I confirm that I am using the device with batteries and no cable.

I am able to see the device correctly paired and listed to the InstaCal's list (board #0 paired), as the manual said.

The BTHCONNECTIONFAIILED error occured with the original example files (C# projects in these cases).

 

Regards,

Marco

Link to comment
Share on other sites

  • 0

Hi Marco,

If it's not too much trouble, could you try my C# code (listed below or file attachment)? Make sure the upper green LED is blinking, indicating it's awake.

Best regards,

John

 

using System;
using System.IO;
using System.Threading;
using MccDaq;
namespace AinScanBackgroundContinuousScan
{
    class Program
    {

        public const int CHANCOUNT      = 4;
        public const int FIRSTCHANNEL   = 0;
        public const int LASTCHANNEL    = 3;
        public const int FREQ           = 100;

  
        //This program works with several devices, enable the Device string for your product
        public const string DEVICE = "BTH-1208LS";

        public static int PACKETSIZE;

        public static MccBoard daq;

        static void Main(string[] args)
        {

            MccDaq.ErrorInfo RetVal;

            int     BoardNum        = 0;
            int     Rate            = FREQ;
            bool    ReadLower       = true;


            BoardNum = GetBoardNum(DEVICE);


            if (BoardNum == -1)
            {
                Console.WriteLine("No {0} detected!", DEVICE);
                WaitForKey();
                return;
            }

            //some devices have odd size packet, so multiply x 2
            int BUFFERSIZE = PACKETSIZE * CHANCOUNT * 2;
            int HALFBUFFSIZE = BUFFERSIZE / 2;

            daq = new MccDaq.MccBoard( BoardNum );
            
            IntPtr buffer = MccService.WinBufAllocEx( BUFFERSIZE );

            if( buffer == IntPtr.Zero )
            {
                Console.WriteLine( "Bad Handle" );
                return;
            }

            short[] chArray = new short[CHANCOUNT]; //configuration array for channel numbers
            Range[] chRange = new Range[CHANCOUNT]; //configuration array for input ranges

            chArray[0] = 0;
            chArray[1] = 1;
            chArray[2] = 2;
            chArray[3] = 3;

            chRange[0] = Range.Bip10Volts;
            chRange[1] = Range.Bip10Volts;
            chRange[2] = Range.Bip10Volts;
            chRange[3] = Range.Bip10Volts;

            IsError( daq.ALoadQueue( chArray, chRange, CHANCOUNT ) );
            IsError( daq.AInputMode(AInputMode.SingleEnded));


            //setup the acquisiton
            IsError( daq.AInScan(   FIRSTCHANNEL, 
                                    LASTCHANNEL, 
                                    BUFFERSIZE, 
                                    ref Rate, 
                                    Range.Bip10Volts, 
                                    buffer,
                                    ScanOptions.Background | ScanOptions.Continuous | ScanOptions.ScaleData
                                ) );


            int Count = 0;
            int Index = 0;
            short daqStatus;

            double[] doubleArray = new double[BUFFERSIZE];

            //Loop until key press
            do{
                RetVal = daq.GetStatus( out daqStatus, out Count, out Index, FunctionType.AiFunction );
                if ((Index >= HALFBUFFSIZE) & ReadLower) //check for 50% more data
                {
                    //get lower half of buffer
                    RetVal = MccService.ScaledWinBufToArray(buffer, doubleArray, 0, HALFBUFFSIZE);
                    IsError(RetVal);
                    DisplayData(doubleArray, HALFBUFFSIZE/CHANCOUNT);
                    ReadLower = false; //flag that controls the next read
                }
                else if ((Index < HALFBUFFSIZE) & !ReadLower)
                {
                    //get the upper half
                    RetVal = MccService.ScaledWinBufToArray(buffer, doubleArray, HALFBUFFSIZE, HALFBUFFSIZE);
                    IsError(RetVal);

                    DisplayData(doubleArray, HALFBUFFSIZE/CHANCOUNT);
                    ReadLower = true;//flag that controls the next read
                }
              

            } while (!Console.KeyAvailable);
            ConsoleKeyInfo cki = Console.ReadKey();

 
            //stop the  acquisition
            RetVal = daq.StopBackground(FunctionType.AiFunction);

            //free up memory
            MccService.WinBufFreeEx(buffer);

            WaitForKey();
            
        }
        public static int IsError(ErrorInfo e)
        {
            if (e.Value != 0)
            {
                Console.WriteLine(e.Message);
                WaitForKey();
                return 1;
            }
            return 0;
        }

        /*////////////////////////////////////////////////////////////////////////////////////*/

        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]);

                            PACKETSIZE = 32;

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


        /*////////////////////////////////////////////////////////////////////////////////////*/

        public static void WaitForKey()
        {
            Console.WriteLine("\nPress any key to continue...");
            do
            {
                System.Threading.Thread.Sleep(20);

            } while (!Console.KeyAvailable);
            ConsoleKeyInfo cki = Console.ReadKey();

        }

        public static void DisplayData(double[] datArray, int rows)
        {
           
            int i = 0;

            for (int row = 0; row < rows; row++)
            {
                
                for (int c = 0; c < CHANCOUNT; c++)
                    Console.Write("{0}\t", datArray[i++].ToString("0.000").PadLeft(10));

                Console.Write("\r\n");

            }

        }
 
    }
}

 

Program.cs

Link to comment
Share on other sites

  • 0

Hi John

thanks for the fast reply.

The program exit saying : "Bluetooth connection failed", but debugging, the board is recognized as in attached image.

I confirm the upper Green LED is blinking.

 

Regards

board.png

Edited by Markzan
Link to comment
Share on other sites

  • 0

Hi Mark,

I can duplicate the error only when I set the GetDaqDeviceInventory to look for Bluetooth and the USB cable is connected. Otherwise, I don't have an answer to what you're experiencing.

It works for me on both Windows 10 and 11 with the following Bluetooth dongle. It's not expensive and perhaps worth a try.

https://www.amazon.com/gp/product/B08J7WN4FP/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&psc=1

best regards,

John

 

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