FREQUENCY COUNTER AND VOLTMETER
Updated on 11.6.2015
Using PIC18F2550 for connecting analogue
and digital signals to USB port . Included Visual Basic 6 code, Visual Studio 2005 C# code, PIC ASM code, PIC C code and a circuit diagram. The PIC microcontroller
has 10 bit analogue to digital converter, by selecting 8 bits conversion the 2 LSB are ignored. The circuit is powered
by the USB. The interface to the PC is HID class.
The frequency counter has a range of up to 4MHz (24bits). Inputs samplings can be done at rates of 1 per second and 1 every 0.1 second.
HID class (human interface device) is a class of
devices like the mouse and the keyboard, the data transfer rate
is limited to 64KB/S. The PC already has a driver for HID USB.
C# code is modified Microchip code from the USB framework, Microchip Solutions v2012-04-03.
VB6 code includes guidance to setting up the PC.
The PC register the PID and VID (product ID) of the USB device when
it's plugged, the VB code uses these ID's to communicate with the
device. For commercial VID it is needed to buy it from USB-IF, but in your lab you can use any number.
The source code is derived from freeware from these sources: http://janaxelson.com/usb.htm , http://openprog.altervista.org/USB_firm_eng.html
You are free to use the circuit diagram and the VB software with no
The VB6 application is a combined digital and analogue
See also Technical Tips
Pin 3 is the analogue input, voltage range 0 to 5V. Max input voltage
is 5.5V .
Pin 11 is the counter input, TTL voltage levels.
Pin 14 is 3.3V internal supply for the USB transceiver. 0.22uF is
required for regulation.
Pins 15,16 are the data lines to the USB connector on the PC.
Pin 20 is the PC 5V powering the PIC. It is limited to 100mA by
the PC. 0.47uF is for decoupling.
For USB wiring info: http://www.interfacebus.com/Design_Connector_USB.html