Skip to content

Commit

Permalink
add a board rev for new sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanthecoder committed Jan 4, 2024
1 parent bb304d5 commit e7aa7d6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion include/i2c/simulation/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "common/core/bit_utils.hpp"
#include "common/core/logging.h"
#include "sensors/core/mmr920C04.hpp"
#include "sensors/core/mmr920.hpp"

namespace i2c {
namespace hardware {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "motor-control/core/utils.hpp"
/*
* MMR920C04 Pressure Sensor
* MMR920 Pressure Sensor
*
* Datasheet:
* https://nmbtc.com/wp-content/uploads/2021/03/mmr920_leaflet_e_rev1.pdf
Expand All @@ -26,12 +26,16 @@
* Leaving them alone for now.
*/
namespace sensors {
namespace mmr920C04 {
namespace mmr920 {
constexpr uint16_t ADDRESS = 0x67 << 1;

// Pressure cannot be measured beyond +/-8226.4F
// Pressure cannot be measured beyond +/-8226.4F on the old sensors
// New sensors have double the threshold but half the fidelity
#if PCBA_PRIMARY_REVISION == 'e'
constexpr float MAX_PRESSURE_READING = 16452.8F;

#else
constexpr float MAX_PRESSURE_READING = 8226.4F;
#endif
enum class SensorStatus : uint8_t {
SHUTDOWN = 0x0,
IDLE = 0xE5,
Expand Down Expand Up @@ -96,7 +100,7 @@ template <typename Reg>
// Struct has a valid register address
// Struct has an integer with the total number of bits in a register.
// This is used to mask the value before writing it to the sensor.
concept MMR920C04CommandRegister =
concept MMR920CommandRegister =
std::same_as<std::remove_cvref_t<decltype(Reg::address)>,
std::remove_cvref_t<Registers&>> &&
std::integral<decltype(Reg::value_mask)>;
Expand Down Expand Up @@ -265,8 +269,11 @@ struct PressureResult {
static constexpr float CMH20_TO_PASCALS = 98.0665;
// conversion factor of a given 3 byte measurement to Pascals
static constexpr float PA_PER_COUNT =
#if PCBA_PRIMARY_REVISION == 'e'
2 * 1e-5 * CMH20_TO_PASCALS; // 1.0e-5cmH2O/count * 98.0665Pa/cmH2O

#else
1e-5 * CMH20_TO_PASCALS; // 1.0e-5cmH2O/count * 98.0665Pa/cmH2O
#endif
uint32_t reading : 32 = 0;

[[nodiscard]] static auto to_pressure(uint32_t reg) -> float {
Expand Down Expand Up @@ -325,7 +332,7 @@ struct StatusResult {
return convert_to_fixed_point(reading, S15Q16_RADIX);
}

struct MMR920C04RegisterMap {
struct MMR920RegisterMap {
Reset reset = {};
Idle idle = {};
MeasureMode1 measure_mode_1 = {};
Expand All @@ -347,5 +354,5 @@ using RegisterSerializedType = uint8_t;
// Command Registers are all 8 bits
// Type definition to allow type aliasing for pointer dereferencing
using RegisterSerializedTypeA = __attribute__((__may_alias__)) uint8_t;
}; // namespace mmr920C04
}; // namespace mmr920
}; // namespace sensors
6 changes: 3 additions & 3 deletions pipettes/firmware/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,21 @@ set(pipette_srcs ${PIPETTE_FW_LINTABLE_SRCS}

foreach_revision(
PROJECT_NAME pipettes-single
REVISIONS b1 c2 d1
REVISIONS b1 c2 d1 e1
SOURCES pipette_srcs pipette_srcs pipette_srcs
CALL_FOREACH_REV pipettes_single_loop
)

foreach_revision(
PROJECT_NAME pipettes-multi
REVISIONS b1 c2 d1
REVISIONS b1 c2 d1 e1
CALL_FOREACH_REV pipettes_multi_loop
SOURCES pipette_srcs pipette_srcs pipette_srcs
)

foreach_revision(
PROJECT_NAME pipettes-96
REVISIONS b1 c1 d2
REVISIONS b1 c1 d2 e1
CALL_FOREACH_REV pipettes_96_loop
SOURCES pipette_srcs pipette_srcs pipette_srcs
)
Expand Down

0 comments on commit e7aa7d6

Please sign in to comment.