HOME Technical Tips  


Updated on 10/9/14 , L Meter added.
PIC18F2550 for connecting analogue and digital signals to USB port . Included Visual Basic 6 software, 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 meter has a range of up to 4MHz (24bits). The meter accuracy is 0.2% or better.
Inputs samplings can be done at rates of 1 per second and 1 every 0.2 second.
The cap meter (max 50uF) measures the period of charging the cap to the Vref. The accuracy is about 5%, it depends on the charge resistors, can be calibrated by trimming 1K5 and 1M5 resistors or by the VB code.
The inductance meter (max 1H) measures the oscillation frequency of the coil under test in parallel to 0.22uF. The oscillation is triggered by a 10uS pulse from RB3. The accuracy of the measurement is about 5% and can be calibrated by the VB code or by trimming 0.22uF cap.
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.
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
Code was written on MPLAB 8x and compiled with C18 ver 3.43. PIC18F2550 was programmed using Velleman K8076.
Software includes PIC code and VB6 code. You are free to use the circuit diagram and the VB software with no limitations.

The VB6 application is a combined digital and analogue voltmeter.

Circuit Description
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.
Cx is the cap under test. BC546 selected as low leakage device for reducing error. Resistors 1M5 and 1K5 selected to give accuracy of 10%, 1K5 can be trimmed for better accuracy of uF range and 1M5 for nF range.
Lx is the coil under test. 220R triggers the coil to oscillate with parallel 0.22uF. For better stability 0.22uF should be polypropylene cap. 470K and 1K resistors on pin 4 bias the comparator input by 10mV to insure high output at idle state.
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. 10uF is for decoupling.
For USB wiring info: http://www.interfacebus.com/Design_Connector_USB.html


Comments and questions

Copy the number from the picture It stops net-robots from adding comments.

25.03.2015 - 13:22
Name: Jaap
Comment: Hi Moty On the site http://embedded-lab.com/blog/?p=3146 , is the source file to download.And according to the comments it,s easy ,only change one digit.But I am not able to compile the hex file. Dare to ask,you can try.

22.03.2015 - 23:06
Name: Moty
Comment: The x in 0x92 is lowercase X letter , the symbol you used isn't C syntax. If you not sure copy and paste from this comment.

22.03.2015 - 22:57
Name: Moty
Comment: Try: const int TC74A0 = 0x92; 0x92 is hex number. If it fails or if you need more general help try this forum, many helpful people there: http://www.electro-tech-online.com/

22.03.2015 - 20:20
Name: Jaap
Comment: Hi Moty I understand that we need to keep in touch. The project that I build at this moment has the same chip PIC18F2550. http://embedded-lab.com/blog/?p=3146 This works fine with a sensor TC74A0. Now I wanted to build it with a TC74A2 sensor. That should be possible with the line of the code: const int TC74A0 = 090; Replace 090 by 092, and it should work.(According to the text in comments) But that failed me, too many errors, and he compiles no hex file. You could manage that? Hope you do not mind this.

24.07.2014 - 00:48
Name: kanishka
Comment: great effort moty it s really useful thing great job great............!!!!!!

iconFlag Countermoty22.co.uk  2008-2022