Summary of PIC18F452 to PC USB 2.0 interface with FT245BM
This article details a project interfacing a PIC18F452 microcontroller with a PC via USB using an FT245BM chip. The system captures ambient temperature via a TC77 sensor, processes it through the PIC, and transmits data to a C# application running on Windows. The USB interface uses D2XX drivers for high speed, with custom device identification stored in an external EEPROM.
Parts used in the PIC18F452 USB Interface Project:
- PIC18F452 Microcontroller
- FT245BM USB Interface Chip
- TC77 SPI Temperature Sensor
- 93C46 External SPI EEPROM
- C# Application Software
- FTD2XX.dll Driver Library
- AID.dll Communication Library
- MProg EEPROM Programming Utility
Here is an example of how to interface a PIC18F452 to a PC via the USB port.
The windows-pc (98, Me, 2000, XP, 2003) runs a program (C# application, Microsoft Visual Studio .NET 2003) to communicate with the USB interface, which transfers data to and from the PIC18F452.
Many thanks to FTDI to deliver royalty-free drivers (FTD2XX.dll) and to KOPF to develop the needed library (AID.dll)
All parts are available in our online shop.
Schematic (Eagle 4.11e), PIC source code (CCS) , PIC hex file, C# code and application available for download.
Circuit explanation:
|
PIC example (18f452) < > USB interface (FT245BM) < > PC program (C# application) |
PIC example (18F452:)
The PIC captures the ambient temperature with a SPI sensor TC77. Its value is then transferred to the USB-interface.
USB interface (FT245BM:)
The USB interface will have to be recognized as a device by Windows. Basically, there are two ways of doing this. Either with a VCP (Virtual COM Port) or with a D2XX (Direct) driver. We will use the D2XX driver here for its high speed. It is more complicated to start up than VCP, but why not going the extra mile?
The FT245BM chip comes with a fixed VID (0403) and PID (6001). We can override this with our own VID (ECDE), PID (0001), our own Product Description (TechDesign USB Device 017) and serial number (FEDC0001). These settings are stored in an external SPI EEPROM 93C46. To program these settings, FTDI made a utility called MProg EEPROM programming utility.
When plugging in for the first time and with a blank (or without) EEPROM, you will notice that the interface is seen as “USB device” and after its driver is installed, it will be recognized as a “FTDI FT8U2XX Device”. Now we can program the EEPROM with our custom settings. To do this, run MProg, open the file 017_USB_id.ept and program (choose “Device”, then “Program”). After this, unplug the interface briefly and plug it in again. It will now be recognized as a “TechDesign USB Device 017”. Acknowledge a couple of times to install it and you are done.
Note that this project will also work without an EEPROM, but in that case you will have to make do with the fixed VID & PID.
PC program (C# application:)
A dll file is performing the communication between the C# application and our USB-interface. It must be placed in the same directory as the exe-file below. Acknowledgements to KOPF for providing this dll and the example “USBTransfer.exe” on which this application is based.
The C# application can be run on any Windows 98, Me, 2000, XP, 2003 platform. It will show the temperature reading captured with the PIC (see above). Here is a quick link to its main form. Download the msi (Microsoft installer file) below to install the application.
You need to have Microsoft .NET Framework 1.1 (or higher) installed to be able to run the executable.
For more detail: PIC18F452 to PC USB 2.0 interface with FT245BM
- How does the PIC capture and transfer data?
The PIC captures ambient temperature with a SPI sensor TC77 and transfers the value to the USB-interface. - Can I use VCP instead of D2XX drivers?
Yes, but the article recommends D2XX for high speed despite it being more complicated to start up than VCP. - What happens if I do not use an EEPROM?
The project will still work without an EEPROM, but you must use the fixed VID and PID provided by the chip. - How do I customize the device name and ID?
You can override the fixed settings by programming custom VID, PID, Product Description, and serial number into an external SPI EEPROM 93C46. - Which utility is used to program the EEPROM settings?
FTDI provides a utility called MProg EEPROM programming utility to write the custom settings. - What software components are required to run the C# application?
You need Microsoft .NET Framework 1.1 or higher installed, along with the FTD2XX.dll and AID.dll files placed in the same directory as the executable. - Which Windows versions support this application?
The C# application can be run on any Windows 98, Me, 2000, XP, or 2003 platform. - How do I verify the custom device settings were applied?
After programming the EEPROM and replugging the interface, Windows should recognize it as "TechDesign USB Device 017" instead of the default FTDI device.
