Acceleration Sensor (2002, 2005)

Table of Contents

  • PIC16F84 + ADXL202
    • Hardware
    • Software
  • H8/3694F + ACB302 + EEPROM
    • Hardware
    • Software

PIC16F84 + ADXL202

Hardware

Software

  • sensor.c sampling program via RS232C for Linux (tested on Linux 2.2.16)
  • Makefile
$ make
$ ./sensor -h
Usage:  sensor [-hd] [-p serial-device]
        -h help
        -d power off serial port
                default serial-device : /dev/ttyS0
$ ./sensor > 20020807.log.3

raw data: 20020807.log.3 (format: index x-acceleration y-acceleration x-speed y-speed x-position y-position)

gnuplot> set xzeroaxis lt -1
gnuplot> set yzeroaxis lt -1
gnuplot> set ticslevel 0
gnuplot> set xlabel "x-speed"
gnuplot> set ylabel "y-speed"
gnuplot> set zlabel "index"
gnuplot> set terminal png color
gnuplot> set output "20020807.log.3.speed.png"
gnuplot> splot "20020807.log.3" using 4:5:1 with line

acceleration: 20020807.log.3.accel.png speed: 20020807.log.3.speed.png position: 20020807.log.3.position.png position animation (QuickTime): plot-line.qt presented by YOKOBORI Masayuki (miyabi at uranus.interq.or.jp)

H8/3694F + ACB303 + EEPROM

Hardware

Block diagram

Parts
Schematics

Qt-BSch3V [suigyodo.com]

$ tar zxvf qbsv010.tgz
$ cd qtbsch3v
$ qmake -project
$ qmake
$ make

Qt-LCo [suigyodo.com]

$ tar zxvf qlco005.tgz
$ cd qtlco005
$ qmake -project
$ qmake
$ make

Schematics: am.png, am.ce3 Libraries: ae-3694.lb3, acb302.lb3, at24c1024.lb3 pin assignment [docs.google.com]

Software

h8300-hms development enviroment

building log

binutils-2.16: success
gcc-3.4.4 (with newlib-1.13.0): fail
gcc-3.4.3 (with newlib-1.13.0): fail
gcc-3.3.2 (with newlib-1.13.0): success
newlib-1.13.0 (by gcc-3.3.2): fail
gcc-3.3.2 (with newlib-1.11.0): success
newlib-1.11.0 (by gcc-3.3.2): success

The summary of compilation logs in the case of success

binutils-2.16
$ tar jxvf binutils-2.16.tar.bz2
$ cd binutils-2.16
$ ./configure --target=h8300-hms 
$ make
# make install
newlib header
# cd /usr/local/src
# tar zxvf newlib-1.11.0.tar.gz
gcc-3.3.2
$ tar jxvf gcc-3.3.2.tar.bz2
$ cd gcc-3.3.2
$ mkdir work
$ cd work
$ ../configure --target=h8300-hms --with-newlib \
--with-headers=/usr/local/src/newlib-1.11.0/newlib/libc/include \
--enable-languages=c
$ make
# make install

long 32bit, int 16bit (without -mint32), short 16bit, char 8bit

newlib-1.11.0
$ tar zxvf newlib-1.11.0.tar.gz
$ cd newlib-1.11.0
$ mkdir work
$ cd work
$ ../configure --target=h8300-hms
$ make
# make install
Writer

Open SH/H8 writer [mes.sourceforge.jp]

Monitor

"Transistor Gijutsu" April 2004 CD-ROM: TR0404SP/support/ Hew/hterm_monitor/monitor/Release/monitor.mot

H8/3694 Series Normal Mode Monitor Ver. 2.0A
Copyright (C) 2003 Renesas Technology Corp.
: ?
    Monitor Vector 0000 - 003F
    Monitor ROM    0100 - 4B09
    Monitor RAM    F780 - F83F
    User    Vector F840 - F87F

Terminal: hterm [Renesas.com] , hterm.c

Sampling

calibration_02.tar.bz2 Moved to the Subversion repository.

3664.mon.x: linker script for the above monitor 3664.rom.x: linker script for rom program 3694S.h Makefile adc.[ch]: ADC driver cal.[ch]: main routine for calibration (dumping out through SCI) crt0.S: start up routine i2c.[ch]: I2C driver sample.c: main routine to store data into EEPROM sci.[ch]: SCI driver
IO.PMR1.BIT.TXD = 1; /* Set P22 to TXD function **/
log/*: calibration data
$ make

Plotting graph from sampling raw data:

$ ./genplot.pl data.log (generates data.log.dat and data.log.plt from RS232C log file)
$ gnuplot data.log.plt (generates data.log.png)
$ qiv data.log.png

First sampling raw data: togawa.log.png, okazaki.log.png, long.log.png, 0613.log.png

Calibration

Calibration method: 3d.pdf

Calibration data:
xp.log, xp.log.png, x-.log, x-.log.png yp.log, yp.log.png, y-.log, y-.log.png zp.log, zp.log.png, z-.log, z-.log.png
Average:
$ ./ave.pl data.log (calculates the averages from log file: *.log)

ave.xls (includes the following table and graphs)

Results
Offset:
$ vi offset.pl (edit offset values and scales for each axis)
$ ./offset.pl data.log
$ gnuplot data.log.offset.plt
$ qiv data.log.offset.png
Sampling rate: 0.5 sec (cal.c: TA.TMA.BYTE = 0x99;)
20050804.log (raw data) 20050804.log.png (raw data graph) 20050804.log.offset.png (raw - offset and bezier curve for each axis) 20050804.log.offset.3d.png (raw - offset 3D) According this result, it is considered that the sampling rate (0.5 sec) is too long.
Sampling rate: 0.03125 sec (cal.c: TA.TMA.BYTE = 0x9b;)
20050806.log (raw data) 20050806.log.png (raw data graph) 20050806.log.offset.png (raw - offset and bezier curve moving average for each axis) 20050806.log.offset.3d.png (3D: raw - offset moving average)
gnuplot> set xrange [-1.5:1.5]                                       
gnuplot> set yrange [-1.5:1.5]                                       
gnuplot> set zrange [-1.5:1.5] 
gnuplot> set terminal x11
gnuplot> splot "20050806.log.offset.dat" using 5:6:7 w l
(column 5:6:7 is moving averages.)
(If you rotate the graph with a mouse,
it is found that the noise signal may have another axis?!)
gnuplot> set terminal png
gnuplot> set output "20050806.log.offset.3d.png"
gnuplot> replot
ag0205.swf presented by YOKOBORI Masayuki (miyabi at uranus.interq.or.jp)

Staff

  • TOGAWA Satoshi
    s-togawa at tkd.att.ne.jp
  • OKAZAKI Atsuya