Skip to content

Commit f6fe742

Browse files
committed
Add cmps2 interface
1 parent c9a488d commit f6fe742

6 files changed

Lines changed: 1216 additions & 0 deletions

File tree

Pmods/CMPS2/README.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Pmod CMPS2
2+
3+
## Contents of Readme
4+
5+
1. About
6+
2. Brief information about Pmod CMPS2
7+
3. Interface Description
8+
4. Tests
9+
5. Status Information
10+
6. Issues
11+
12+
---
13+
14+
## About
15+
16+
Simple interface for the [Digilent Pmod CMPS2](https://reference.digilentinc.com/reference/pmod/pmodcmps2/start) or any other module with [MMC3416xPJ](http://www.memsic.com/uploadfiles/2020/08/20200827165224614.pdf).
17+
18+
## Brief information about Pmod TMP3
19+
20+
The [Digilent Pmod CMPS2](https://reference.digilentinc.com/reference/pmod/pmodcmps2/start) is a 3-Axis Magnetometer. It contains [Memsic's MMC3416xPJ](http://www.memsic.com/uploadfiles/2020/08/20200827165224614.pdf) 3-axis Magnetic Sensor.
21+
22+
## Interface Description
23+
24+
Module `cmps2` can be used as a simple interface for the [Pmod CMPS2](https://reference.digilentinc.com/reference/pmod/pmodcmps2/start) (or any other module with [MMC3416xPJ](http://www.memsic.com/uploadfiles/2020/08/20200827165224614.pdf)).
25+
26+
Module `cmps2` offers two measurement modes. Normal measurement (initiated with `measure`) does a set measurement and subtracts existing offsets from measurement results. Calibration measurement (initiated with `calibrate`) does a reset measurement followed by a set measurement. Using these measurement results, calibrated measurement values and new offsets are calculated. Measurement results calculated via *(set results - reset results) / 2* and offset values calculated via *(set results + reset results) / 2*.
27+
28+
**IOs:**
29+
30+
| Port | Type | Width | Description |
31+
| :------: | :----: | :----: | ------ |
32+
| `clk` | I | 1 | System Clock |
33+
| `rst` | I | 1 | System Reset |
34+
| `clkI2Cx2` | I | 1 | I²C Clock source |
35+
| `SCL` | IO | 1 | I²C Clock Pin |
36+
| `SDA` | IO | 1 | I²C Data Pin |
37+
| `x_axis` | O | 16 | Measurement result for X axis |
38+
| `y_axis` | O | 16 | Measurement result for Y axis |
39+
| `z_axis` | O | 16 | Measurement result for Z axis |
40+
| `resolution` | I | 2 | Resolution configuration of [MMC3416xPJ](http://www.memsic.com/uploadfiles/2020/08/20200827165224614.pdf) |
41+
| `x_offset` | O | 16 | Calculated offset for X axis |
42+
| `y_offset` | O | 16 | Calculated offset for Y axis |
43+
| `z_offset` | O | 16 | Calculated offset for Z axis |
44+
| `calibrate` | I | 1 | Initiate a measurement with a new calibration |
45+
| `measure` | I | 1 | Initiate a measurement with using existing calibration |
46+
| `i2cBusy` | O | 1 | Another master is using I²C bus |
47+
| `valid` | O | 1 | New measurement results ready and valid |
48+
49+
I: Input O: Output
50+
51+
**Note:** Maximum frequency of `clkI2Cx2` is 800 kHz, `SCL` will have half of this frequency.
52+
53+
**Timing:**
54+
55+
Time takes from initiation of new measurement and obtaining valid measurement results for diffent cases can be found at the table below.
56+
57+
| `resolution` | `calibrate` | `measure` |
58+
|:---:|:---:|:---:|
59+
| 2'b00 (16 bit)|15,98 ms|7,743ma|
60+
| 2'b01 (16 bit)|8,927 ms|4,217 ms|
61+
| 2'b10 (14 bit)|5,298 ms|2,402 ms|
62+
| 2'b11 (12 bit)|3,485 ms|1,495 ms|
63+
64+
**(Synthesized) Utilization on Artix-7:**
65+
66+
* Slice LUTs: 234 (as Logic)
67+
* Slice Registers: 251 (as Flip Flop)
68+
69+
## Test
70+
71+
The [CMPS2](https://reference.digilentinc.com/reference/pmod/pmodcmps2/start) interface module tested with test module [tester_cmps2.v](Test/tester_cmps2.v) and constrains [Basys3.xdc](Test/Basys3.xdc). I²C pins are monitored via [DDiscovery](https://reference.digilentinc.com/reference/instrumentation/digital-discovery/start). Right button connected to `calibrate`, left button connected to `measure`. Two right most switches are connected to `resolution`. Seven segment display is used to display `x_axis`, `y_axis` and `z_axis`; controled via two left most switches. Output values are also send via UART on positive edge of `valid`. They are send in following order: `x_axis`, `y_axis`, `z_axis`, `x_offset`, `y_offset`, `z_offset`. UART configurations are 115200, 8 bits with no parity and 1 bit stop.
72+
73+
## Status Information
74+
75+
**Last test:** 17 June 2021, on [Digilent Basys 3](https://reference.digilentinc.com/reference/programmable-logic/basys-3/reference-manual).
76+
77+
## Issues
78+
79+
* For some measurements, least significant bit of the result is wrong, resulting 0.5mG error.

0 commit comments

Comments
 (0)