SMALL PROJECTS   Projects tipsTechnical Tips
Categories
Android Projects
Doorbell
PC Frequency Counters
Codelocks
Analogue
Egg Timers
Frequency Generators
LCD Frequency Counters
LED Frequency Counters
LED Thermometer
Data Loggers
LPT Interface
Birthday Cards
OBD2
OLED Frequency Counters
OLED Thermometers
Oscilloscope
SD Card Audio
Picture Frames
Serial Port Interface
Water Softeners
Talking Clocks
TFT Clocks
TFT Frequency Counters
TFT Egg Timers
Thermometers
USB Frequency Counters
CH341, LCD To USB
USB Thermometers
USB Inputs Outputs
WiFi Projects

See also PC Counter c1mhz.php

USB FREQUENCY COUNTER AND VOLTMETER

Using PIC18F2550 for connecting analogue and digital signals to USB port . Included Visual Basic 6 code, Visual Studio 2005 C# code, Visual Studio 2010 VB code, PIC C code for MPLABX with XC8, PIC ASM code and PIC C code for C18. Any app code works with every PIC code. 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 12MHz (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.
MPLABX, VB, and C# code is modified Microchip code from the USB framework, Microchip Solutions v2017-03-06.
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 VB6 and C18 source code is derived from freeware from these sources: http://janaxelson.com , http://openprog.altervista
You are free to use the circuit diagram and the VB software with no limitations.

 counter

Circuit Description
See also Technical Tips

Analogue input, voltage range 0 to 5V. Max input voltage is 5.5V .
The counter input, TTL voltage levels.
3.3V internal supply for the USB transceiver. 0.22uF is required for regulation.
D+ D- are the data lines to the USB connector on the PC.
For USB wiring info: http://www.interfacebus.com

line

USB FREQUENCY COUNTER AND VOLTMETER

Using PIC16F1459 for connecting analogue and digital signals to USB port . Included Visual Basic 6 code, PIC C code for MPLAB-X 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.
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 , http://openprog.altervista.org/
You are free to use the circuit diagram and the VB software with no limitations.

counter 

Circuit Description
See also Technical Tips

Analogue input, voltage range 0 to 5V. Max input voltage is 5.5V .
The counter input, TTL voltage levels.
3.3V internal supply for the USB transceiver. 0.22uF is required for regulation.
D+ D- are the data lines to the USB connector on the PC.
For USB wiring info: http://www.interfacebus.com/

line

USB FREQUENCY COUNTER AND VOLTMETER FOR ANDROID

Using PIC18F2550 for connecting analogue and digital signals to Android USB port . The Android USB port is easily accessed by imitating keyboard. 
PIC C code is Microchip sample code for USB Keyboard. The file Keyboard.c has the added code for the ADC and the frequency counter from line 900.  The USB sends 1 bytes at a time for each key, the 11 digits of the counter and voltage are sent in 30 bytes. The HEX file is included, the c code can be compiled using C18 v3.43 with MPLAB.
The Android app is in BASIC! graphic text. http://mougino.free.fr . The app uses graphic screen to displays voltage and frequency. The .apk file is the file that installs manually the app to your phone. For editing the app the .bas file can be imported after you install the RFO BASIC app to your PC and or your Android device.
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.

pc

The Android App

line

USB VOLTAGE, FREQUENCY INDUCTANCE AND CAPACITANCE METER

Using 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/ , http://openprog.altervista.org/
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.

 

Circuit Description
See also Technical Tips

PIC18F2550
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/

line

USB OSCILLOSCOPE PIC18F2550

USB low frequency oscilloscope, bandwidth is DC to 1KHz. Max sampling rate is 12680 samples per second. The trigger circuit uses the integrated comparator and CCP. An oscilloscope with these specifications has limited use, but it has an advantage on analogue oscilloscope for low frequencies.
App 1 is Visual Basic 6 and MPLAB C18 v3.30 or ASM, app 2 is VB2010 and MPLABX XC8. The circuit is powered by the USB. The interface to the PC is HID class.
The screen is constructed from 64 sampling. The ADC reads the input at resolution of 8 bits and in intervals determent by the Time Base. The 64 bytes are transmitted in one stream every 100ms or longer for lower frequencies.
The trigger input starts the sampling of the input at the trigger voltage rise. This gives the ability to measure phase shift between the trigger and the input. The trigger input isn't needed when looking at waveform only.
HID class (human interface device) is a USB class of devices like the mouse and the keyboard, the data transfer rate is limited to 64KB/S.
PIC18F2550 code is assembly code and C code (under GNU General Public License) for Microchip C18 compiler. MPLABX code is based on Microchip MLA USB Framework.
VB6 code includes guidance to setting up the PC. The PC register the PID (Product ID) and VID (Vendor 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 , http://openprog.altervista.org/

 

Circuit Description
See also Technical Tips

PIC18F2550
Pin 3 is the analogue input. Input voltage range is 0 to 5V absolute max, voltage outside this range can latch the input or even permanently damage the IC.
Pin 4 is the comparator input used to generate the trigger.
Pin 14 is 3.3V internal supply for the USB transceiver.
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

line

USB HID BMP DISPLAYED ON TFT

Using PIC18F2550 and 1.8", 160x128, ST7735 driver TFT module. Included Visual Basic 2010 code and MPLAB X XC8 code based on Microchip code. The circuit is powered by the USB. The interface to the PC is HID class. The app in VS2010-Express works for BMP files 24 bits only. Files have to be sized to 160 px wide and 128 px high.
When USB is plugged it verifies the connection with the host and then initialize the TFT. On uploading a BMP file it displays in about 2 seconds..
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.

 oled

line

WinUSB - TFT BMP Bitmap DISPLAY See also usb_lcd for CH341 TFT.

Using PIC18F2550 for connecting LCD TFT module to USB port .
WinUSB Driver and VS2005 software
Included PIC software based on LVR software for winUSB generic driver. The PC software using Visual Basic 2005 is based on LVR version. This driver allows data transfer at a speed of 120KB/s and the screen is loaded in 2 seconds.
After connecting the programmed PIC to the PC you need to install the driver, use the INF file that included. For the missing files you can download Microchip USB framework, all the needed files are there, http://ww1.microchip.com/

VB6 and HID class USB software
Also included Visual Basic 6 code and PIC C code that interfaces the PC in HID class. 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.The screen loads in about 1 minute.
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.

LCD TFT Module used is 8 bits drive. Inputs to the TFT driver are level shifted from 5V to 3.3V by buffers. The LCD driver is ILI9341.
The pic firmware can read only bitmap file of 24 bits bmp type. The file has to be size of 240 pixels width and 320 pixels high. The firmware removes the bitmap header (54 bytes) and then streams the rest of the file to the TFT. Every 3 bytes are the 24 bits color for one pixel. The bitmap format reads and displays the pixels of the image starting from bottom left.
To create a *.bmp file shrink the picture to 240 pixel wide and 320 pixel high, save it as 24 bit bitmap. You can use MS Paint.

The source code is derived from freeware from these sources: http://janaxelson.com http://openprog.altervista
Code was compiled with C18 ver 3.30. PIC18F2550 was programmed using Velleman K8076 or PICKIT2.
Software includes PIC code and VB code.

  

Circuit Description
See also Technical Tips

RD input is connected to 3.3V on the TFT module.
RST is the RESET of the TFT Module.
The module supply is 5V. The LCD driver I have is ILI9341.
PIC18F2550
Pin 14 is 3.3V internal supply for the USB transceiver. 0.22uF is required for regulation.
Pins 21 to 28 are port B outputs.
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



Name:

Comments and questions

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



14.04.2017 - 02:42
Name: Moty
Comment: The HEX file has to be programmed to the pic without any bootloader. You can use PICKIT 2/3 or similar programmer.

14.04.2017 - 00:19
Name: Ahmed
Comment: i meant source for the HIDbootloader, thanks

14.04.2017 - 00:18
Name: Ahmed
Comment: hi Moty, could you please provide de 18f2550 hidbootloader.hex and source for this excellent project? thanks for your help.

01.10.2016 - 02:27
Name: kanishka wijayananda
Comment: great! great! well done! thanks moty

02.03.2016 - 08:50
Name: wimpie
Comment: Hi my email is wimpieswanepoel1@gmail.com .if any one can help thanks

02.03.2016 - 08:48
Name: wimpie
Comment: Hi can i ask .i am building a sd card player useing a pic 16f690 i want 4 select switches that will play 4 short wav files on sd card .i am useing flowcode 4 but can not get it to work .and dont understand c code .any help thanks in advance

24.10.2015 - 21:40
Name: Moty
Comment: Hi Olakunle. I don't know the answer, try to get help from electronics forums.

24.10.2015 - 06:09
Name: Olakunle
Comment: please, how can I transmit a monochrome picture bit map from one pic 16f877 microcontroller, then at the destination pic16f877, how can I assemble the transmitted bit map into a file and give it d name of the source image monochrome bit map file e.g truck_bmp.c and then pass this file to Glcd_Image to help me draw the image on the Glcd of the destination pic 16f877. with the help of the mikro c online ebook, I have been able to display a monochrome image on the glcd using Glcd_Image (truck_bmp), so what I would like to do now is to transmit this image from the source to the destination. Thanks. Kunle

23.08.2015 - 23:46
Name: Richard Bahr
Comment: Some of the website links are dead Error 404 etc.

15.05.2015 - 03:49
Name: Ернар
Comment: хорошая идея

26.04.2014 - 11:24
Name: Moty
Comment: Hi. I've looked at your work, it is very impressive. Unfortunately I don't have the knowledge and the tools to use C#. I'm glad to be an inspiration.

25.04.2014 - 10:53
Name: N1c0
Comment: Hi Moty, An extended version of the USB Voltmeter was developed based on your schema & firmware. The client application sources can be found here: https://github.com/neremin/USB_Voltmeter It was developed using C# 4.0. It will work with you counter as well, in case you are interested in trying it. Thank you for publishing your project as a starting point for my work.

10.01.2014 - 02:14
Name: Moty
Comment: Hi ttede, I don't have experience with Proteus. Please ask your question but I can't promise to give help.

09.01.2014 - 11:29
Name: ttwde
Comment: Hello! I tried the in program Proteus your scheme to see it works correctly. Voltmeter shows nothing but Proteus it reacts, flashes 27 input PIC. Write please me your e-mail. My e-mail: ttwde@rambler.ru

25.05.2012 - 00:32
Name: Luis Alfonso Pulido Perez
Comment:

30.07.2010 - 19:49
Name: Moty
Comment: Hi Eduardo. The software I sent you is for Microchip C18, it will compile on C18 only. Because of the complexity of USB it will be to hard to migrate the software. You may find USB HID software for CCS on the net. I have no experience with CCS. Download the new C software for usbio from my website, it's for C18 but may give small number of errors when compiled on CCS.

30.07.2010 - 19:48
Name: Moty
Comment: Hi Alejando. To do what you want you need a HID Bootloader, the bootloader comes with an application for the PC to write the hex file to the PIC. You can find all the information and software you need free on Microchip website. You can also use other free bootloaders available on the net. My firmware will load on a PIC with bootloader only after re-compiling with bootloader linker file. The linker file arranges the location of the bootloader and the main application in the ROM of the PIC.

30.07.2010 - 00:15
Name: Alejando Ramos
Comment: Moty, I saw my brother assembly your circuit, i have a doubt, can we use the PIC in HID mode and write to the EEPROM?, my idea is to disconnect the PIC after loading a program and put the PIC in RUN MODE so it can be the brain of a robot or any other autonomus dvice, I did it but using a JDM Serial Programmer, it will be great to use the HID and don't have to unplug the PIC to program in the JDM programmer every time we would like to modify the program voltronch@hotmail.com

30.07.2010 - 00:07
Name: Eduardo Ramos
Comment: Hello Moty, which compiler do you use?, we tried the CCS and Mplab after modifying you main.c file to have all the Port B as Outputs. eduardoramosgaz@hotmail.com, v771v771@hotmail.com

29.07.2010 - 13:06
Name: Moty
Comment: Hi Regen. I've added tips about increasing the input voltage, please see the Technical Tips page: http://www.moty22.co.uk/general.php

02.07.2010 - 15:43
Name: Moty
Comment: Hi Eduardo. The HID device receives every 10ms 8 bytes from the PC together with the 8 bytes it sends. In the firmware the array of 8 bytes is named: ReceivedDataBuffer[ ] , the frequency counter uses byte1 for selecting the timebase, you can find the code in main.c . Bytes ReceivedDataBuffer[2] up to ReceivedDataBuffer[7] can be used to receive data. The VB6 sends array named: OutputReportData( ) . Byte0 is used for ID, you can use byte2 up to byte7 to send data to the device. The firmware already drives a LED. Connect the LED cathode to ground and the anode via 1K resistor to RB5 of PIC18F2550, By selecting the timebase on the VB you switch the LED on or off. You can see the instruction for that on line 209 of main.c - PORTBbits.RB5=ReceivedDataBuffer[1];

02.07.2010 - 03:07
Name: Eduardo Ramos
Comment: The HID also permit to write to a device ? I mean can we write a program that can move a motor o turn on a led through the PIC ?

21.06.2010 - 21:23
Name: Moty
Comment: Hi Eduardo. Yes, you can use the hex file on the PIC18F2450. The programme is about 2.1KB so it will easily fit into the ROM.

19.06.2010 - 21:34
Name: Eduardo Ramos
Comment: Hello, if I use the PIC18F2450 instead of the PIC18F2550, it will work loading the same V-Fmk2.hex file ?, If not what must I change in the file? regards,


16.06.2010 - 00:52
Name: Eduardo Ramos
Comment: Wow!, Fantastic, It wasn't working in my PC until I installed a HID device, Can you send me the V-Fmk2 c file ? my email is eduardoramosgaz@hotmail.com, thanks for share your knowledge, regards,

16.06.2010 - 00:46
Name: Eduardo Ramos
Comment: Wow! Fantastic, it wasn't working in my pc until I installed a HID device, I want to learn how to program it, can you send me the V-Fmk2 c file, thanks for share your knowledge, my email is eduardoramosgaz@hotmail.com,


19.05.2010 - 04:18
Name: Eduardo Ramos
Comment: eduardoramosgaz@hotmail.com Hello Moty, I assembly the circuit, and program the firmware "V-Fmk2.hex" using the WinPIC800 program and a JDM programmer circuit, but 1.- when I connect the usb circuit to the PC this doesn't recognize a usb device attached 2.- When I run the VB program does not recognize a device attached can you give me a clue how to troubleshoot the problem, I will appreciate your help, thank you very much

18.05.2010 - 09:44
Name: Moty
Comment: Hi Eduardo, This firmware does not have a bootloader, the program itself starts at address 0x0000. If you write to the pic18f2550 the hex file the same way you write the bootloader then the program of the counter will start immediately. If you want to add bootloader then you have to change the startup address in the asm file to address where you want to put the program in the ROM. If you use Microchip bootloader then the address is 0x1000.

17.05.2010 - 19:45
Name: Eduardo Ramos
Comment: Hello from Mexico, the hexadecimal file "V-Fmk2.hex" has the bootloader already for the pic18F2550?

16.05.2010 - 15:02
Name: Moty
Comment: Hi Jesus, Please add email address to send the software to. If you don't want your email displayed don't tick the box for displaying the comment.

16.05.2010 - 04:45
Name: Jesus
Comment: Hello friend, could you send me the C code for this project. Thanks.

Name: J K BARIK
Comment: THANKS


13.04.2010 - 01:41
Name: Mother Fucker von der Spree im Schwarzwald
Comment: Vielen Dank! Schickes kleines Projekt.

icon Flag Counter moty22.co.uk  2008-2025