Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| pmod:pmodcmps2:reference-manual [2022/09/13 17:27] – changed forum.digilentinc.com to forum.digilent.com jeff.greenberg_ni.com | pmod:pmodcmps2:reference-manual [2022/10/04 11:38] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Pmod CMPS2 Reference Manual ====== | ||
| + | The Digilent Pmod CMPS2 (Revision A) is a 3-axis anisotropic magneto-resistive sensor. With [[http:// | ||
| + | |||
| + | {{Digilent Image Gallery | ||
| + | | image = {{: | ||
| + | | image = {{: | ||
| + | | image = {{: | ||
| + | | image = {{: | ||
| + | | image = {{: | ||
| + | }} | ||
| + | |||
| + | |||
| + | == Download This Reference Manual == | ||
| + | * {{ : | ||
| + | |||
| + | ---- | ||
| + | |||
| + | ====== Features ====== | ||
| + | * Low noise 3-axis Digital Compass | ||
| + | * 0.5 mG Field Resolution in ±16 Gauss fields | ||
| + | * I²C Slave, FAST (≤400 kHz) mode | ||
| + | * Optional pull-up resistors for SCL and SDA pins | ||
| + | * ±1° heading accuracy | ||
| + | * Small PCB size for flexible designs 0.8" × 1.25" (2.0 cm × 3.2 cm) | ||
| + | * 6-pin Pmod connector with I²C serial interface | ||
| + | * Pass-through Pmod host port for daisy chaining | ||
| + | * Follows Digilent {{/ | ||
| + | * Library and example code in the Pmod CMPS2 [[pmod: | ||
| + | |||
| + | |||
| + | ====== Specifications ====== | ||
| + | ^ Parameter | ||
| + | | Power Supply Voltage | ||
| + | | Output Resolution | ||
| + | | Alignment Error | -3 | ±1 | +3 | degrees | ||
| + | ^ Parameter | ||
| + | | Total RMS Noise | 16 bits at 7.92 ms/S | 1.5 || mG | | ||
| + | | Total RMS Noise | 16 bits at 4.08 ms/S | 2.0 || mG | | ||
| + | | Total RMS Noise | 14 bits at 2.16 ms/S | 4.0 || mG | | ||
| + | | Total RMS Noise | 12 bits at 1.20 ms/S | 6.0 || mG | | ||
| + | | Max Output Data Rate | 16 bits at 7.92 ms/S | 125 || Hz | | ||
| + | | Max Output Data Rate | 16 bits at 4.08/ | ||
| + | | Max Output Data Rate | 14 bits at 2.16 ms/S | 450 || Hz | | ||
| + | | Max Output Data Rate | 12 bits at 1.20 ms/S | 800 || Hz | | ||
| + | ^ Parameter | ||
| + | | Field Range for Each Axis | ±16 ||| G | | ||
| + | |||
| + | ---- | ||
| + | |||
| + | |||
| + | ===== Pinout Table Diagram ===== | ||
| + | |||
| + | ^ Header J1 | ||
| + | ^ Pin ^ Signal | ||
| + | | 1 | N/C | Not Connected | ||
| + | | 2 | N/C | Not Connected | ||
| + | | 3 | SCL | Serial Clock | 3 | SCL | Serial Clock | SDA | ||
| + | | 4 | SDA | Serial Data | 4 | SDA | Serial Data | ||
| + | | 5 | GND | Power Supply Ground | ||
| + | | 6 | VCC | Power Supply (3.3V) | ||
| + | |||
| + | ===== Physical Dimensions ===== | ||
| + | |||
| + | The pins on the pin header are spaced 100 mil apart. The PCB is 1.25 inches long on the sides parallel to the pins on the pin header and 0.8 inches long on the sides perpendicular to the pin header. | ||
| + | ---- | ||
| + | |||
| + | ====== Functional Description ====== | ||
| + | The Pmod CMPS2 utilizes the MMC34160PJ to collect magnetic field data. While communicating with the host board via the [[pmod: | ||
| + | |||
| + | ===== Serial Communication ===== | ||
| + | |||
| + | The Pmod CMPS2 communicates with the host board via the [[learn/ | ||
| + | |||
| + | |||
| + | ===== Register Details ===== | ||
| + | |||
| + | ==== Data Registers ==== | ||
| + | |||
| + | Each Cartesian axis has two registers to store the high and low data bytes for each measurement. The data registers are arranged in a low byte, high byte arrangement. | ||
| + | |||
| + | ^ Data Registers addresses 0x00 to 0x05 || | ||
| + | ^ Address | ||
| + | | 0x00 | X out LSB | | ||
| + | | 0x01 | X out MSB | | ||
| + | | 0x02 | Y out LSB | | ||
| + | | 0x03 | Y out MSB | | ||
| + | | 0x04 | Z out LSB | | ||
| + | | 0x05 | Z out MSB | | ||
| + | |||
| + | |||
| + | ==== Status Register ==== | ||
| + | |||
| + | ^Bit Name ^Bit Number | ||
| + | |RSV |[7] |Reserved | ||
| + | |RSV |[6] |Reserved | ||
| + | |RSV |[5] |Reserved | ||
| + | |RSV |[4] |Reserved | ||
| + | |ST_XYZ_OK | ||
| + | |Rd_Done | ||
| + | |Pump On |[1] |Pump On |0¹ |This bit indicates the status of the charge pump. | | ||
| + | |RSV |[0] |Meas Done |0¹ |Indicates that a measurement event is completed. | | ||
| + | |||
| + | |||
| + | ==== Internal Control Registers ==== | ||
| + | |||
| + | ^ Internal Control 0 ^^^^^ ^ Internal Control 1 ^^^^^ | ||
| + | ^Bit Name ^Bit Number | ||
| + | |Refill Cap |[7] |Refill Cap |0¹ |Setting this bit will recharge the\\ capacitor at the CAP pin, it is\\ requested to be issued before the SET/RESET command |::: | ||
| + | |RST |[6] |Reset Sensor | ||
| + | |SET |[5] |Set Sensor | ||
| + | |No Boost |[4] |No boost |0¹ |Disable the charge pump |::: | ||
| + | |CM Freq1² | ||
| + | |CM Freq0² | ||
| + | |Cont Mode On |[1] |Continuous Measurement Mode |0¹ |Setting this bit enables Continuous Measurement Mode |::: | ||
| + | |TM |[0] |Take Measurement | ||
| + | |||
| + | Notes:\\ | ||
| + | ¹ - This is the value on power-up and reset\\ | ||
| + | ² - For more details see the [[pmod: | ||
| + | ³ - For more details see the [[pmod: | ||
| + | |||
| + | === Continuous Measurement Mode === | ||
| + | |||
| + | ^ Continuous Measurement Mode Settings | ||
| + | ^ CM Freq1 ^ CM Freq0 ^ Frequency | ||
| + | | 0 | 0 | 1.5 Hz | | ||
| + | | 0 | 1 | 13 Hz | | ||
| + | | 1 | 0 | 25 Hz | | ||
| + | | 1 | 1 | 50 Hz | | ||
| + | |||
| + | === Output Resolution and Measurement Time === | ||
| + | |||
| + | ^ Bandwidth Output Resolution and Measurement Time ^^^^ | ||
| + | ^ BW1 ^ BW0 ^ Output Resolution | ||
| + | | 0 | 0 | 16 bits | 7.92 mS | | ||
| + | | 0 | 1 | 16 bits | 4.08 mS | | ||
| + | | 1 | 0 | 14 bits | 2.16 mS | | ||
| + | | 1 | 1 | 12 bits | 1.20 mS | | ||
| + | |||
| + | |||
| + | ===== Quick Start ===== | ||
| + | |||
| + | Here is the series of commands to acquire a set of magnetometer data from the Pmod CMPS2 via pseudo I²C code. | ||
| + | |||
| + | - Power on the Pmod CMPS2 and wait for 10 mS before further operation. | ||
| + | - Provide a START condition and call the device ID with a write bit< | ||
| + | - Wait to receive an ACK from the Pmod CMPS2. | ||
| + | - Send the Internal Control Register 0 (address 0x07) as the register to communicate with< | ||
| + | - Wait to receive an ACK from the Pmod CMPS2. | ||
| + | - Write the command to take a measurement by setting bit 0 high followed by a STOP bit. < | ||
| + | - Delay at least 7.92 mS by default to allow the Pmod CMPS2 to finish collecting data. | ||
| + | - Provide a START condition and call the device ID with a write bit< | ||
| + | - Wait to receive an ACK from the Pmod CMPS2. | ||
| + | - Send the Status Register (0x03) as the register to read < | ||
| + | - Provide a START condition and call the device ID with a read bit< | ||
| + | - Wait to receive an ACK from the Pmod CMPS2. | ||
| + | - Cycle the SCL line to receive the Status Register data on the SDA line. Keep reading the Status Register by repeating steps 8 through 13 until bit 0 is set to ' | ||
| + | - Provide a START condition and call the device ID with a write bit< | ||
| + | - Wait to receive an ACK from the Pmod CMPS2. | ||
| + | - Send the first register address corresponding to Xout LSB (0x00) as the register to be read. < | ||
| + | - Provide a START condition and call the device ID with a read bit< | ||
| + | - Wait to receive an ACK from the Pmod CMPS2. | ||
| + | - Cycle the SCL line to receive the data bits from the X, Y, and Z registers in the SDA line, providing an ACK between each data byte. The Pmod CMPS2 address pointer automatically moves to each consecutive byte. End the communication by sending a NACK followed by a STOP command. < | ||
| + | - Convert the readings into usable data. More details are available in the Data Conversion section. | ||
| + | - Wait 1/3 of the acquisition time (by default 2.64 ms) before performing another measurement. | ||
| + | |||
| + | |||
| + | |||
| + | ===== Applications Information ===== | ||
| + | The %%Pmod CMPS2%% is an ideal Pmod to use as a compass. Like all compasses, it is recommended that the Pmod CMPS2 is calibrated before using the module. | ||
| + | |||
| + | ==== Calibration ==== | ||
| + | |||
| + | To calibrate the magnetometer, | ||
| + | |||
| + | The internal offset can be calculated and accounted for through the following method: | ||
| + | |||
| + | --> Reveal the Method# | ||
| + | - Power on the Pmod CMPS2 and wait for 10 mS before further operation. | ||
| + | - Provide a START condition and call the device ID with a write bit< | ||
| + | - Wait to receive an ACK from the Pmod CMPS2. | ||
| + | - Send the Internal Control Register 0 (address 0x07) as the register to communicate with< | ||
| + | - Wait to receive an ACK from the Pmod CMPS2. | ||
| + | - Write the command to recharge the capacitor to prepare for the SET action. < | ||
| + | - Wait to receive an ACK from the Pmod CMPS2. | ||
| + | - Delay at least 50 mS to allow the Pmod CMPS2 to finish preparing. | ||
| + | - Provide a START condition and call the device ID with a write bit< | ||
| + | - Wait to receive an ACK from the Pmod CMPS2. | ||
| + | - Send the Internal Control Register 0 (address 0x07) as the register to communicate with< | ||
| + | - Wait to receive an ACK from the Pmod CMPS2. | ||
| + | - Write the command to start a SET action. < | ||
| + | - Wait to receive an ACK from the Pmod CMPS2. | ||
| + | - Delay at least 1 mS to allow the Pmod CMPS2 to finish the SET action. | ||
| + | - Provide a START condition and call the device ID with a write bit< | ||
| + | - Wait to receive an ACK from the Pmod CMPS2. | ||
| + | - Send the Internal Control Register 0 (address 0x07) as the register to communicate with< | ||
| + | - Wait to receive an ACK from the Pmod CMPS2. | ||
| + | - Write the command to take a measurement by setting bit 0 high followed by a STOP bit. < | ||
| + | - Delay at least 7.92 mS by default to allow the Pmod CMPS2 to finish collecting data. | ||
| + | - Provide a START condition and call the device ID with a write bit< | ||
| + | - Wait to receive an ACK from the Pmod CMPS2. | ||
| + | - Send the Status Register (0x03) as the register to read < | ||
| + | - Provide a START condition and call the device ID with a read bit< | ||
| + | - Wait to receive an ACK from the Pmod CMPS2. | ||
| + | - Cycle the SCL line to receive the Status Register data on the SDA line. Keep reading the Status Register by repeating steps 8 through 13 until bit 0 is set to ' | ||
| + | - Provide a START condition and call the device ID with a write bit< | ||
| + | - Wait to receive an ACK from the Pmod CMPS2. | ||
| + | - Send the first register address corresponding to Xout LSB (0x00) as the register to be read. < | ||
| + | - Provide a START condition and call the device ID with a read bit< | ||
| + | - Wait to receive an ACK from the Pmod CMPS2. | ||
| + | - Cycle the SCL line to receive the data bits from the X, Y, and Z registers in the SDA line, providing an ACK between each data byte. The Pmod CMPS2 address pointer automatically moves to each consecutive byte. End the communication by sending a NACK followed by a STOP command. < | ||
| + | - Each of the readings will contain the external magnetic field //H// in addition to offset associated with the current put through the coil by the SET action. \\ $Output1 = +H + Offset$\\ | ||
| + | - Now a RESET action will be performed to reverse the magnetization for the sensing resistors to get the inverse offset value. | ||
| + | - Provide a START condition and call the device ID with a write bit< | ||
| + | - Wait to receive an ACK from the Pmod CMPS2. | ||
| + | - Send the Internal Control Register 0 (address 0x07) as the register to communicate with< | ||
| + | - Wait to receive an ACK from the Pmod CMPS2. | ||
| + | - Write the command to recharge the capacitor to prepare for the RESET action. < | ||
| + | - Wait to receive an ACK from the Pmod CMPS2. | ||
| + | - Delay at least 50 mS to allow the Pmod CMPS2 to finish preparing. | ||
| + | - Provide a START condition and call the device ID with a write bit< | ||
| + | - Wait to receive an ACK from the Pmod CMPS2. | ||
| + | - Send the Internal Control Register 0 (address 0x07) as the register to communicate with< | ||
| + | - Wait to receive an ACK from the Pmod CMPS2. | ||
| + | - Write the command to start a RESET action. < | ||
| + | - Wait to receive an ACK from the Pmod CMPS2. | ||
| + | - Delay at least 1 mS to allow the Pmod CMPS2 to finish the SET action. | ||
| + | - Provide a START condition and call the device ID with a write bit< | ||
| + | - Wait to receive an ACK from the Pmod CMPS2. | ||
| + | - Send the Internal Control Register 0 (address 0x07) as the register to communicate with< | ||
| + | - Wait to receive an ACK from the Pmod CMPS2. | ||
| + | - Write the command to take a measurement by setting bit 0 high followed by a STOP bit. < | ||
| + | - Delay at least 7.92 mS by default to allow the Pmod CMPS2 to finish collecting data. | ||
| + | - Provide a START condition and call the device ID with a write bit< | ||
| + | - Wait to receive an ACK from the Pmod CMPS2. | ||
| + | - Send the Status Register (0x03) as the register to read < | ||
| + | - Provide a START condition and call the device ID with a read bit< | ||
| + | - Wait to receive an ACK from the Pmod CMPS2. | ||
| + | - Cycle the SCL line to receive the Status Register data on the SDA line. Keep reading the Status Register by repeating steps 8 through 13 until bit 0 is set to ' | ||
| + | - Provide a START condition and call the device ID with a write bit< | ||
| + | - Wait to receive an ACK from the Pmod CMPS2. | ||
| + | - Send the first register address corresponding to Xout LSB (0x00) as the register to be read. < | ||
| + | - Provide a START condition and call the device ID with a read bit< | ||
| + | - Wait to receive an ACK from the Pmod CMPS2. | ||
| + | - Cycle the SCL line to receive the data bits from the X, Y, and Z registers in the SDA line, providing an ACK between each data byte. The Pmod CMPS2 address pointer automatically moves to each consecutive byte. End the communication by sending a NACK followed by a STOP command. < | ||
| + | - Each of the readings will contain the external magnetic field //H// in addition to offset associated with the current put through the coil by the RESET action. \\ $Output2 = -H + Offset$\\ | ||
| + | - The offset associated with the device can be calculated and then subtracted from future measurements to obtain the actual magnetic field.\\ $Offset = \dfrac{Output1 + Output2}{2}$ | ||
| + | |||
| + | <-- | ||
| + | |||
| + | The other method of calibration is to remove the hard iron bias introduced to the magnetometer by the surrounding environment by measuring (either continually or for a set time) all of the possible magnetometer readings in a Cartesian sphere and keep track of the highest and lowest readings for each axis. The offset can then be calculated in the same fashion as described above with the SET and RESET actions. The advantage of this method is when the Pmod CMPS2 is continually changing locations or when other external magnetic fields may be introduced into the test environment. | ||
| + | |||
| + | ==== Data Conversion ==== | ||
| + | The Memsic MMC34160PJ provides data for each axis in units of Gauss, but the information is generally more legible when presented as a compass heading. The method for converting Gauss units to a compass heading is provided below. | ||
| + | |||
| + | --> | ||
| + | - Calculate the real Gauss value for the X and Y axes from the amount of LSBs returned where the LSB value by default is 0.48828125 mG, resulting in 2048 LSBs per Gauss.\\ $xGaussData = xDataLSB * 0.48828125\ mG$\\ $yGaussData = yDataLSB * 0.48828125\ mG$\\ | ||
| + | - Calculate the direction //D// by first checking to see if the X Gauss data is equal to 0 to prevent divide by 0 zero errors in the future calculations. If the X Gauss data is 0, check to see if the Y Gauss data is less than 0. If Y is less than 0 Gauss, the direction D is 90 degrees; if Y is greater than or equal to 0 Gauss, the direction D is 0 degrees. | ||
| + | - If the X Gauss data is not zero, calculate the arctangent of the Y Gauss and X Gauss data and convert from polar coordinates to degrees.\\ $D = arctan\left({\dfrac{yGaussData}{xGaussData}}\right)*\dfrac{180}{\pi}$\\ | ||
| + | - If the direction D is greater than 360 degrees, subtract 360 degrees from that value. | ||
| + | - If the direction D is less than 0 degrees, add 360 degrees to that value. | ||
| + | - The compass heading can then be determined by the direction value D: | ||
| + | * If D is greater than 337.25 degrees or less than 22.5 degrees -- North | ||
| + | * If D is between 292.5 degrees and 337.25 degrees -- North-West | ||
| + | * If D is between 247.5 degrees and 292.5 degrees -- West | ||
| + | * If D is between 202.5 degrees and 247.5 degrees -- South-West | ||
| + | * If D is between 157.5 degrees and 202.5 degrees -- South | ||
| + | * If D is between 112.5 degrees and 157.5 degrees -- South-East | ||
| + | * If D is between 67.5 degrees and 112.5 degrees -- East | ||
| + | * If D is between 0 degrees and 67.5 degrees -- North-East | ||
| + | <-- | ||
| + | |||
| + | |||
| + | ==== Timing Diagrams ==== | ||
| + | An example timing diagram for reading and writing to the Pmod CMPS2 taken from the Memsic datasheet is provided below: | ||
| + | |||
| + | {{ : | ||
| + | |||
| + | When using an external power supply to run the Pmod, be sure to stay within the parameters provided in [[pmod: | ||
| + | |||
| + | ---- | ||
| + | |||
| + | ====== Additional Information ====== | ||
| + | |||
| + | The schematics of the %%Pmod CMPS2%% are available {{reference: | ||
| + | |||
| + | Example code demonstrating how to get information from the %%Pmod CMPS2%% can be found on its Resource Center [[pmod: | ||
| + | |||
| + | If you have any questions or comments about the %%Pmod CMPS2%%, feel free to post them under the appropriate section (" | ||
| + | |||
| + | |||
| + | {{tag> | ||

