PIC24FJ64GB002 with bluetooth USB dongle

Page: 12345.. > >> Showing page 1 of 13 - Powered by APG vNext Trial
Author
yts
Super Member
  • Total Posts : 560
  • Reward points : 0
  • Joined: 2005/09/06 17:45:30
  • Status: offline
2010/03/29 17:16:31 (permalink)
0

PIC24FJ64GB002 with bluetooth USB dongle

I will explain my project (how to control a bluetooth USB dongle by PIC24FJ64G002 on HCI protocol layer) step by step.

I recommend you to check your bluetooth USB dongle. Some dongle has a hub construction. Here, I concentrate only on a dongle that has “no” hub construction, because “USB Host - MCHPUSB - Generic Driver Demo” does not support the hub construction. You can check easily by using “usbview.exe” (distributed by Michrosoft) whether your dongle has the hub construction or not. I am using a PLANEX BT-MicroEDR1X bluetooth USB dongle as seen in the picture.

A picture of electric circuit and a schematic diagram are attached. A RS232C adapter is useful to debug your firmware for your target device, which will be uploaded later. Now I am drawing a schematic diagram for the adapter.

Attached Image(s)

#1

251 Replies Related Threads

    yts
    Super Member
    • Total Posts : 560
    • Reward points : 0
    • Joined: 2005/09/06 17:45:30
    • Status: offline
    RE: PIC24FJ64GB002 with bluetooth USB dongle 2010/03/30 17:07:08 (permalink)
    0
    I took a mistake. Previously, I wrote that I used a PLANEX BT-MicroEDR1X bluetooth USB dongle “for PC”. I noticed yesterday that I did not. I used a bluetooth dongle (see an attached picture) that is not a brand product. When I replaced the dongle with the PLANEX one yesterday, I could not connect PC to a target PIC device (Inquiry could be maid, though). So I work with the non-brand dongle for a while. Sorry for your inconvenience. We can, needless to say, use a PLANEX BT-MicroEDR1X bluetooth USB dongle for the target PIC device and communicate with PC.

    Attached Image(s)

    #2
    yts
    Super Member
    • Total Posts : 560
    • Reward points : 0
    • Joined: 2005/09/06 17:45:30
    • Status: offline
    RE: PIC24FJ64GB002 with bluetooth USB dongle 2010/03/30 17:36:50 (permalink)
    0
    Specification Documents for HCI (Host Controller Interface) are described in "Core v2.0 + EDR.pdf". See Volume 2; Part E. This pdf file can be obtained from Web site as http://www.bluetooth.com/SiteCollectionDocuments/Core_v210_EDR.zip.

    My project totally depends on the works of Mr. Ishikawa. Although he uses “a UART interface bluetooth module”, we can learn much about the HCI protocol. His Web site is http://www.asahi-net.or.jp/~QX5K-ISKW/robot/blue.html. The site is written in Japanese, but you can download and read his source codes (as for HCI, treservo.zip and treservopc.zip). He seems to develop a RFCOMM protocol layer.
    #3
    yts
    Super Member
    • Total Posts : 560
    • Reward points : 0
    • Joined: 2005/09/06 17:45:30
    • Status: offline
    RE: PIC24FJ64GB002 with bluetooth USB dongle 2010/03/30 18:17:02 (permalink)
    0
    Before you burn your PIC with the firmware I uploaded, please check a following few points.

    #1. I use a resonator of 4 MHz. For example, if you are using a resonator (or oscillator) of 8 MHz, you should change from PLLDIV_NODIV to PLLDIV_DIV2 in _CONFIG2 (main.c).

    #2. As for the RS232C connection, do not comfuse output and input pins (main.c).
        // Configure U2RX - put on pin 19 (RP8)
        RPINR19bits.U2RXR = 8;
        // Configure U2TX - put on pin 5  (RP7)
        RPOR3bits.RP7R = 5;
    #3. When the target PIC can not enumerate your bluetooth USB dongle, change the delay time “DelayMs(30);//YTS” and try again (4906 lines from the top of usb_host.c)

    #4
    yts
    Super Member
    • Total Posts : 560
    • Reward points : 0
    • Joined: 2005/09/06 17:45:30
    • Status: offline
    RE: PIC24FJ64GB002 with bluetooth USB dongle 2010/03/31 16:47:43 (permalink)
    0
    I upload a picture of RS232C adapter and its schematic diagram. Connect JP2 of the PIC board with JP1 of this adapter (1pins are No Connection, 2pin to 2pin, etc.). You can connect a D_SUB 9pins’ connector to your PC and monitor the data send from the PIC. An application software “Hyperterminal” (included in Windows XP) is convenient to monitor the data (settings: 57600 bps, 8 bits, non-parity, 1 stop bit, and no flow-control). When you do not have a RS232C port in your PC, you can use a RS232C to USB conversion cable instead.

    Attached Image(s)

    #5
    yts
    Super Member
    • Total Posts : 560
    • Reward points : 0
    • Joined: 2005/09/06 17:45:30
    • Status: offline
    RE: PIC24FJ64GB002 with bluetooth USB dongle 2010/03/31 17:33:31 (permalink)
    0
    To avoid the confusion, I write the situation of my project. The communication between (PC:Windows XP + non brand bluethooth USB dongle) and (PIC24FJ64GB002 + PLANEX BT-MicroEDR1X) have been made with success.(*) Hereafter, the non brand bluethooth USB dongle is referred to as “the PC dongle” and the PLANEX BT-MicroEDR1X as “the PIC dongle”.

    (*) Now I am trying to connect (PC:Windows XP + PLANEX BT-MicroEDR1X) with (PIC24FJ64GB002 + PLANEX BT-MicroEDR1X) for my responsibility. Please wait for a while.

    #6
    yts
    Super Member
    • Total Posts : 560
    • Reward points : 0
    • Joined: 2005/09/06 17:45:30
    • Status: offline
    RE: PIC24FJ64GB002 with bluetooth USB dongle 2010/04/01 16:43:34 (permalink)
    +2 (1)
    The data link between (PC:Windows XP + PLANEX BT-MicroEDR1X) and (PIC24FJ64GB002 + PLANEX BT-MicroEDR1X) is established. Two changes were needed.
    #1. Please comment out the following line (410 line from the top of main.c)
    if(buf[0]!=0x20){ DemoState =BT_STATE_READ_EP1; break;}
    as
    //if(buf[0]!=0x20){ DemoState =BT_STATE_READ_EP1; break;}
    #2. The other change was needed in an application software (bluehost.exe). See below.
    #7
    yts
    Super Member
    • Total Posts : 560
    • Reward points : 0
    • Joined: 2005/09/06 17:45:30
    • Status: offline
    RE: PIC24FJ64GB002 with bluetooth USB dongle 2010/04/01 17:09:34 (permalink)
    0
    Here I upload the application software (bluehost.exe) working on the PC (Windows XP).As for the device driver, see below.
    #8
    yts
    Super Member
    • Total Posts : 560
    • Reward points : 0
    • Joined: 2005/09/06 17:45:30
    • Status: offline
    RE: PIC24FJ64GB002 with bluetooth USB dongle 2010/04/01 17:12:07 (permalink)
    0
    A generic device driver used here (Uusbd.sys) has been presented by Mr. Kashiwano. He owns his copyright and you can use this driver only for hobby.
    #9
    yts
    Super Member
    • Total Posts : 560
    • Reward points : 0
    • Joined: 2005/09/06 17:45:30
    • Status: offline
    RE: PIC24FJ64GB002 with bluetooth USB dongle 2010/04/01 17:33:26 (permalink)
    0
    Before you execute the software (bluehost.exe), you should enumerate your PC dongle on you PC.
    #1. Edit a “UUSBD.INF” file in “driver” folder to meet with your PC dongle. Example is written in the “UUSBD.INF” file.
    #2. Move file “bth.inf” out of a WINDOWS\inf folder so that Windows XP cannot identify your PC dongle any more and asks you the place where the device deriver is.
    #3. You select “driver” folder to enumerate your PC dongle by “uusbd.sys”
    #4. Comment out the following sentences of “bluehostDlg.cpp” in “bluehost folder” to meet your PC dongle and compile again.

    .     //see the endpoint order by using "USBVIEW.EXE"
        h1=Uusbd_OpenPipe(husb,0,0);//first  Endpoint 1(81) for HCI event
        //for PLANEX
        h2=Uusbd_OpenPipe(husb,0,1);//second Endpoint 2(02) for ACL data
        h3=Uusbd_OpenPipe(husb,0,2);//third  Endpoint 2(82) for ACL data
        //for non brand product
    //    h3=Uusbd_OpenPipe(husb,0,1);//second Endpoint 2(82) for ACL data
    //    h2=Uusbd_OpenPipe(husb,0,2);//third  Endpoint 2(02) for ACL data

    Now, let turn on your PIC board, then execute the application software (bluehost.exe). After the connection between the PC and the PIC is established, a dialog box with 2 edit boxes and 1 SEND button appears. When you write something in the upper box and push the SEND button, only 3 characters appear in the lower box. You find that only the first character is changed. For example, you get “223”, when you send “12345”. First character of ‘2’ = ‘1’ +1 in ASCII code. Here you can switch off the target PIC board. When you send some characters again, there is no response any more, meaning that the connection between PC and PIC through bluetooth dongles is really established. 
    #10
    yts
    Super Member
    • Total Posts : 560
    • Reward points : 0
    • Joined: 2005/09/06 17:45:30
    • Status: offline
    RE: PIC24FJ64GB002 with bluetooth USB dongle 2010/04/01 18:04:14 (permalink)
    0
    When you would like to send and receive more data, please change the following lines "consistently". Otherwise you will loose the connection. As for the format of ACL packets, see 5.4.2 HCI ACL Data Packets of Core v2.0 + EDR.pdf.

    PIC firmware:
    Change from 421 to 458 lines from the top in main.c to meet your purpose. Connection Handle is stored as handle[0]=buf[3];handle[1]=buf[4]+0x20 at 397th line from the top in main.c. Here 0x20 corresponds to PB and BC flags.

    Application software:
    Change from 222 to 231 lines from the top in bluehostDlg.cpp. Connection Handle is stored as aa[0]=buf[3];aa[1]=buf[4]|0x20; at 178th line from the top in bluehostDlg.cpp. Here 0x20 corresponds to PB and BC flags.

    #11
    yts
    Super Member
    • Total Posts : 560
    • Reward points : 0
    • Joined: 2005/09/06 17:45:30
    • Status: offline
    RE: PIC24FJ64GB002 with bluetooth USB dongle 2010/04/01 18:14:04 (permalink)
    0

    After you finish debuging your firmware, you can use your target PIC board with single power supply of 3V (lower limit is around 2.7V in case PLANEX BT-MicroEDR1X) as seen in an attached picture. This means that we can get a handy bluetooth remote controller in our hand. Please enjoy.

    Attached Image(s)

    #12
    Guachuchon
    New Member
    • Total Posts : 3
    • Reward points : 0
    • Joined: 2010/04/22 14:31:41
    • Location: 0
    • Status: offline
    RE: PIC24FJ64GB002 with bluetooth USB dongle 2010/05/15 16:49:37 (permalink)
    0

    First of all, thanks for sharing this project, it is very interesting.

    A Question...

    Have you controlled No Brand BT USB Dongle with PIC24FJ64GB002 ?

    Is it possible?

    Thanks in advance for your answer

    Best Regards

    #13
    Vinod.Basi
    New Member
    • Total Posts : 10
    • Reward points : 0
    • Joined: 2010/05/19 03:08:23
    • Location: Bangalore, India
    • Status: offline
    RE: PIC24FJ64GB002 with bluetooth USB dongle 2010/05/24 22:35:39 (permalink)
    0
    Thanku YTS 
    Thanks a ton for the info...
    I was stuck up wit same usin PIC24FJ256GB106.
    Can i implement the same idea on this PIC ???
    Plz find time to reply.. 

    Thankyou

    Vinod Basi
    #14
    yts
    Super Member
    • Total Posts : 560
    • Reward points : 0
    • Joined: 2005/09/06 17:45:30
    • Status: offline
    RE: PIC24FJ64GB002 with bluetooth USB dongle 2010/05/27 23:53:28 (permalink)
    +2 (1)
    “My” non-brand BT USB Dongle has a hub-structure and cannot work with PIC24FJ64GB002. This is because “USB Host - MCHPUSB - Generic Driver Demo”, does not support the hub structure. If you get a (non-brand or brand) BT USB Dongle that “does not have a hub-structure”, I think it can work with PIC24FJ64GB002. As I wrote before, you can check easily by using “usbview.exe” (I have uploaded it by mistake) whether the dongle has the hub-structure or not.
    #15
    yts
    Super Member
    • Total Posts : 560
    • Reward points : 0
    • Joined: 2005/09/06 17:45:30
    • Status: offline
    RE: PIC24FJ64GB002 with bluet o o th USB dongle 2010/05/28 01:56:24 (permalink)
    0
    Unfortunately, I am not familiar with PIC24FJ256GB106. However, please see the 87th line from the top in main.c (USB Host - MCHPUSB - Generic Driver Demo) that Microchip distributes. The line looks like “ # elif defined(__PIC24FJ256GB106__)”. This means that you can use this firmware (for USB host) with PIC24FJ256GB106 and that only what you should do is to change my firmware for PIC24FJ256GB106. Only the PIC dependent program lines (_CONFIG1 etc.) are needed to be change, I think.

    As you know there are some layers in a BT stack; HCI, L2CAP, SDP, RFCOMM, HID etc. Only the HCI layer has been established in my project. The HCI layer is enough for data exchange (data link). Possibly, you can contract L2CAP, SDP, RFCOMM, HID layers in PIC24FJ256GB106 if you want.

    post edited by Nanci - 2010/06/25 07:56:52
    #16
    yts
    Super Member
    • Total Posts : 560
    • Reward points : 0
    • Joined: 2005/09/06 17:45:30
    • Status: offline
    RE: PIC24FJ64GB002 with bluetooth USB dongle 2010/06/18 12:41:15 (permalink)
    0
    Just information. In order to develop bluetooth stack, HID, RFCOMM etc., a monitor program working on Windows OS is useful. If you have bluetooth equipments, you can utilize “USBTrace” (free for 15 days: download “usbtrace.zip” and “WCDecoder.zip” from http://www.sysnucleus.com/) and would find how bluetooth equipments send/receive HCL and ACL data.
    #17
    yts
    Super Member
    • Total Posts : 560
    • Reward points : 0
    • Joined: 2005/09/06 17:45:30
    • Status: offline
    RE: PIC24FJ64GB002 with bluetooth USB dongle 2010/06/23 15:37:25 (permalink)
    0
    Here is a bluetooth-HID firmware of beta version for PIC24FJ64G002. PC (OS: Windows XP, bluetooth USB dongle:PLANEX BT-MicroEDR1X, bluetooth stack: bluesoleil 2.7.0.13 *, and application software: see below).

    The time-out for service connection is only about 2 seconds. If you double click “yts icon” in window of bluesoleil, then an “hourglass icon” appears. After the hourglass icon disappears, click a “mouse icon” (surrounded by a squire: see an attached picture)  within 2 seconds. Then you can connect PIC with PC on the HID profile. Otherwise, you lose connection. This is a problem. I hope that someone solves this problem. Time-out of 20 seconds would be better for me.

    I must say again that this firmware totally depends on the works of Mr. Ishikawa. Very useful information is in “blueme015.lzh, btcount015.lzh, and bluemelt_r8c15_050722.lzh” (http://www.asahi-net.or.jp/~qx5k-iskw/robot/blue.html). He starts to develop a RFCOMM layer on PIC24FJ64G002 now. Let’s wait for his success.

    *) Although bluesoleil version 6 cannot be used stably with my firmware (I don’t know the reason why), bluesoleil 2.1.2.0 can be. You can download the latter from the web site (http://www.pc210.com/downloadhtml/BlueSoleil_2.1.2.0_Release060301%2826.9MB%29_374.html ).

    post edited by yts - 2010/06/25 07:52:02

    Attached Image(s)

    #18
    yts
    Super Member
    • Total Posts : 560
    • Reward points : 0
    • Joined: 2005/09/06 17:45:30
    • Status: offline
    RE: PIC24FJ64GB002 with bluetooth USB dongle 2010/06/25 07:22:48 (permalink)
    0
    Thank you everybody who helps me. The forbidden word was " w i i m o t e ".

    I used Service Discovery Protocol (SDP) data of “Nintendo's w i i m o t e" in my firmware (data are in the arrays, att1, att2a, and so on, in main.c). As for the report ID, I used the input and output report IDs (0x21 and 0x18, respectively). One can send/receive data within 21 bytes by using these IDs.
    For Protocol and Service Multiplexor (PSM): SDP 0x0001, HID_Control 0x0011, HID_Interrupt 0x0013 and for SDP: SDP 0x0001, HIDP 0x0011

    More detailed information can be obtained from the following web-sites (remove spaces)
    Data of  w i i m o t e  : http://w i i brew.org/wiki/ W i i m o t e
    SDP of w i i m o t e: http://wiki. w i i m o t e project.com/Bluetooth_Specs
    uuid for SDP: http://hi.baidu.com/tangyuanan/blog/item/dbb1951b728db21d8718bfe1.html
    Bluetooth HID profile: http://www.bluetooth.com/SiteCollectionDocuments/HID_SPEC_V10.pdf
    DEVICE IDENTIFICATION SPECIFICATION: http://www.bluetooth.com/...nts/DI_SPEC_V12r00.pdf
    post edited by yts - 2010/12/05 18:28:08
    #19
    yts
    Super Member
    • Total Posts : 560
    • Reward points : 0
    • Joined: 2005/09/06 17:45:30
    • Status: offline
    RE: PIC24FJ64GB002 with bluetooth USB dongle 2010/06/25 07:34:38 (permalink)
    0
    Here is an application software for PC to communicate with PIC on the HID profile level. After connecting PIC with PC by using bluesoleil, execute "PICkit2.exe". A dialog box with 2 edit boxes and 1 SEND button appear. When you write something in the upper box (within 21 characters) and push the SEND button, the characters appear in the lower box. You find that only the first character is changed. For example, you get “22345”, when you send “12345”. First character of ‘2’ = ‘1’ +1 in ASCII code.
    #20
    Page: 12345.. > >> Showing page 1 of 13 - Powered by APG vNext Trial
    Jump to:
    © 2018 APG vNext Trial Version 4.5