top of page
Adiuvo Engineering & Training logo
MicroZed Chronicles icon

MicroZed Chronicles: Cmod S7 & RTL Env Sensing

  • 6 hours ago
  • 4 min read

Sometimes I like to just sit and write RTL and try to create a simple project. Recently, I have been doing a lot of flying again. If you see me on a flight, you can be sure you are in for a turbulent experience, as it seems every flight I take is bumpy (sorry!).



For a long while, I have been meaning to run a small experiment and create a compact, portable logging system which records acceleration, rotation, pressure, and temperature.

I decided that I could do this using a small Digilent Cmod S7 and a PmodNAV. I wanted this solution to be RTL-based and not use a microprocessor. It is a classic FPGA RTL application: read sensors over SPI, form a packet, and send it out over a USB UART to a laptop for plotting using Python.


The PmodNAV uses two different devices. One provides a gyroscope, accelerometer, and magnetometer, while the second provides pressure and temperature measurements.


The goal of this design is to create a solution which implements in a small number of resources. This will allow me to add similar capabilities to a wide range of designs with comparable sensors attached for health and usage monitoring.


We are going to use an SPI master module which implements an SPI master interface. This SPI master is included within a sensor controller, which uses the SPI master to initialise the sensors over SPI, driving the three chip selects as required. Once configured, the sensor controller reads data from the sensors.



This data includes accelerometer X, Y, Z; gyroscope X, Y, Z; magnetometer X, Y, Z; pressure; and temperature. Each of these is output as a 16-bit register from the sensor controller, with the exception of pressure, which is a 24-bit result.



The packets are output via a simple packet formatter, which cycles through the values presented by the sensor controller.



This connects to a simple UART module, which outputs the samples at the desired line rate. To enable a Python application to locate the data stream, the first thing transmitted is a header.



The overall architecture looks as shown below.



To ensure the design was correctly initialising the SPI sensors and operating as expected, I wrote a simulation to verify the intended behaviour.



Timing-wise, I designed the application to run at 921,600 baud for transmission. As we are sending 10 bits over the UART, we can transmit 92,160 bytes per second. Each frame we send consists of 24 bytes. This includes a header and 23 data bytes containing the captured information.


As we are sampling at 100 Hz (defined in the package and controlled by a timer at the top level), we are sending 2,400 bytes per second, which equates to only 2.6% of the link’s capacity.


To display the data from the Cmod S7, I created a Python script which displays the four different types of data. The script also logs the data to a CSV file to maintain a long-term record.



I think a nice addition would be to store the data in a buffer within the non-volatile configuration memory. This could use the unused space in the configuration memory, as the device bitstream is small and can be compressed. This would allow sensor data to be stored on the device with no need for an external connection until the data needs to be accessed.


This was a fun project to create. All of the source files are available on GitHub, so please feel free to download them and experiment!


FPGA Conference

FPGA Horizons US East - April 28th, 29th 2026 - THE FPGA Conference, find out more and get Tickets here.


FPGA Journal

Read about cutting edge FPGA developments, in the FPGA Horizons Journal or contribute an article.


Workshops and Webinars:

If you enjoyed the blog why not take a look at the free webinars, workshops and training courses we have created over the years. Highlights include:



Boards

Get an Adiuvo development board:

  • Adiuvo Embedded System Development board - Embedded System Development Board

  • Adiuvo Embedded System Tile - Low Risk way to add a FPGA to your design.

  • SpaceWire CODEC - SpaceWire CODEC, digital download, AXIS Interfaces

  • SpaceWire RMAP Initiator - SpaceWire RMAP Initiator,  digital download, AXIS & AXI4 Interfaces

  • SpaceWire RMAP Target - SpaceWire Target, digital download, AXI4 and AXIS Interfaces

  • Other Adiuvo Boards & Projects.


Embedded System Book   

Do you want to know more about designing embedded systems from scratch? Check out our book on creating embedded systems. This book will walk you through all the stages of requirements, architecture, component selection, schematics, layout, and FPGA / software design. We designed and manufactured the board at the heart of the book! The schematics and layout are available in Altium here.  Learn more about the board (see previous blogs on Bring up, DDR validation, USB, Sensors) and view the schematics here.


Sponsored by AMD

bottom of page