albertaloop / T_SWE_2022_2023

Software for AlbertaLoop's first-generation pod.
MIT License
3 stars 0 forks source link

Read a measurement from the Honeywell Pressure Sensor #16

Open Iyury1 opened 2 years ago

Iyury1 commented 2 years ago

Summary

The pressure sensor is listen on our inventory spreadsheet on line 143: https://docs.google.com/spreadsheets/d/166oBmYiOq8Hv_DUqrxcnC_O5FaleVYDK5c3WXsnDpGY/edit?usp=sharing

A Mouser webpage is linked for where the sensor was purchased: https://www.mouser.ca/ProductDetail/Honeywell/MIPAN2XX500PSAAX?qs=BJlw7L4Cy78iVqHPSW%252BpDA%3D%3D

The datasheet for the sensor is found on the Mouser webpage: https://www.mouser.ca/datasheet/2/187/honeywell_sensing_heavy_duty_pressure_mip_series_d-1760329.pdf

The calculation needed for reading the sensor is on page 4. image

In the Features section on page 1, it lists "Current output: 4 mA to 20 mA". This means the sensor abides by 4-20 mA standard. https://www.predig.com/indicatorpage/back-basics-fundamentals-4-20-ma-current-loops

The supply voltage for the sensor is listed on page 2 in the electrical specifications as 5V. Also the ratiometric output of the sensor is listen in the Features section as 0.5Vdc - 4.5Vdc.

On the webpage for the Teensy 4.1 under "Analog Pins" and "Analog Range", it reads "The analog input range is fixed at 0 to 3.3V. On Teensy 4.1, the analogReference() function has no effect. The analog pins are not 5V tolerant. Do not drive any analog pin higher than 3.3 volts."

To interface the pressure sensor with a Teensy 4.1 we will need to use a level shifter. We have purchased a Sparkfun Logic Level Converter for this, and it is listed on line 144 of the inventory spreadsheet.

Acceptance Criteria

Iyury1 commented 1 year ago

To read from the ADC, the analogRead() function can be used. However this would rely entirely on the default ADC configurations, and could potentially block the program until the ADC conversion is complete. Also, the reference manual suggests we initiate an ADC calibration before use.
A library for the Teensy 4.1 ADC can be found here: https://github.com/pedvide/ADC. Check the examples for how to use this library.
To use the ADC, we should perform the following steps:
-Initialize analog pin. -Initialize ADC by calling constructor of ADC class. -Configure number of averages if needed, resolution, conversion speed, sampling speed. -Calibrate ADC. -Initiate a conversion, and read the value when it is ready.