test sampler AC

This commit is contained in:
Matthew Kennedy 2023-08-09 13:44:12 -07:00
parent 1897917dd7
commit 1d7c2284e8
1 changed files with 29 additions and 3 deletions

View File

@ -14,7 +14,7 @@ int GetESRSupplyR()
return 22000;
}
TEST(Sampler, TestDcBehavior)
TEST(Sampler, TestDc)
{
Sampler dut;
@ -23,7 +23,7 @@ TEST(Sampler, TestDcBehavior)
data.PumpCurrentVoltage = 1.75f;
constexpr float virtualGroundVoltage = 1.65f;
for (size_t i = 0; i < 10; i++)
for (size_t i = 0; i < 5000; i++)
{
dut.ApplySample(data, virtualGroundVoltage);
}
@ -31,5 +31,31 @@ TEST(Sampler, TestDcBehavior)
// not exactly 0 because of filtering
EXPECT_NEAR(0, dut.GetNernstAc(), 1e-3);
EXPECT_FLOAT_EQ(0.45f, dut.GetNernstDc());
EXPECT_NEAR(-0.0295, dut.GetPumpNominalCurrent(), 1e-3);
EXPECT_NEAR(-0.1616, dut.GetPumpNominalCurrent(), 1e-3);
}
TEST(Sampler, TestAc)
{
Sampler dut;
AnalogChannelResult dataLow;
dataLow.NernstVoltage = 0.45f - 0.1f;
dataLow.PumpCurrentVoltage = 1.75f;
AnalogChannelResult dataHigh;
dataHigh.NernstVoltage = 0.45f + 0.1f;
dataHigh.PumpCurrentVoltage = 1.75f;
constexpr float virtualGroundVoltage = 1.65f;
for (size_t i = 0; i < 5000; i++)
{
dut.ApplySample(dataLow, virtualGroundVoltage);
dut.ApplySample(dataHigh, virtualGroundVoltage);
}
// not exactly 0 because of filtering
EXPECT_NEAR(0.2, dut.GetNernstAc(), 1e-3);
EXPECT_FLOAT_EQ(0.45f, dut.GetNernstDc());
EXPECT_NEAR(-0.1616, dut.GetPumpNominalCurrent(), 1e-3);
}