Table of Contents

Overview

This document explain how to control ADC on the Odroid ADK board by Android ADK App. PIC24FJ64GB002 is going to try read ADC value from voltage at the battery and the Variable Resistor, and transfer to Android ADK App. ADK App display the result based on the ADC value.


이 문서는 Odroid ADK Board 를 이용하여 ADC 를 제어하는 Android ADK app 를 설명한다. PIC24FJ64GB002 칩은 밧데리와 가변저항의 전압을 ADC 값으로 읽어 와서, Android ADK app 으로 전달한다. Android ADK App 는 ADC 값을 바탕으로 화면에 결과를 표시한다.

What you need

Knowledge Base

Variable Resister

* Symbol vresister.jpg

ADC(Analog to Digital Converter)

Please refer to PIC24F Family Reference Manual, Sect. 17 10-Bit A/D Converter.([http://ww1.microchip.com/downloads/en/DeviceDoc/39705b.pdf])

Circuit

Schematic

Video

[http://www.youtube.com/watch?v=gjGIvDDPYD4]

//www.youtube.com/embed/gjGIvDDPYD4

Software

ADK svn check out http://dev.odroid.com/svn/accessory/trunk/ODROIDAccessoryADCDemo

    private void initDevice() {
        Log.e(TAG, "initDevice");
        // fix bug 
        // You must call function to use GPIO input mode, if firmware version is 1.0 
        initI2C();
        initBMP180();
        // fix bug 
        initADC(true);
    }   

초기화 후 handler에서 battery 값과 ADC 값을 읽어 표시하면 됩니다.

        accessoryManager.read(commandPacket);

    switch(commandPacket[0]) {
        case RECEIVED_LETTER_ADC:                      
            value = (short) (commandPacket[3] << 8); 
            value |= (short) (commandPacket[4] & 0x00ff);
            updateADC(value);
            break;
                
        case RECEIVED_LETTER_BATT:
            value = (short) (commandPacket[3] << 8); 
            value |= (short) (commandPacket[4] & 0x00ff);
            updateBatt(value);
            break;

Bluetooth

svn check out

http://dev.odroid.com/svn/accessory/trunk/ODROIDBluetoothADCDemo

svn check out

http://dev.odroid.com/svn/accessory/trunk/ODROIDBluetoothADCDemo

ADK 펌웨어에서는 자동으로 ADC와 Battery 값을 보내 주지만, BaB 펌웨어에서는 request해야 보내 줍니다. 그래서 Timer를 두어 protocal로 request를 보내고 받아서 처리하면 됩니다.

private void getADC() {
        //Log.e(TAG, "getADC");
        Message msg = Message.obtain(handler, SEND_LETTER_ADC_CONFIG, ADC_PORT, 0);
        handler.sendMessage(msg);
    }

private void getBattery() {
        //Log.e(TAG, "getBattery");
        Message msg = Message.obtain(handler, SEND_LETTER_BATT, 0, 0);
        handler.sendMessage(msg);
    }