Prototyping The Future: Building A “Star Trek” Tricorder
Michael Parks, P.E. for Mouser Electronics
Licensed under CC BY-SA 4.0
Software
Demonstration Code
The code provided as a demonstration allows the user to cycle through the various sensors to get a reading from each one and display the results on the Sharp96 display. The user can cycle through the various sensor readings.
For this project, we’ve spread the code over three files:
1. MSP432Tricorder.ino: This is the main file for the project. It contains the setup() and loop() function that controls the user experience in terms of display output and reading button presses by the user.
2. TricorderSupport.h: By pulling out all the code necessary for the BoosterPack to interface with the MSP432P401R into a header file, developers can easily edit the header file to get the BoosterPack to operate with future hardware without having to rummage through the main .ino file. The header file contains all the pin mapping and function definitions to interact with the various sensors.
3. TricorderSupport.cpp: The code for interfacing with the sensors is located in this .cpp file.
The Main Source code file can be found in the Resources section. An image of the code for viewing purposes is also located in the Resources section.
Sensor Library Source code can be found in the Resources section. What follows is an image of the code for viewing:
Let’s take a deep dive on the LMT70 analog temperature sensor. You will see that we have coded the algorithm that was given in the datasheet. When the user selects the LMT70 sensor from the Tricorder sensor menu, the software will make a function call to read_LMT70() which returns a floating point number. In the case of the LMT70 this floating point number represents the ambient temperature it senses.
Stepping through the read_LMT70() function we see that it first it enables the LMT70 output by raising the LMT70_TON pin to high. It then takes a short delay to let the sensor acquire a reading which it reads from the analog input pin LMT70_TAO. It then stores the sensor reading in the temporary variable LMT70_reading.
Lastly, it computes the temperature using the algorithm we mentioned earlier and then returns the result so it can be displayed to the user.
We would love to hear what you think about this project; please tell us in the comments section below.