CM-3G 周辺モジュール拡張技術文書 MS5607センサ(温度、気圧)

Similar documents
CM-3G 周辺モジュール拡張技術文書 INA226センサ(電流、電圧、電力)

Microsoft Word - C.....u.K...doc

£Ã¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç (2018) - Â裵²ó ¨¡ À©¸æ¹½Â¤¡§¾ò·ïʬ´ô ¨¡

II 3 yacc (2) 2005 : Yacc 0 ~nakai/ipp2 1 C main main 1 NULL NULL for 2 (a) Yacc 2 (b) 2 3 y

r07.dvi

ohp07.dvi

double float

AutoTuned-RB

卒 業 研 究 報 告.PDF

C

:30 12:00 I. I VI II. III. IV. a d V. VI

ohp03.dvi

slide5.pptx

Baud Rate 9600 Parity NONE Number of Data Bits 8 Number of Stop Bits 1 Flow Control NONE 1 RS232C 200mm 2,000mm DIMM ( ) Telescope East/West LX200 * 1

CSIDE Version6への移行について

1 $ cat aboutipa 2 IPA is a Japanese quasi-government 3 organization established in accor- 4 dance with The Law for Information 5 Processing Technolog

Minimum C Minimum C Minimum C BNF T okenseq W hite Any D

r08.dvi

1 1.1 C 2 1 double a[ ][ ]; 1 3x x3 ( ) malloc() 2 double *a[ ]; double 1 malloc() dou

橡Pro PDF

joho07-1.ppt

I. Backus-Naur BNF : N N 0 N N N N N N 0, 1 BNF N N 0 11 (parse tree) 11 (1) (2) (3) (4) II. 0(0 101)* (

ohp08.dvi

mbed_library_study_meeting_v1.0.key

£Ã¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç (2018) - Â裶²ó ¨¡ À©¸æ¹½Â¤¡§·«¤êÊÖ¤· ¨¡

44 6 MPI 4 : #LIB=-lmpich -lm 5 : LIB=-lmpi -lm 7 : mpi1: mpi1.c 8 : $(CC) -o mpi1 mpi1.c $(LIB) 9 : 10 : clean: 11 : -$(DEL) mpi1 make mpi1 1 % mpiru

Condition DAQ condition condition 2 3 XML key value

XMPによる並列化実装2

II ( ) prog8-1.c s1542h017%./prog8-1 1 => 35 Hiroshi 2 => 23 Koji 3 => 67 Satoshi 4 => 87 Junko 5 => 64 Ichiro 6 => 89 Mari 7 => 73 D

file:///D|/C言語の擬似クラス.txt

r03.dvi

NI P1200 Release Notes Cover

Microsoft Word - PCI-3346A_BSP_Release_Notes.doc

para02-2.dvi

file"a" file"b" fp = fopen("a", "r"); while(fgets(line, BUFSIZ, fp)) {... fclose(fp); fp = fopen("b", "r"); while(fgets(line, BUFSIZ, fp)) {... fclose

tuat1.dvi

comment.dvi

I. Backus-Naur BNF S + S S * S S x S +, *, x BNF S (parse tree) : * x + x x S * S x + S S S x x (1) * x x * x (2) * + x x x (3) + x * x + x x (4) * *

gengo1-12

P6dark P6dark µ-pic 2 µ-pic 2 3 µ-pic µ-pic µ-pic 3 µ-pic (10cm ) MPGC N3035-KA195 No. SN ASD (16ns[C]) (16nsC

ex01.dvi

:30 12:00 I. I VI II. III. IV. a d V. VI

‚æ4›ñ

memo

新・明解C言語 ポインタ完全攻略

A/B (2018/10/19) Ver kurino/2018/soft/soft.html A/B

1 1.1 C 2 1 double a[ ][ ]; 1 3x x3 ( ) malloc() malloc 2 #include <stdio.h> #include

PowerPoint プレゼンテーション

Original : Hello World! (0x0xbfab85e0) Copy : Hello World! (0x0x804a050) fgets mstrcpy malloc mstrcpy (main ) mstrcpy malloc free fgets stream 1 ( \n

プログラミング及び演習 第1回 講義概容・実行制御

I 2 tutimura/ I 2 p.1/??

2008 ( 13 ) C LAPACK 2008 ( 13 )C LAPACK p. 1

WinHPC ppt

1. 入力した正の整数を降順に並べ換えて出力するプログラムを作成せよ プログラムは個別にコンパイルし make コマンドで実行すること 入力データは 50 以下とし 以下の数が混在しているとする 16 進数 : 先頭 1 文字が x または X( エックスの小文字か大文字 ) 8 進数 : 先頭 1

gengo1-12

£Ã¥×¥í¥°¥é¥ß¥ó¥°(2018) - Âè11²ó – ½ÉÂꣲ¤Î²òÀ⡤±é½¬£² –

DVIOUT

( ) 1 1: 1 #include <s t d i o. h> 2 #include <GL/ g l u t. h> 3 #include <math. h> 4 #include <s t d l i b. h> 5 #include <time. h>

1) OOP 2) ( ) 3.2) printf Number3-2.cpp #include <stdio.h> class Number Number(); // ~Number(); // void setnumber(float n); float getnumber();

1 C STL(1) C C C libc C C C++ STL(Standard Template Library ) libc libc C++ C STL libc STL iostream Algorithm libc STL string vector l

第5回お試しアカウント付き並列プログラミング講習会

01-introduction.ppt

untitled

新・明解C言語 実践編

SystemC言語概論

Microsoft Word - Cプログラミング演習(12)

1.ppt

新版明解C言語 実践編

lexex.dvi

Gfarm/MPI-IOの 概要と使い方

main main Makefile Makefile C.5 Makefile Makefile Makefile A Mech (TA ) 1. Web ( iku

Nios II - PIO を使用した I2C-Bus (2ワイヤ)マスタの実装

Logical Volume Manger (LVM) の制限に関する情報

Microsoft Word - Lab5d-DB2組み込みSQL.doc

273? C

PowerPoint プレゼンテーション

ex14.dvi

/* do-while */ #include <stdio.h> #include <math.h> int main(void) double val1, val2, arith_mean, geo_mean; printf( \n ); do printf( ); scanf( %lf, &v

Prog1_6th

C ( ) C ( ) C C C C C 1 Fortran Character*72 name Integer age Real income 3 1 C mandata mandata ( ) name age income mandata ( ) mandat

gengo1-12

C B

エラー処理・分割コンパイル・コマンドライン引数

昨年度までの研究紹介 および 研究計画

1st-session key

Taro-リストⅢ(公開版).jtd

DA100データアクイジションユニット通信インタフェースユーザーズマニュアル

tutorial_lc.dvi

ex01.dvi

PowerPoint Presentation

二次元連続動的計画法による知的画像処理システム ImageFileSelector RTC 機能仕様書 ImageFileSelectorRTC Ver.1.0 ( 株 ) 東日本計算センター 1 / 11

DKA ( 1) 1 n i=1 α i c n 1 = 0 ( 1) 2 n i 1 <i 2 α i1 α i2 c n 2 = 0 ( 1) 3 n i 1 <i 2 <i 3 α i1 α i2 α i3 c n 3 = 0. ( 1) n 1 n i 1 <i 2 < <i

j x j j j + 1 l j l j = x j+1 x j, n x n x 1 = n 1 l j j=1 H j j + 1 l j l j E

第1回 プログラミング演習3 センサーアプリケーション

IP L09( Tue) : Time-stamp: Tue 14:52 JST hig TCP/IP. IP,,,. ( ) L09 IP (2017) 1 / 28

PICKIT3オフライン書き込みガイドブック

Microsoft Word - EGX100によるH663通信手引

program.dvi

Microsoft Word - iMCs03…\…t…g…E…F…A…}…j…–…A…‰_v1_1.doc

PowerPoint プレゼンテーション

Transcription:

CM-3G 周辺モジュール拡張技術文書 MS5607 センサ ( 温度 気圧 ) ( 第 1 版 ) Copyright (C)2016 株式会社コンピューテックス 目次 1. はじめに... 1 2. MS5607 について... 1 3. 接続図... 1 4. アプリケーション ソース... 2 5. アプリケーションのコンパイル方法... 7 6. アプリケーションの実行... 8

1. はじめに 本書は CM-3G 開発キットで MS5607 センサを使用するための補足マニュアルです CM-3G の拡張コネクタに接続可能なセンサを使用するための手順を記述します 2. MS5607 について MS5607 は I2C で接続可能な温度 気圧センサです 3. 接続図 MS5607 と CM-3G100 D-BOARD の接続信号表 MS5607 CM-3G100 D-BOARD SENSOR コネクタ GND GND VIN VDD SCL SCL SDA SDA CM-3G 周辺モジュール拡張技術文書 MS5607 センサ ( 温度 気圧 ) 1

4. アプリケーション ソース センサ情報を表示するアプリケーション ソースは以下の通りです /* * ms5607.c * * Copyright (C) 2012 Computex Co.,Ltd. * * Sample to test MS5607 using CM-3G CHECK BOARD */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <unistd.h> #include <fcntl.h> #include <linux/i2c-dev.h> #define I2C_DEVICE #define DEV_ADDRESS "/dev/i2c-3" 0x76 #define CMD_RESET 0x1E // ADC reset command #define CMD_ADC_READ 0x00 // ADC read command #define CMD_ADC_CONV 0x40 // ADC conversion command #define CMD_ADC_D1 0x00 // ADC D1 conversion #define CMD_ADC_D2 0x10 // ADC D2 conversion #define CMD_ADC_256 0x00 // ADC OSR=256 #define CMD_ADC_512 0x02 // ADC OSR=512 #define CMD_ADC_1024 0x04 // ADC OSR=1024 #define CMD_ADC_2048 0x06 // ADC OSR=2048 #define CMD_ADC_4096 0x08 // ADC OSR=4096 #define CMD_PROM_RD 0xA0 // Prom read command int file; void usage(char *app_name) printf("%s - Displays Temperature and Pressure values using MS5607 sensor\n", app_name); printf("usage: %s -d [device path]\n", app_name); printf("\t\t-d - i2c device path (Default: "I2C_DEVICE")\n"); printf("eg: %s\n", app_name); exit(0); int i2c_send(unsigned char cmd) unsigned char buf[1]; buf[0] = cmd; CM-3G 周辺モジュール拡張技術文書 MS5607 センサ ( 温度 気圧 ) 2

if (write(file, buf, 1)!= 1) printf("failed to write to i2c bus. Check if MS5607 is connected\n"); return 0; int i2c_recv(unsigned char *buf, int count) if (read(file, buf, 2)!= 2) printf("failed to read from to i2c bus. Check if MS5607 is connected\n"); return 0; /******************************************************* Performs ADC conversion ********************************************************/ int read_adc(char cmd, unsigned int *val) unsigned char buf[3]; /* send conversion command */ if(i2c_send(cmd_adc_conv cmd)) /* wait for conversion */ switch (cmd & 0x0f) case CMD_ADC_256: usleep(900000); case CMD_ADC_512: usleep(3000); case CMD_ADC_1024: usleep(4000); case CMD_ADC_2048: usleep(6000); case CMD_ADC_4096: usleep(10000); /* send read comand and read */ if(i2c_send(cmd_adc_read)) if(i2c_recv(buf, 3)) CM-3G 周辺モジュール拡張技術文書 MS5607 センサ ( 温度 気圧 ) 3

*val = (buf[0]<<16) (buf[1]<<8) buf[2]; return 0; /******************************************************* Reads calibration coefficients ********************************************************/ int get_coeff(unsigned int coeff_num, double *val) unsigned char buf[2]; /* send PROM READ command and read */ if(i2c_send(cmd_prom_rd + coeff_num * 2)) if(i2c_recv(buf, 2)) *val = (buf[0]<<8) buf[1]; return 0; /**************************************************************** * Main ****************************************************************/ int main(int argc, char* argv[]) unsigned char buf[10]; int d; int i; char shortoptions[] = "d:h"; char input_device[16]; float hres, hres2, lres; double coeff[8]; unsigned int D1, D2; double dt, T, P, OFF, SENS; input_device[0] = 0; for (;;) d = getopt_long(argc, argv, shortoptions, (void *)NULL, &index); if (-1 == d) switch (d) case 'd': strcpy(input_device, optarg); default: usage(argv[0]); CM-3G 周辺モジュール拡張技術文書 MS5607 センサ ( 温度 気圧 ) 4

if(input_device[0] == 0) strcpy(input_device, I2C_DEVICE); file = open(input_device, O_RDWR); if(file < 0) printf("error: "I2C_DEVICE " open failed\n"); exit(1); if(ioctl(file, I2C_SLAVE, DEV_ADDRESS) < 0) printf("error: %s setting device address to 0x%xfailed\n", input_device, DEV_ADDRESS); goto _out; /* send reset sequence */ if (i2c_send(cmd_reset)) goto _out; /* wait for the reset sequence timing */ usleep(3000); /* read coefficients */ for(i=1; i<7; i++) if(get_coeff(i, &coeff[i])) goto _out; printf("temperature Pressure\n"); while(1) if(read_adc(cmd_adc_d1 CMD_ADC_4096, &D1) read_adc(cmd_adc_d2 CMD_ADC_4096, &D2)) goto _out; dt = D2 - coeff[5] * 256; OFF = coeff[2] * 131072 + ((coeff[4] * dt) / 64); SENS = coeff[1] * 65536 + (coeff[3] * dt) / 128; T = (2000 + (dt * coeff[6]) / 8388608) / 100; P = (((D1 * SENS) / 2097152 - OFF) / 32768) /100; printf("%0.3f?c %0.3f mbar\n", T, P); sleep(1); _out: close(file); return 0; CM-3G 周辺モジュール拡張技術文書 MS5607 センサ ( 温度 気圧 ) 5

Makefile は以下の通りです # Makefile BUILDROOT_DIR:=../../../../../../ OUTPUT_DIR:=output CROSS_COMPILE:=$(BUILDROOT_DIR)/$(OUTPUT_DIR)/host/usr/bin/arm-linux- #APP_DEBUG:=-ggdb CC = $(CROSS_COMPILE)gcc $(APP_DEBUG) -I$(TSLIB_DIR) -I$(KERNEL_HEADERS) -O0 -lm APP=ms5607 LIB= -ldl -lpthread SRCS=ms5607.c all: $(SRCS) $(CC) -o $(APP) $(SRCS) $(LIB) clean: rm -f *.o *~ $(APP) CM-3G 周辺モジュール拡張技術文書 MS5607 センサ ( 温度 気圧 ) 6

5. アプリケーションのコンパイル方法 buildroot の以下のディレクトリでアプリケーションをコンパイルする手順を説明します $buildroot/board/ckb/cm-3g/samples/service-patch/ms5607 まず アプリケーションをコンパイルする作業ディレクトリを作成します LINUXPC$ mkdir -p board/ckb/cm-3g/samples/service-patch/ms5607 アプリケーション ソース (ms5607.c) と Makefile を作業ディレクトリにコピーし カレント ディレクトリを移動します LINUXPC$ cd board/ckb/cm-3g/samples/service-patch/ms5607 make を実行し ソース ファイルをコンパイルします LINUXPC$ make make が成功すると 実行ファイル (ms5607) が作成されますので microsd カードの /usr/bin に実行ファイルをコピーします LINUXPC$ sudo cp ms5607 /media/rootfs/usr/bin CM-3G 周辺モジュール拡張技術文書 MS5607 センサ ( 温度 気圧 ) 7

6. アプリケーションの実行 以下のようにアプリケーションを実行すると センサの値を取得して表示します # ms5607 アプリケーションの実行結果は以下のようになり 温度 気圧の情報を一定時間ごとに表示します アプリケーションを終了する場合は [Ctrl] + [C] を入力してください # ms5607 Temperature Pressure 23.712 1020.483 mbar 23.712 1020.483 mbar 23.712 1020.483 mbar 23.721 1020.501 mbar CM-3G 周辺モジュール拡張技術文書 MS5607 センサ ( 温度 気圧 ) 8

変更履歴 日付版内容 2016-1 1 初版

本書の内容の一部 または全部を無断で使用することや 複製することはできません 本書の内容 および仕様に関しては将来予告なしに変更することがあります 本書は万全の注意を払って生産されていますが ご利用になった結果について当社は一切の責任を負いかねますのでご了承ください COMPUTEX は ( 株 ) コンピューテックスの登録商標です その他本書で取り上げる会社名および製品名などは 一般に各メーカーの商標 または登録商標です 株式会社コンピューテックス 本社 605-0846 京都市東山区五条橋東 4-432-13 對嵐坊ビル TEL:075-551-0528( 代 ) FAX:075-551-2585 東京営業所 TEL:03-5753-9911( 代 ) FAX:03-5753-9917 テクニカルセンタ TEL:075-551-0373 FAX:075-551-2585 CM-3G 周辺モジュール拡張技術文書 MS5607 センサ ( 温度 気圧 ) 2016 年 1 月第 1 版 CX534(A)1601