dcsimg
Skip to end of metadata
Go to start of metadata

Table of Contents

Project Overview

The goal of this project is to demonstrate IDT’s wireless charging technology and the use of supercapacitors as an alternative to battery backups.  The device also uses an XBee wireless module to communicate with another identical device with each sending the state of charge to the other.  The incoming data is then processed through a microcontroller and written to an LCD display via I2C.  

Resources Used

 

Hardware

Schematic

Figure 1. Schematic view.

Figure 1 shows the schematic of the main PCB.  Header JP1 is the +5V input from the IDT receiver which is fed into the input of the MIC29300 LDO regulator (U2).  While the +5V from the wireless charger is present, the MIC29300 provides 3.3V to the rest of the board and acts as the input to the LTC3110 charger (U1).  The voltage divider on the DIR pin of the LTC3110 will be set above its rising threshold and put in charging mode.  The charge current can be programmed up to 2A with a resistor, but in this application we set it to 500mA.  When the +5V is removed, DIR will become low and the capacitors will be used as the input.  The 3.3V system voltage is then provided by the LTC3110.  The Schottky diode (D1) prevents backward current flow during backup mode.

Meanwhile, the PIC16F1708 microcontroller (U3) reads the voltage at the midpoint of the capacitors on RA4 and converts it into a percentage.  The percentage is written to the LCD display over I2C and sent over UART to the XBee module (U4) to be transmitted.  The device is calibrated for the 100% point being 5.0V and the regulator cuts out around 0.25V.  Therefore, the device will lose power when the display shows approximately 10% charge.  

Layout

Figure 2. Layout view.

Figure 2 shows the layout of the main board.  Pay special attention to the manufacturer’s recommended layout for the LTC3110 buck-boost converter to ensure stability and good thermal performance.  

This board was fabricated by OSH Park and follows their design rules.  It has two layers and measures 90.7mm x 69.5mm.  The zip file below contains the Gerber and drill files necessary to reproduce this design.

EWProjectGerbers.zip

 

Software

XBee Configuration

First, let’s start with the settings of the XBee module.  The settings can be programmed through Digi International’s XCTU software.  For this project, a USB adapter board like Sparkfun’s WRL-11812 was used to program the device.  I have left all the settings at the default values aside from the addresses, which can be seen below in Figure 3.

 















Figure 3. XCTU settings.

Note that the destination and source addresses would need to be flipped on the other unit.  This application doesn’t require very long distance transmission, so the lowest power setting is okay, but since we have plenty of power to spare I left it at the highest.  This can be scaled as necessary.

Note:  You may notice that there is an I/O line from the microcontroller (RC2) to the SLEEP_RQ pin on the XBee module.  The pin hibernate or sleep functions can be used, but be warned that the devices can become out of sync and miss data packets.  No sleep function is used in the final build of this project.

Embedded

 

Since this project uses multiple peripherals on the PIC16, Microchip’s Code Configurator extension for MPLAB X is very useful for getting everything up and running quickly.   The individual settings and API definitions can be found in the full project below, but I will highlight the main settings here:

  • Clock set as INTOSC 16MHZ_HF
  • I2C at 100kHz with 7-bit slave addresses
  • USART with transmit enabled and continuous receive at 9600 baud
  • ADC using VDD as positive Vref and clock set at FOSC/64, using channels AN3 and AN7
  • TMR0 with 10ms period using a prescaler of 256, callback rate of 1000ms, interrupts enabled
  • TMR1 with 1ms period from FOSC/4, interrupts enabled

Important:  The I2C slave address for the LCD of 0x78 that is given in the data sheet will not work as is.  It has been pre-shifted to include the R/W bit and will not translate correctly if passed to the Microchip I2C APIs.  It needs to be shifted right one bit. So the correct 7-bit address is 0x3C.

Full MPLABX project: Embedded World Project.X.zip


main.c
/**
  Generated Main Source File
  Company:
    Microchip Technology Inc.
  File Name:
    main.c
  Summary:
    This is the main file generated using MPLAB® Code Configurator
  Description:
    This header file provides implementations for driver APIs for all modules selected in the GUI.
    Generation Information :
        Product Revision  :  MPLAB® Code Configurator - v2.25.2
        Device            :  PIC16F1823
        Driver Version    :  2.00
    The generated drivers are tested against the following:
        Compiler          :  XC8 v1.34
        MPLAB             :  MPLAB X v2.35 or v3.00
*/
/*
Copyright (c) 2013 - 2015 released Microchip Technology Inc.  All rights reserved.
Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).
You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.
SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
*/
#include "mcc_generated_files/mcc.h"
#include "lcd.h"
#define WRITE_BUFFER_SIZE 5
/*The voltage on the DIR pin of the LTC3110 should be around 1.2V or 372 raw A/D or 0, depending on the state. 
We choose a value at about half that as the threshold to correctly determine the state. */
#define CHG_THRESH 180  
uint8_t chg_message[21] = "@Charging:";  //Message = Data control byte,'@' or 0x40 + text
uint8_t dischg_message[21] = "@My charge:";  
uint8_t otherchg_message[21] = "@Other charge:";
unsigned char flag = 0;
unsigned int delay = 0;  //External variables to use for the timers
void delay_ms(uint8_t time)
{
    delay = 0;
    while(delay<time);
    delay = 0;
}
/*
                         Main application
 */
void main(void)
{
    uint16_t i = 0;
    uint8_t write_buffer[WRITE_BUFFER_SIZE] = {LCD_DATA_BYTE, 0, 0, 0, '%'};
    uint16_t adc_result, state;
    uint8_t charge_percent;
    uint32_t temp; 
    uint8_t current_state, past_state, change;
    delay = 0;
    
    // initialize the device
    SYSTEM_Initialize();
    // When using interrupts, you need to set the Global and Peripheral Interrupt Enable bits
    // Use the following macros to:
    // Enable the Global Interrupts
    INTERRUPT_GlobalInterruptEnable();
    // Enable the Peripheral Interrupts
    INTERRUPT_PeripheralInterruptEnable();
    // Disable the Global Interrupts
    //INTERRUPT_GlobalInterruptDisable();
    // Disable the Peripheral Interrupts
    //INTERRUPT_PeripheralInterruptDisable();
    
    delay_ms(2000); //Delay to give the LCD time to start up before using I2C.
    LCD_Init();
    change = 1; //Make sure the LCD displays something right away
    while (1)
    {
        ADC_StartConversion(channel_AN7);       //Begin conversion of the DIR pin on LTC3110
        while(!ADC_IsConversionDone());
        state = ADC_GetConversionResult();    //Check the initial state after power up
        if(state < CHG_THRESH)              //Determine if charging or in backup
        {
            current_state = 0;
        }
        else
        {
            current_state = 1;
        }
        
        if(past_state != current_state)     //Compare to past state to see if it has switched over. Used to avoid rewriting the whole LCD unnecessarily.
        {
            change = 1;
        }
        ADC_StartConversion(channel_AN3);   //Begin A/D conversion of the capacitor voltage.
        
        if(change != 0)
        {
            if(!current_state)      //State is "low" -> device is discharging
            {
                //LCD Layout should look like this:
                //My charge: xxx%
                //Other charge: xxx%
                LCD_Command(0x01);      //Clear current LCD message
                for(i=0; i<1000; i++);  //Give the LCD time to process the instruction
                LCD_Write(dischg_message, 15);  //Write the discharging message
                LCD_Move_Cursor(2,0);
                for(i=0; i<1000; i++);
                LCD_Write(otherchg_message, 14);
            }
            else if(current_state)    //State is "high" -> device is being charged
            {
                //LCD Layout should look like this:
                //Charging... xxx%
                //Other charge: xxx%
                LCD_Command(0x01);  //Clear current LCD message
                for(i=0; i<1000; i++);  //Give the LCD time to process the instruction
                LCD_Write(chg_message, 12); //Write the charging message
                LCD_Move_Cursor(2,0);
                for(i=0; i<1000; i++);
                LCD_Write(otherchg_message, 14);
            }
            change = 0;                 //Clear the change of state flag
        }
        
        LCD_Move_Cursor(1, 15);
        
        while(!ADC_IsConversionDone());
        /*Read the result of the capacitor voltage and convert A/D value into a percent.  775 is the value of 2.5V
		  Note that 2.5V is the ideal value, so you may occasionally see percentages > 100 due to various tolerances. */
        adc_result = ADC_GetConversionResult();      
        temp = (uint32_t) adc_result * 100;
        temp = (uint32_t) temp / 775;
        charge_percent = (uint8_t) temp;
        if(flag)        
        //Flag is set about once per second by the timer interrupt callback. This avoids the LCD updating too frequently and displaying small variations in the A/D reading.
        { 
            delay_ms(14);       //Wait long enough for the XBee to wake up.
            Decimal2Ascii(charge_percent, write_buffer);
            LCD_Write(write_buffer, WRITE_BUFFER_SIZE);
            EUSART_Write(charge_percent);   //Send the percentage of charge to the UART
            LCD_Move_Cursor(2,15);   //Move LCD address cursor to the correct spot before writing
            if(EUSART_DataReady > 0) //Check if there is data waiting on the UART
            {
                //Read in the data of the other device
                Decimal2Ascii(EUSART_Read(), write_buffer);
                LCD_Write(write_buffer, WRITE_BUFFER_SIZE);
            }
            flag = 0;
        }
        past_state = current_state;
    }            
}
/**
 End of File
*/


tmr1.c
void TMR1_CallBack(void) {
    // Add your custom callback code here
    delay++;
}
tmr0.c
 void TMR0_CallBack(void) {
    // Add your custom callback code here
    // this code executes every 100 TMR0 periods
    flag = 1;       //Set flag to let main know to write to LCD and Xbee
    
}

Bill of Materials


Quantities provided are for making one complete project with two boards. 

Table 1. Bill of Materials

Qty

Designator

Digi-Key P/N

Manufacturer P/N

Description

2

U1

LTC3110EFE#PBF-ND

LTC3110EFE#PBF

IC REG BUCK BOOST ADJ 2A 24TSSOP

2

U2

576-1120-ND

MIC29300-3.3WU

IC REG LDO 3.3V 3A TO263-3

2

U3

PIC16F1708-I/P-ND

PIC16F1708-I/P

IC MCU 8BIT 4K FLASH 20DIP

2

U4

602-1273-ND

XB24-API-001

MOD XBEE 802.15.4 1MW W/PCB ANT

2

U5

NHD-C0220BIZ-FS(RGB)-FBW-3VM-ND

NHD-C0220BIZ-FS(RGB)-FBW-3VM

LCD DISPLAY RGB LED BKLT 20 X 2

4

N/A

SAM1230-10-ND

MMS-110-01-L-SV

CONN RCPT 10 POS 2MM PITCH TH - Xbee headers

2

N/A

AE9998-ND

A20-LC-TT

CONN IC DIP SOCKET 20POS TIN - PIC

2

L1

587-1997-1-ND

NR8040T2R0N

FIXED IND 2UH 6.3A 11.7 MOHM SMD

2

Q1

478-7808-1-ND

 SD1206T020S1R0

DIODE SCHOTTKY 20V 1A 1206

2

Csys

399-5506-1-ND

C0805C476M9PACTU

CAP CER 47UF 6.3V X5R 0805

2

Cin

399-9155-1-ND

C0805C104K9RACTU

CAP CER 0.1UF 6.3V X7R 0805

6

Ccap, C3, C4

399-1284-1-ND

C0805C105K4RACTU

CAP CER 1UF 16V X7R 0805

2

Cout

399-8014-1-ND

C0805C106M9PACTU

CAP CER 10UF 6.3V X5R 0805

2

Cvsys

445-8199-1-ND

CGJ4J2X7R0J224K125AA

CAP CER 0.22UF 6.3V X7R 0805

4

C1, C2

 JUK0E276MHD-ND

JUK0E276MHD

CAP 27UF 2.5V 20%

2

Rprog

311-12.1KCRCT-ND

RC0805FR-0712K1L

RES SMD 12.1K OHM 1% 1/8W 0805

2

R2

311-536KCRCT-ND

RC0805FR-07536KL

RES SMD 536K OHM 1% 1/8W 0805

2

R1

311-1.91MCRCT-ND

RC0805FR-071M91L

RES SMD 1.91M OHM 1% 1/8W 0805

2

Rsvsys

311-51.1CRCT-ND

RC0805FR-0751R1L

RES SMD 51.1 OHM 1% 1/8W 0805

2

R3

311-976KCRCT-ND

RC0805FR-07976KL

RES SMD 976K OHM 1% 1/8W 0805

2

R4

311-221KCRCT-ND

RC0805FR-07221KL

RES SMD 221K OHM 1% 1/8W 0805

2

R5

311-7.50KCRCT-ND

RC0805FR-077K5L

RES SMD 7.5K OHM 1% 1/8W 0805

2

R6

311-2.49KCRCT-ND

RC0805FR-072K49L

RES SMD 2.49K OHM 1% 1/8W 0805

4

R7, R8

311-4.70KCRCT-ND

 RC0805FR-074K7L

RES SMD 4.7K OHM 1% 1/8W 0805

2

R9

311-150CRCT-ND

RC0805FR-07150RL

RES SMD 150 OHM 1% 1/8W 0805

 

Table 2. External Components.

1

External

800-2975-ND

P9038-R-EVK

EVAL KIT FOR P9038 - Transmitter

2

External

800-2977-ND

P9025AC-R-EVK

EVAL KIT FOR P9025 - Receiver

2

Enclosure

SRB53-TCBC-ND

RB53-1TC1BC

BOX PLSTC CLEAR 4.72"L X 3.15"W

4

Standoffs

36-8431-ND

8431

HEX STANDOFF 8-32 ALUMINUM 1"

4

Screws

335-1101-ND

R8-32X5/16 2701

MACHINE SCREW PAN PHILLIPS 8-32

1

USB Adapter

1568-1305-ND

WRL-11812

SPARKFUN XBEE EXPLORER USB

Comments

Comments, feedback, and questions can be sent to: eewiki@digikey.com

 


 

  • No labels