Skip to content

Commit a0c053a

Browse files
mp020422-amsOSRAMptr814
authored andcommitted
Initial checkin.
0 parents  commit a0c053a

18 files changed

+6173
-0
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
*****************************************************************************
3+
* Copyright by ams OSRAM AG *
4+
* All rights are reserved. *
5+
* *
6+
* IMPORTANT - PLEASE READ CAREFULLY BEFORE COPYING, INSTALLING OR USING *
7+
* THE SOFTWARE. *
8+
* *
9+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
10+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
11+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
12+
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
13+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
14+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
15+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
16+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
17+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
18+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
19+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
20+
*****************************************************************************
21+
*/

README.md

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
# TMF8806 (Time-of-flight) Arduino Uno driver
2+
3+
This is a simple universal driver to show the capabilies of the time-of-flight device TMF8806.
4+
5+
## Requirements
6+
7+
- an Arduino Uno R3 board
8+
- an ams TMF8806 Arduino Shield Board [TMF8806_EVM_EB_SHIELD](https://ams-osram.com/search?q=tmf8806)
9+
- a USB B cable
10+
- the [Arduino IDE](https://www.arduino.cc/en/software) to compile and download the Arduino Uno example application
11+
12+
13+
## Files
14+
15+
The arduino project in the folder: **tmf8806_app** is a very simple single character command line interpreter listening/printing on UART
16+
It contains the following files:
17+
18+
- **tmf8806_app.ino** - the arduino specific wrapper for the application
19+
- **tmf8806_app.h** and **tmf8806_app.cpp** - the TMF8806 command line application
20+
- **tmf8806.h** and **tmf8806.cpp** - the TMF8806 driver
21+
- **tmf8806_shim.h** and **tmf8806_shim.cpp** - a shim to abstract the arduino specific I2C, UART and GPIO functions
22+
- **tmf8806_image.h** and **tmf8806_image.c** - the TMF8806 firmware that is downloaded by the driver as a c-struct
23+
24+
You can use application interrupt driven. For this you need to set the following define to 1: **USE_INTERRUPT_TO_TRIGGER_READ**
25+
26+
### Porting to another MCU
27+
28+
To port the driver and application to another platform you need to adapt the following files:
29+
- **tmf8806_a.ino** - the arduino specific wrapper for the application, replace this with the requirements for your selected platform
30+
- **tmf8806_shim.h** and **tmf8806_shim.cpp** - a shim to abstract the arduino specific I2C, UART and GPIO functions
31+
32+
## UART and command line interpreter
33+
34+
The project listens and talks on the UART. Baud rate is 115200, 8-bit, no parity, 1 stop bit.
35+
36+
The command line interpreter uses single characters followed by ENTER as input commands.
37+
For interfacing with a zeromq server the command line interpreter also supports complex command strings with binary payload.
38+
39+
UART commands (single character)
40+
41+
- a ... dump registers
42+
- c ... toggle configuration
43+
- d ... disable device
44+
- e ... enable device
45+
- f ... factory calibration
46+
- h ... help
47+
- i ... I2C address change
48+
- m ... start measure
49+
- p ... power down
50+
- s ... stop measure
51+
- t ... switch persistence and thresholds
52+
- w ... wakeup
53+
- x ... clock correction on/off
54+
- z ... histogram dump
55+
- + ... log level+
56+
- - ... log level-
57+
58+
UART commands (binary payload)
59+
60+
- b\x30<tmf8806FactoryCalibData data> .. set arbitrary factory calibration data
61+
- b\x31<tmf8806MeasureCmd data> .. set arbitrary configuration
62+
- b\x32<pers,loThres,hiThres> .. set arbitrary persistence / threshold
63+
64+
## Command line interpreter application
65+
66+
The command line interpreter application mimics a simple host application. It allows the user to switch between 2 pre-defined configurations:
67+
68+
- Configuration 0: Period 33 ms, KiloIterations = 400
69+
- Configuration 1: single shot mode, KiloIterations = 100
70+
71+
You can modify the configurations (e.g. choose different period or KiloIterations) in the application source file, recompile and download your own configuration application to the Arduino.
72+
73+
## Examples
74+
75+
### Power up device
76+
77+
Before the device can be used the host must power the device. The arduino uno setup function will pull the enable line to the TMF8806 low. I.e. the TMF8806 will be powered down.
78+
79+
Enter the character
80+
81+
- e
82+
83+
followed by ENTER to enable the device. If necessary the driver will automatically download the the firmware patch file to the TMF8806 RAM. The arduino uno will publish the FW version in the terminal:
84+
85+
e.g. version 192.4.11.0
86+
87+
### Power up device and do measurements
88+
89+
Type the following commands on UART:
90+
91+
- e
92+
- m
93+
94+
The header for the results looks like this:
95+
\#Obj,i2c_slave_address,result_number,reliability,measured_distance,corrected_distance,sys_clock,temperature,reference_hits,object_hits,crosstalk
96+
97+
You will see measurement result records on the UART for the default configuration.
98+
99+
\#Obj,65,165,63,295,295,735639833,27,69216,27384,829
100+
\#Obj,65,166,63,295,295,735796255,27,69243,27459,830
101+
\#Obj,65,167,63,294,294,735951813,27,69362,27297,799
102+
103+
# Factory calibration
104+
105+
Factory calibration must be done for each device.
106+
107+
The simplest way is to do a live factory calibration. I.e. do the following steps:
108+
1. Connect your Arduino Uno and tmf8806 to the PC via USB
109+
2. Start a terminal program
110+
3. Configure and connect the terminal program to the arduino uno
111+
4. Make sure you have a cover glass on top of the TMF8806. This is needed for the crosstalk.
112+
5. Make sure there is no object in front of the TMF8806 within 40 cm.
113+
6. Enter the following commands in your terminal console:
114+
- e
115+
- f
116+
7. The application reports the calibration data: e.g. #Cal,2,0,0,A,B0,BE,BD,7C,F5,F0,F3,F7,7,4
117+
8. If the application does not send the calibration data the calibration has failed. Check your cover glass and check if there is no object (within 40cm) in the field-of-view of the sensor.
118+
119+
## Crosstalk readout
120+
121+
The application reports the crosstalk with each measurement result. E.g.:
122+
123+
\#Obj,65,167,63,294,294,735951813,27,69362,27297,799
124+
125+
The crosstalk is the last field in the line.
126+
127+
## I2C slave address changing
128+
129+
Send the command "i" to the application to change the sensor I2C address. The application will report the new I2C address. E.g.: Addr=0x42
130+
131+
# Histogram dumping
132+
133+
The device can also dump histograms. The order the Arduino Uno driver reports these histograms is exactly the same as the TMF8806 reports them on I2C.
134+
135+
There are five different types of histograms available
136+
137+
- electrical calibration histograms (ID=1)
138+
- proximity histograms (ID=2)
139+
- distance histograms (ID=4)
140+
- pileup-corrected distance histograms (ID=8)
141+
- summed histogram (ID=16)
142+
143+
Type "z" and ENTER until you have the desired value for histogram dumping. E.g if the application sends:
144+
145+
Histogram is 4
146+
147+
distance histograms are configured for dumping. The application dumps ALL histograms if:
148+
149+
Histogram is 31
150+
151+
For all histograms, the first number after the marker (e.g. #TG7) will give the channel this histogram contains.
152+
153+
There are always 10 histograms reported.
154+
155+
- Number 0 == TDC0, Channel0
156+
- Number 1 == TDC0, Channel1
157+
- ...
158+
- Number 9 == TDC4, Channel0
159+
- Number 10 == TDC0, Channel1
160+
161+
The header for the raw histograms looks like this:
162+
\#<histogram_type>,bin_0,bin_1,...,bin_127
163+
164+
Line Tag | Histogram Type
165+
----------|-----------------------
166+
\#CI | electrical calibration
167+
\#PT | proximity
168+
\#TG | distance
169+
\#TGPUC | pileup-corrected distance
170+
\#SUM | summed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
srec_cat.exe -o tmf8806_image.c -C-Array tmf8806_image -INClude mainapp_PATCH_Leica_k3.hex -Intel

0 commit comments

Comments
 (0)