jml

ADXL362 Blinky Demo

Discussion created by jml on Oct 4, 2012

In the engineering zone post: How to use the ADXL362 to eliminate a power switch and control system power http://ez.analog.com/message/40001 I gave a basic schematic and some code to set an and ADXL362. Please have a look at that post and the attache zip file for the full C code and libraries along with a PDF for the schematic.  The PDF schematic is also attached to this post.

 

  In a recent challenge it was asked can you set the ADXL362 to blink and LED.  Of course other choices for an LED blinker could be the '555 and and LML3909. It turns out that the 'xl362 as an LED blinker uses less power than either of the other solutions.

 

The ADXL362 as an LED flasher is only using under 2na other then the LED on current.

The ‘555 takes 3 ma @ 5v so it takes about 1000 times more current!

The ‘3909 takes 0.5 ma so its over 200 times the current!

 

So the ADXL362 as an LED flasher is more power efficient!

 

Here is the code to set it up:

 

/*----------------------------------------------------------------------
  File Name          :
  Author             : MPD Application Team
  Version            : V0.0.1
  Date               : 11/06/2008
  Description        :
  File ID            : $Id: xl362_blink_main.c,v 1.1 2012/09/28 19:54:41 jlee11 Exp $

  Analog Devices ADXL362 digital output accelerometer
  with advanced digital features.

  (c) 2008 Analog Devices application support team.
  xxxxxx@analog.com@analog.com

  ----------------------------------------------------------------------

  The present firmware which is for guidance only aims at providing
  customers with coding information regarding their products in order
  for them to save time.  As a result, Analog Devices shall not be
  held liable for any direct, indirect or consequential damages with
  respect to any claims arising from the content of such firmware and/or
  the use made by customers of the coding information contained herein
  in connection with their products.

----------------------------------------------------------------------*/
//  include <pic.h>
//  include <datalib.h>
#include <htc.h>
#include "XL362.h"
#include "xl362_io.h"
__CONFIG(FOSC_INTOSC &  BOREN_OFF & PWRTE_ON & CP_OFF & MCLRE_ON & LVP_ON & LPBOR_OFF & WDTE_OFF );

void i2cinit(void);
unsigned char buffer[8]; /* a buffer to use with the read and write functions */
void main(){
  OPTION_REG = 0x87 /*disable wakeup and pullups max prescaller*/;
  OSCCON = 0x30; // 1 mhz

/* power up timer */
buffer[3] = 255;
while(buffer[3]--);
/* initialize SPI with two device ID read */
xl362Read(4,XL362_DEVID_AD,buffer);
xl362Read(4,XL362_DEVID_AD,buffer);

/* soft reset for safety */
  buffer[0] = XL362_SOFT_RESET_KEY;
  xl362Write(1,XL362_SOFT_RESET,buffer);

/* wait for soft reset to pass */
buffer[3] = 255;
while(buffer[3]--);

  /* set up a buffer with all the initialization for activity and inactivity */
  buffer[0] = 1;     /* XL362_THRESH_ACTL minimum*/
  buffer[1] = 0  ;  /* THRESH_ACTH */
  buffer[2] = 50  ;  /* TIME_ACT  1/2 second at 100 hz*/
  buffer[3] = 255;  /* THRESH_INACTL maximum*/

  buffer[4] = 7  ;  /* THRESH_INACTH */
  buffer[5] = 50 ;  /* TIME_INACTL 1/2 seconds at 12.5 hz*/
  buffer[6] = 0  ;  /* TIME_INACTH */
  buffer[7] =     /* ACT_INACT_CTL */
               XL362_ACT_ENABLE | XL362_ACT_DC | XL362_INACT_ENABLE
    | XL362_INACT_AC | XL362_ACT_INACT_LINK | XL362_ACT_INACT_LOOP;
  xl362Write(8,XL362_THRESH_ACTL,buffer);


  /* set up a buffer with all the initization for intmaps fitler and power*/
  buffer[0] = 0 ; /* INTMAP1 */
  buffer[1] = XL362_INT_AWAKE ; /* INTMAP2 */
  buffer[2] =     /* FILTER_CTL */
    XL362_RATE_100 |  XL362_RANGE_8G;
  buffer[3] =     /* POWER_CTL */
    XL362_MEASURE_3D |  XL362_LOW_POWER;
  xl362Write(4,XL362_INTMAP1,buffer);

  /* No interrupts INTCON = 0x90; */
  while(1){ /* we only resume here after a wakeup interupt */
    asm("sleep"); /* go into low power mode */
  } /* while */
} /* main */

 

 


Attachments

Outcomes