18f4550 usb slave

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
Roy Johnston
Flowcode V4 User
Posts: 220
Joined: Mon Aug 24, 2009 8:38 am
Has thanked: 2 times
Been thanked: 34 times

18f4550 usb slave

Post 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

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: 18f4550 usb slave

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

Roy Johnston
Flowcode V4 User
Posts: 220
Joined: Mon Aug 24, 2009 8:38 am
Has thanked: 2 times
Been thanked: 34 times

Re: 18f4550 usb slave

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

Roy Johnston
Flowcode V4 User
Posts: 220
Joined: Mon Aug 24, 2009 8:38 am
Has thanked: 2 times
Been thanked: 34 times

Re: 18f4550 usb slave

Post 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:

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: 18f4550 usb slave

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

Roy Johnston
Flowcode V4 User
Posts: 220
Joined: Mon Aug 24, 2009 8:38 am
Has thanked: 2 times
Been thanked: 34 times

Re: 18f4550 usb slave

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

Post Reply