Overview
========

The DI/OT Monitoring Module (MoniMod) is a monitoring module developed
for the DI/OT project's [#DIOT]_ power supply and (optional) fan tray,
and based on the ATSAMD21G18 Cortex-M0+ uC [#SAMD21]_. It can monitor
voltage and current consumption for up to three power rails, host up
to three temperature sensors, and control up to three fans without
requiring them to support PWM. The module is accessed and managed
through a PMBus interface. A picture of the first prototype can be
seen at :numref:`monimod_proto_img`. It will be qualified against
radiation effects, up to a total dose of 500 Gy.


Repository Structure
--------------------

The project's repository [#REPO]_ is intended to be as complete as
possible, containing both the PCB design and the uC firmware source.

The MoniMod PCB design can be found in the ``monimod-pcb`` directory.
The firmware sources are currently split in three separate programs:

1. The main FW, that implements most functionality. This lives in
   the ``main_fw`` directory.
2. The bootloader, that implements remote programming. That lives in
   the ``bootloader`` directory.
3. The simple I2C master written to help develop the main FW can be
   found in the ``test_master`` directory.

Beside these three program directories, there is a ``common``
directory that hosts shared code, and a ``utils`` directory that is
used to host any general development utilities. There is also a
``build`` directory which hosts a very simple top-level makefile; this
simply builds all FW binaries and gathers them in one place.

Each program project has an ``atmel_start_prj`` subdirectory: this is
a testament to the use of the Atmel START tool [#START]_ to generate
drivers, linker scripts and makefiles. The structure of the generated
files has been slightly altered, with our code located in the ``src``,
``include`` and ``build`` subdirectories, outside of
``atmel_start_prj``.


Feature Checklist
-----------------

The following features have been implemented:

* Option to use USB as a terminal to print debug messages and possibly
  interact with the program
* Implement the PMBus command subset for voltage, current and
  temperature monitoring (by means of a `LM61
  <http://www.ti.com/lit/ds/symlink/lm61.pdf>`_ sensor)
* Implement the PMBus command subset for fan control and monitoring
* Support Packet Error Checking (PEC) for robustness (as described in
  the SMBus specification [#SMBUS_SPEC]_)
* PID fan control
* Versatile temperature control, configured using manufacturer specific
  PMBus commands
* Per-command callback support on command writes and reads
* Support for reset over manufacturer specific PMBus command
* Bootloader support for remote reprogramming over manufacturer specific
  PMBus commands
* Radiation mitigation measures


.. [#DIOT] DI/OT project home: `<https://www.ohwr.org/project/diot/wikis/home>`_

.. [#SAMD21] ATSAMD21 product page: `<https://www.microchip.com/wwwproducts/en/ATsamd21g18>`_

.. [#REPO] MoniMod repository: `<https://www.ohwr.org/project/diot-monimod>`_

.. [#START] ATMEL START: `<https://start.atmel.com>`_

.. [#PMBUS_SPEC] The PMBus 1.0 specification, part II: `<http://pmbus.org/Assets/PDFS/Public/PMBus_Specification_Part_II_Rev_1_0_20050328.pdf>`_

.. [#SMBUS_SPEC] The SMBus 2.0 specification: `<http://smbus.org/specs/smbus20.pdf>`_
