Pmod_GYRO™ Digilent Reference Manual: Overview The PmodGYRO is a peripheral module featuring the STMicroelectronics® L3G4200D MEMS motion sensor. The L3G4200D provides a three-axis digital output gyroscope with built in temperature sensor. Features include: • • • • •

Standard SPI and I2C™ interface 250/500/2000dps Selectable Resolutions Two customizable interrupt pins Power-down and Sleep Mode User configurable signal filtering

Pmod VHDL Demo Code: The project uses the SPI interface to communicate with the PmodGYRO using the JA interface. The device pin-out, defined on the schematic, is shown below. The INT1 (M10, *IO_L22P) and INT2 (N9, *IO_L22N ) are interrupt pins from the L3G4200D to the Xilinx, but are not currently connected in

the design.

The project demo design first configures the PmodGYRO, and then begins to sample temperature and axis data at 100Hz. The user uses switches on the Nexys3 to select which data they want to display on the seven segment display. The selected data is continuously sampled and displayed on the seven segment display (SSD) when active. While the data is continuously sampled, the display can only show one value at a time.

Pmod Xilinx Design:

Pmod Demo Control/Switch Definitions: There are five switches used on this project, SW[4:0]. The switch operations are defined in the following table. Switch

Function

SW0

Reset

SW1

Start

SW2

Display Select LSB

SW3

Display Select MSB

SW4

1=Decimal, 0=Hex (except for temp)

The display is controlled by SW[3:2] and uses the table from the demo application note, copied below.

Depending on the orientation you are holding the Nexys3 and Pmod (the Pmod edge is “forward”), the axis may be described as: x-axis:

roll

positive when lowering the board right side

y-axis:

pitch

positive tilting the Pmod up

z-axis:

yaw

positive rotating the board/Pmod counter clockwise

Note that the Gyro is in terms of angular velocity. Therefore, the output only registers values while being moved. For angular position, an integrator with an output scaling would be required. Zero-bias offset may be required. Observe the temperature error and the LSB dithering when the board/Pmod is lying undisturbed on the table.

Pmod Demo Display Controller

This is very nicely done. You may want to consider this design for other projects.

Gyro IC, The STMicroelectronics L3G4200D MEMS motion sensor: ultra-stable three-axis digital output gyroscope Features • Three selectable full scales (250/500/2000 dps) • I2C/SPI digital output interface • 16 bit-rate value data output • 8-bit temperature data output • Two digital output lines (interrupt and data ready) • Integrated low- and high-pass filters with userselectable bandwidth • Ultra-stable over temperature and time • Wide supply voltage: 2.4 V to 3.6 V • Low voltage-compatible IOs (1.8 V) • Embedded power-down and sleep mode • Embedded temperature sensor • Embedded FIFO • High shock survivability • Extended operating temperature range (-40 °C to +85 °C) • ECOPACK® RoHS and “Green” compliant Applications • Gaming and virtual reality input devices • Motion control with MMI (man-machine interface) • GPS navigation systems • Appliances and robotics Description The L3G4200D is a low-power three-axis angular rate sensor able to provide unprecedented stability of zero rate level and sensitivity over temperature and time. It includes a sensing element and an IC interface capable of providing the measured angular rate to the external world through a digital interface (I2C/SPI). The sensing element is manufactured using a dedicated micro-machining process developed by STMicroelectronics to produce inertial sensors and actuators on silicon wafers. The IC interface is manufactured using a CMOS process that allows a high level of integration to design a dedicated circuit which is trimmed to better match the sensing element characteristics. The L3G4200D has a full scale of ±250/±500/±2000 dps and is capable of measuring rates with a user-selectable bandwidth.

Block Diagram

Pin Description and Rotational Axis

SPI Interface

Maximum clock rate 10 MHz

Filtering and Digital Registers Block Diagram

SPI Read and Write Protocol

SPI Register Definitions

Initialization and Operation -- setup control register 1 to enable x, y, and z. CTRL_REG1 (0x20) -- with read and multiple bytes not selected -- output data rate of 100 Hz -- will output 8.75 mdps/digit at 250 dps maximum constant SETUP_GYRO : std_logic_vector(15 downto 0) := X"0F20"; -- address of X_AXIS (0x28) with read and multiple bytes selected (0xC0) constant DATA_READ_BEGIN : std_logic_vector(7 downto 0) := X"E8"; -- address of TEMP (0x26) with read selected (0x80) constant TEMP_READ_BEGIN : std_logic_vector(7 downto 0) := X"A6"; CTRL_REG1 (0x20)

0x0F:

Normal mode, all axis enables, 100Hz, 12.5 Hz cutoff

CTRL_REG2 (0x21)

default:

Normal mode, HPF cutoff is 8 Hz

CTRL_REG3 (0x22)

default:

Interrupts disabled active high push-pull.

CTRL_REG4 (0x23)

default:

4-wire SPI, continuous update, LSB @ lower add. , 250 dps

CTRL_REG5 (0x24)

default:

Normal Mode Boot, FIFO disable, HPF disabled,

Xilinx Demo Code: Finite State Machine for Reading type StateTYPE is ( idle , setup , temp , run , hold , wait_ss , wait_run ); idle  setup Setup  hold or wait_ss hold  “previousState” wait_ss  wait_ss or wait_run wait_run  wait_run or temp or run or idle temp  hold or wait_ss run  hold or wait_ss Notes: Previous state is manipulated for the conditionals. Byte count drives run state selection.