Basic USB - Using Microchip Stack and C#.Net - Hardware |
![]() |
![]() |
![]() |
Written by Mat | |||||||
Sunday, 26 February 2006 | |||||||
Page 1 of 5 This article is an introduction to designing a USB PIC based device. It is based on the original C# API I developed, and heavily influenced by J1M's article. The article will demonstrate how to use a PIC18F4550 to produce a USB 2.0 Device which will perform basic input/output operations, whilst communicating with a C#.Net application via the microchip drivers. Please note all code is released AS-IS and should used at the users own risk, no guarantee is made by PICcoder.co.uk or the author with regards to the accuracy of the diagrams or code contained in this article. Discuss this article on the forums. (117 posts)
![]() Example Application In this article I will be discussing a basic C# application which communicates with a PIC via usb, allowing control of two LED's and can send two bytes to the PIC, which returns the summation of the two. The example application may be seen on the right. The project consists of four main components-
Without one of these components working correctly, the project will fail entirely and be very difficult to debug, this makes initial development of such a system particularly taxing, and I would strongly recommend taking this work as a basis for developing any further systems. All the code discussed code and dircuit diagram can be found in the zip file below. OverviewIt is important to consider how the overall system is going to work, and how the different components interact with each other to complete the overall task which in this case is a rather trivial one. At the basic level we are going to use the on board USB interface on the PIC to communicate with PC, all communications on the PIC are handled by the microchip usb stack. The USB stack is responsible for enumerating the device on the PC, this is essentially a fancy way of letting the PC know that we are connected and to which port it is connect to. The stack is also responsible for sending the appropiate descriptors to the PC, essentially telling the PC what sort of device it is. It is possible to change both of these however I shall leave these for another article! Once the pic is connected to the PC, we shall be using the standard microchip drivers to communicate with the device. This forms a data channel from Windows to a segment of code in the PIC. The final link in the chain is the code at both ends of the channel, which can be customised to produce the functionallity required. So now you know roughly what we are going to try and do, lets get cracking!! |
|||||||
Last Updated ( Thursday, 06 April 2006 ) |
< Prev |
---|