Skip to content

Commit

Permalink
prepare for very low value cap
Browse files Browse the repository at this point in the history
  • Loading branch information
mean committed Jun 30, 2020
1 parent 929e3cf commit 44ffb6a
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
16 changes: 3 additions & 13 deletions componentLibrary/Capacitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,20 +332,10 @@ bool Capacitor::computeVeryLowCap()
c=c/log( (float)vB/(float)vA);
c=c*(float)samplingTime/(float)F_CPU;

if(c>(float)p1->_calibration.capOffsetHighInPf/pPICO)
c-=(float)p1->_calibration.capOffsetHighInPf/pPICO;

char st[25];
Component::prettyPrint(c,"F",st);
TesterGfx::drawCapacitor(0,st,p1->pinNumber(),p2->pinNumber());

//
while(1)
{

}




capacitance=c;
return true;
}
/**
Expand Down
2 changes: 1 addition & 1 deletion componentLibrary/Component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void Component::prettyPrint(float value, const char *unit, char *output)
scale=small;
}
int dex=0;
while(1)
while(dex<=3)
{
if(value>1 && value<1000)
break;
Expand Down
14 changes: 9 additions & 5 deletions nvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "nvm_default.h"
#include "cpuID.h"

#define HASH 0x4569
#define HASH 0x456B


/**
Expand Down Expand Up @@ -46,16 +46,19 @@ bool NVM::loadTestPin(int pin, TestPinCalibration &calibration)
int calibrationHash=eep.read(0);
if(calibrationHash != HASH)
{
calibration.resUp =WIRE_RESISTANCE_AND_INTERNAL;
calibration.resDown =WIRE_RESISTANCE_AND_INTERNAL;
calibration.capOffsetInPf =INTERNAL_CAPACITANCE_IN_PF;
calibration.inductanceInUF =INTERNAL_INDUCTANCE_IN_UF;
calibration.resUp =WIRE_RESISTANCE_AND_INTERNAL;
calibration.resDown =WIRE_RESISTANCE_AND_INTERNAL;
calibration.capOffsetInPf =INTERNAL_CAPACITANCE_IN_PF;
calibration.capOffsetHighInPf =INTERNAL_CAPACITANCE_IN_PF_HIGH;
calibration.inductanceInUF =INTERNAL_INDUCTANCE_IN_UF;
return true; // default value
}
calibration.resUp= eep.read(10*pin+1+0);
calibration.resDown= eep.read(10*pin+1+1);;
calibration.capOffsetInPf= eep.read(10*pin+1+2)+1;; // there is a ~ 3/4 pf Error
calibration.inductanceInUF= eep.read(10*pin+1+3);;
calibration.capOffsetHighInPf= eep.read(10*pin+1+4);;
calibration.capOffsetHighInPf =INTERNAL_CAPACITANCE_IN_PF_HIGH;
return true;
}
/**
Expand All @@ -71,6 +74,7 @@ bool NVM::saveTestPin(int pin, const TestPinCalibration &calibration)
eep.write(10*pin+1+1, calibration.resDown);;
eep.write(10*pin+1+2,calibration.capOffsetInPf);;
eep.write(10*pin+1+3,calibration.inductanceInUF);;
eep.write(10*pin+1+4,calibration.capOffsetHighInPf);;
return true;
}

Expand Down
4 changes: 3 additions & 1 deletion nvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ class TestPinCalibration
public:
uint16_t resDown;
uint16_t resUp;
uint16_t capOffsetInPf;
uint16_t capOffsetInPf; // when using fast ADC
uint16_t capOffsetHighInPf; // when using slow adc
uint16_t inductanceInUF;
TestPinCalibration()
{
resDown=0;
resUp=0;
capOffsetInPf=0;
inductanceInUF=0;
capOffsetHighInPf=0;
}
};

Expand Down
1 change: 1 addition & 0 deletions nvm_default.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@


#define INTERNAL_CAPACITANCE_IN_PF (1*14) // 6 pf is the ADC internal cap also
#define INTERNAL_CAPACITANCE_IN_PF_HIGH (1*29)
#define INTERNAL_INDUCTANCE_IN_UF (130)
#define WIRE_RESISTANCE_AND_INTERNAL 24

Expand Down
5 changes: 4 additions & 1 deletion pinAutoTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ int easySample(TestPin &M);
static bool singlePinTest(TestPin &A, TestPin &MeasurePin, const char **failure)
{
int sum;
{
AutoDisconnect ad2;
}
AutoDisconnect ad;
{
pinMode(MeasurePin.pinADC(),INPUT_ANALOG);
pinMode(MeasurePin.pinADC(),INPUT_ANALOG);
A.setToGround();
sum=easySample(MeasurePin);
if(sum>LOW_FLOOR)
Expand Down

0 comments on commit 44ffb6a

Please sign in to comment.