Page 1 of 1

18f4550 usb slave

Posted: Sun Dec 13, 2009 5:25 am
by Roy Johnston
I have successfully set up a project using the USB slave routine. I am communication via MS access Visual basic.
What I cannot get correct is to successfully connect two cards to the computer and be able to access a particular card using an address of some kind.
Please help
Thks in advance

Re: 18f4550 usb slave

Posted: Mon Dec 14, 2009 10:48 am
by Benj
Hello

To use the USB slave functions for more then one device you must perform the following sequence.

1. use the getcount function call to detect the number of devices connected to the PC.

2. use the open function with a parameter of 1 to open the first device.

3. When you have finished with this device then close the connection to it using the close function.

4. Establish comms to the next device by using the open function again with a parameter of 2.

etc....

Let me know if you have any problems.

Re: 18f4550 usb slave

Posted: Mon Dec 14, 2009 11:00 am
by Roy Johnston
This seems Logical; however I will know beforehand how many I will have connected. The uncertainty is if I start up the pc every time will the order of 1 to 2 remain the same.
It is important to me that device1 remains device 1 all the time ect.
Is there a way of setting up an address that device 1 remains device 1 and so on.

Re: 18f4550 usb slave

Posted: Tue Dec 15, 2009 3:54 am
by Roy Johnston
After sleeping on the problem, I think I have the solution.

1) I will assign a value from within the microchip, which will be representative of an address. Therefore each card on the system will have a unique identifier.
2) When opening my application I will use the getcount feature.
3) I will open each card separately and read in the address, where I will be able to identifier the device count to an address.
4) I will try this approach and advise accordingly, unless someone has a better solution.

Thanks
Roy Johnston
:lol:

Re: 18f4550 usb slave

Posted: Tue Dec 15, 2009 9:35 am
by Benj
Hi Roy

Yes that is a good idea. You could have the unit reply when it gets a particular incoming byte. Eg 0x01 represents get id value.

Let me know how you get on.

Re: 18f4550 usb slave

Posted: Thu Dec 31, 2009 7:01 am
by Roy Johnston
The solution was rather simple.
1) I used 2 inputs as an address on the pic This allows for 4 cards to be identified on one system.
2) I then use the get function to determine how many cards are present.
3) I then read in the address ( from the 2 inputs) of each card.
4) Thereby I assign the correct card to the correct software.
5) This effectively eliminates a unique software for each pic.