Intro: Android On-The-Go (OTG) LC-Meter
Presented here is a modified design based on a Microchip PIC18F14K50 USB Flash Microcontroller which is connected to an Android phone using the On-The-Go (OTG) mode. The phone provides power to the circuitry and an Android Application provides the Graphical-User-Interface (GUI).
The following are the highlights of the design:
- Single PIC18F14K50 microcontroller with USB interface and internal analog comparator
- Simple c-code on the microcontroller implementing a basic frequency counter
- GUI Test code in Qt Creator and Android application using Android Studio
- All calculations carried out in higher level language
- Low power consumption ~ 18 mA at +5V
- Design verified by building a bread-board and engineered unit
I wish to acknowledge use of the Usb serial controller for Android v4.5 example code in implementing the OTG connectivity.
Step 1: Theory of Operation & Circuit Schematic
The basic principle of operation is based on determining the resonant frequency of a LC parallel tuned circuit.
Refering the equivalent circuit: The internal comparator is set-up as an oscillator whose frequency is determined by the LC parallel resonant circuit.
L1/C7 form the core resonant circuit oscillating at ~50 kHz. Let us call this F1
A capacitor of accurate value, C6 is added in parallel during the calibration cycle. The frequency then changes to ~ 30 kHz. Let us call this F2.
The resonant frequency changes when either an unknown inductor LX is connected in series with L1 or an unknown capacitor CX is connected in parallel with C7. Let us call this F3.
Measuring F1, F2 & F3 it is possible to calculate the unknown LX or CX using the equations shown.
The calculated and displayed values for two conditions 470 nF and 880 uH are shown.
The PIC18F14K50 is a single chip solution for the OTG-LC Meter as it provides an internal comparator which can be used for the LC-Oscillator and an in-built USB interface permitting connection to a PC-USB port or the Android Phone OTG Port.
Step 2: Android Application
- After setting up the Android phone to development mode, install the app-debug.apk from the software step using a PC and suitable USB cable.
- Connect the LC-meter to the Android phone using an OTG adaptor.
- Open the LC meter Application (Figure 1)
- Press the Connect button, results in request for connection (Figure 2)
- With probes open in C-Mode or shorted in L-Mode, press Calibrate, results in Ready (Figure 3)
- In C-Mode, connect unknown capacitor (470 nF) and press Run, (Figure 4, 5)
- In L-Mode, connect unknown inductor (880 uH) and press Run (Figure 6,7)
Step 3: Power Consumption
The PIC18F14K50 is a USB Flash Microcontrollers with nanoWatt XLP Technology.
The three pictures show the current drawn by the LC-Meter hardware in OTG-Mode during different stages of operation:
- When the hardware is connected to the Android phone but the application is not initiated, 16.28 mA
- When the application is initiated and is in RUN mode, 18.89 mA
- Only for 2 Seconds when Calibration is initiated, 76 mA (additional relay current)
Overall the application when running draws less than 20 mA which would be of the order drawn by the 'Torch' in an Android phone.
Step 4: Hardware
The PCB design was carried out in Eagle-7.4 and the CAD files are attached in .Zip form. They contain all details including the Gerber data.
However for this project, a breadboard model was first fabricated. After finalization of the circuitry the detailed design was carried out in CADSOFT Eagle 7.4 and the PCB fabricated using the toner-transfer method.
Card level tests were carried out using the Qt test software before packaging the card into the plastic enclosure.
Fabrication and test of two units helps in validating the repeatability of the design.
Step 5: Software
This project involved the development of code on three development platforms:
- The development of the embedded code for the PIC18F14K50 microcontroller
- PC based test/independent application in Qt on Linux
- Android application using Android Studio on Linux
The C-Code for the PIC18F14K50 was developed under MPLAB 8.66 using CCS-C WHD Compiler. The code and fuze file are attached:
- 037_Android_2_17 Sept 17.rar
- PIC_Android_LC-Meter.hex (open in MPLAB with a checksum 0x8a3b)
Qt test application on Linux
A Qt test application was developed under Qt Creator 4.3.1 with Qt 5.9.1 under "Debian GNU/Linux 8 (jessie)". The code is attached:
This can be used as an independent PC based application using the LC-meter hardware
Android application on Linux
Developed under Android Studio 2.3.3 with sdk 26.0.1.
Tested on Android phone, Radmi MH NOTE 1LTE with Android version 4.4.4 KTU84P
apk file app-debug.apk