Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] PIC18F4550 USB Same VID, PID Help

Status
Not open for further replies.

Dymtra

Newbie level 6
Joined
Jun 24, 2011
Messages
12
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,390
Hi, I've managed to connect the PIC18F4550 via USB and the PC recognized it, the problem is that i need to connect a second one, but where do i tell the PC is a different PIC?.

I know that i can't use the serial number option due to the limitations of the microchip driver.

I'm using Visual C++ 6 to the main program to send and receive data from the PIC, and CCS to program the PIC.
 

No serial number is required to connect multiple instances of an USB device. Serial numbers allow however a better identification of individual devices. It's a field in the device descriptor that you have to personalize.
 

No serial number is required to connect multiple instances of an USB device. Serial numbers allow however a better identification of individual devices. It's a field in the device descriptor that you have to personalize.

I'm using a special header (that was provided at class) for the compiling for the PIC. Here i found the device descriptor part you mentioned. But i'm not really sure what to modify.

Code C++ - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//////////////////////////////////////////////////////////////////
///
///   start device descriptors
///
//////////////////////////////////////////////////////////////////
 
   //device descriptor
   char const USB_DEVICE_DESC[] ={
         USB_DESC_DEVICE_LEN,          //the length of this report
         0x01,                //constant DEVICE (0x01)
         0x10,0x01,           //usb version in bcd
         0x00,                //class code (if 0, interface defines class.  FF is vendor defined)
         0x00,                //subclass code
         0x00,                //protocol code
         USB_MAX_EP0_PACKET_LENGTH,   //max packet size for endpoint 0. (SLOW SPEED SPECIFIES 8)
         0xD8,0x04,           //vendor id (0x04D8 is Microchip)
         0x11,0x00,           //product id
         0x00,0x01,           //device release number
         0x01,                //index of string description of manufacturer. therefore we point to string_1 array (see below)
         0x02,                //index of string descriptor of the product
         0x00,                //index of string descriptor of serial number
         USB_NUM_CONFIGURATIONS   //number of possible configurations
   };

 

The way that you identify different devices is driver dependent.. which USB endpoind and Class are you using? Which is the driver you are thryng to use? If it is MCHPUSB than just take a look at this post. LINK. You can create different handlers for each device ... after that you can poll each device and get the serial number...
 

The way that you identify different devices is driver dependent.. which USB endpoind and Class are you using? Which is the driver you are thryng to use? If it is MCHPUSB than just take a look at this post. LINK. You can create different handlers for each device ... after that you can poll each device and get the serial number...


This is the header i use to declare the Class in VC++


Code C++ - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// USB.h: interface for the USB class.
//
//////////////////////////////////////////////////////////////////////
 
#if !defined(AFX_USB_H__801FD7DD_554C_4197_A9AF_6A4FC934E5FA__INCLUDED_)
#define AFX_USB_H__801FD7DD_554C_4197_A9AF_6A4FC934E5FA__INCLUDED_
 
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
 
class USB  
{
public:
    void ClosePipes();
    void Initialice();
    void OpenPipes();
    USB();
    virtual ~USB();
    //void ReceivePacket(short* ReceiveData,DWORD* ReceiveLength);
    void ReceivePacket(/*PVOID*/BYTE *ReceiveData,PDWORD ReceiveLength);//Este es el original
    //void SendPacket(short* SendData, DWORD SendLength);
    void SendPacket(BYTE *SendData, DWORD SendLength);
    //void SendPacket(PVOID SendData, DWORD SendLength);ORIGINAL
    void SendPacket2(int PosServo);
    void SendPacket2(int Position1, int PosMotor);
    void SumaPIC(UINT sumando1, UINT sumando2);
    UINT ResultadoPIC();
    void ORPIC(UINT sumando1, UINT sumando2);
    void NOTPIC(UINT sumando1, UINT sumando2);
    void XORPIC(UINT sumando1, UINT sumando2);
    void ANDPIC(UINT sumando1, UINT sumando2);
};
 
#endif // !defined(AFX_USB_H__801FD7DD_554C_4197_A9AF_6A4FC934E5FA__INCLUDED_)



And this is how in the header for the Dlg of the main program i declare the Class


Code C++ - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// USB_P1Dlg.h : header file
//
 
#if !defined(AFX_USB_P1DLG_H__3C513493_AE54_483A_9A96_A4F988C1169B__INCLUDED_)
#define AFX_USB_P1DLG_H__3C513493_AE54_483A_9A96_A4F988C1169B__INCLUDED_
 
#if _MSC_VER > 1000
#pragma once
#include"usb.h"
#include"usb2550.h"
#endif // _MSC_VER > 1000
 
/////////////////////////////////////////////////////////////////////////////
// CUSB_P1Dlg dialog
 
class CUSB_P1Dlg : public CDialog
{
// Construction
public:
    CUSB_P1Dlg(CWnd* pParent = NULL);   // standard constructor
    USB MyUSB; //This is my object USB
              .
 
              .
 
              .
 
              .

 

Here i found the device descriptor part you mentioned. But i'm not really sure what to modify.
As the comment tells, serial number is a string descriptor. You have to define a new index for it (e.g. 3) and add code to the application, that sends a serial number string, when it's requested by the host. Use the code, that handles the existing string descriptors as a template.
 

As the comment tells, serial number is a string descriptor. You have to define a new index for it (e.g. 3) and add code to the application, that sends a serial number string, when it's requested by the host. Use the code, that handles the existing string descriptors as a template.

Yes I know that in the code it says something about the serial number, but the problem is that the driver mchpusb doesn't support it. How can I access the serial number?? Is there a VC++ function for this?
 

The serial number can be always obtained by browsing the registry.
 

The serial number can be always obtained by browsing the registry.

I used USBDeview to see all the information on the USB devices recognized in my computer, but even when it recognize the PIC the serial number still doesn't appear.

And i was thinking since in the Device Descriptor is the USB_DEVICE_DESC[] defined, maybe in the PIC program i could get that it into a variable an then send it to the PC, and in the VC++ program just read the bits of the serial number and then assign a Class to it. Do you think it could work?
 

Solved!!! I just had to change the VID and the driver =)
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top