Files

87 lines
3.2 KiB
Markdown
Raw Permalink Normal View History

2019-02-14 10:21:14 +08:00
# ToF ユニット {docsify-ignore-all}
2018-12-25 16:04:58 +08:00
<img src="assets/img/product_pics/unit/M5GO_Unit_tof.png" width="30%" height="30%"><img src="assets/img/product_pics/unit/unit_tof_grove_a.png" width="30%" height="30%">
***
2019-04-25 11:09:49 +08:00
:memo:**[概要](#概要)**&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:octocat:**[サンプルコード](#サンプルコード)**&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :electric_plug:**[回路図](#回路図)** &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;🛒**[購入リンク](https://www.aliexpress.com/item/M5Stack-Official-ToF-Unit-VL53L0X-Time-of-Flight-ToF-Laser-Ranging-Sensor-Breakout-Laser-Distance-Sensor/32949310300.html)**
2018-12-25 16:04:58 +08:00
## 概要
2019-04-25 11:09:49 +08:00
**<mark>ToF</mark>**ユニットは940nmのレーザー光を使って距離を測定する「Time-of-Flight」型のセンサー(VL53L0X)ユニットです。 他の測距センサーに比べて精度が高く、ミリ単位で計測可能です。(最大測定距離2メートル)データ取得時間は30ミリ秒と高速です。ポートAを利用して通信を行います。I2Cで値を取得可能で、I2Cアドレスは**0x29**です。
2018-12-25 16:04:58 +08:00
## 特徴
- 高精度
2019-04-25 11:09:49 +08:00
- 測定可能距離: 最大2m
- レーザー波長: 940nm
- GROVEポートサポート、[UIFlow](http://flow.m5stack.com)、[Arduino](http://www.arduino.cc)プログラミングサポート
2018-12-25 16:04:58 +08:00
- LEGO 互換ホール
2019-04-25 11:09:49 +08:00
## パッケージ内容
- 1x ToFユニット
- 1x Groveケーブル
2018-12-25 16:04:58 +08:00
## アプリケーション
2019-04-25 11:09:49 +08:00
- ジェスチャーコントロール
- レーザー測距
- 3D構造化光イメージング(3Dセンシング)
- カメラアシスト(超高速オートフォーカスと被写界深度マップ)
2018-12-25 16:04:58 +08:00
2019-04-25 11:09:49 +08:00
## 関連リンク
2018-12-25 16:04:58 +08:00
2019-04-25 11:09:49 +08:00
- **[公式ビデオ](https://www.youtube.com/channel/UCozgFVglWYQXbvTmGyS739w)**
2018-12-25 16:04:58 +08:00
2019-04-25 11:09:49 +08:00
- **[フォーラム](http://forum.m5stack.com/)**
- **データシート** - [VL53L0X](https://pdf1.alldatasheet.com/datasheet-pdf/view/948120/STMICROELECTRONICS/VL53L0X.html)
2018-12-25 16:04:58 +08:00
## サンプルコード
### 1. Arduino IDE
2019-04-25 11:09:49 +08:00
*完全なソースコードは[こちら](https://github.com/m5stack/M5-ProductExampleCodes/tree/master/Unit/TOF/Arduino)。*
2018-12-29 18:15:57 +08:00
```arduino
#include <M5Stack.h>
#include <Wire.h>
2019-02-26 10:46:54 +08:00
#define ToF_ADDR 0x29//the I2C address of tof
2018-12-29 18:15:57 +08:00
#define SYSRANGE_START 0x00
#define RESULT_RANGE_STATUS 0x14
2019-02-26 10:46:54 +08:00
#define ToF_ADDR 0x29 //the I2C address of ToF
2018-12-29 18:15:57 +08:00
// declaration
uint16_t dist=0;
// initialization
M5.begin();
Wire.begin();// join i2c bus (address optional for master)
// read data
write_byte_data_at(VL53L0X_REG_SYSRANGE_START, 0x01);
read_block_data_at(VL53L0X_REG_RESULT_RANGE_STATUS, 12);//read 12 bytes once
// get distance
dist = makeuint16(gbuf[11], gbuf[10]);//split distance data to variable "dist"
```
2019-02-22 15:38:20 +08:00
### 2. UIFlow
2018-12-29 18:15:57 +08:00
2019-04-25 11:09:49 +08:00
*完全なソースコードは[こちら](https://github.com/m5stack/M5-ProductExampleCodes/tree/master/Unit/TOF/UIFlow)。*
2018-12-29 18:15:57 +08:00
2019-02-22 15:38:20 +08:00
<img src="assets/img/product_pics/unit/unit_example/TOF/example_unit_tof_01.png">
2018-12-25 16:04:58 +08:00
## 回路図
<img src="assets/img/product_pics/unit/tof_sch.JPG">
2018-12-27 16:13:35 +08:00
### ピンマップ
2018-12-25 16:04:58 +08:00
<table>
2018-12-29 18:15:57 +08:00
<tr><td>M5Core(GROVEインターフェースA)</td><td>GPIO22</td><td>GPIO21</td><td>5V</td><td>GND</td></tr>
2018-12-25 16:04:58 +08:00
<tr><td>TOF Unit</td><td>SCL</td><td>SDA</td><td>5V</td><td>GND</td></tr>
</table>