more syntax fixes (from merge) #changelog
This commit is contained in:
parent
26d7a978d3
commit
9ce36b8607
3 changed files with 23 additions and 45 deletions
|
|
@ -62,8 +62,9 @@ update the voltMeterConstant variable in pP_config.h with the correct value*/
|
||||||
Vin = readVcc(), DEC;
|
Vin = readVcc(), DEC;
|
||||||
followerLong = followerThrs * 1023L;
|
followerLong = followerThrs * 1023L;
|
||||||
compLong = compThrs * 1023L;
|
compLong = compThrs * 1023L;
|
||||||
|
followerInt = (long long) followerLong / Vin;
|
||||||
compInt = (long long) compLong / Vin;
|
compInt = (long long) compLong / Vin;
|
||||||
senseInt = (int) senseInt;
|
followerInt = (int) followerInt;
|
||||||
compInt = (int) compInt;
|
compInt = (int) compInt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -73,7 +74,7 @@ update the voltMeterConstant variable in pP_config.h with the correct value*/
|
||||||
/* Compares diffs of threshold vs read value
|
/* Compares diffs of threshold vs read value
|
||||||
if positive, adjusts the follower to within
|
if positive, adjusts the follower to within
|
||||||
the range set above*/
|
the range set above*/
|
||||||
ADJ_FOLLOW = (senseInt / 4);
|
ADJ_FOLLOW = (followerInt / 4);
|
||||||
|
|
||||||
// Analog output (PWM) of duty cycle
|
// Analog output (PWM) of duty cycle
|
||||||
analogWrite(V_FOL_PWM, ADJ_FOLLOW);
|
analogWrite(V_FOL_PWM, ADJ_FOLLOW);
|
||||||
|
|
@ -105,7 +106,6 @@ void adjustGain() {
|
||||||
pinMode(GADJ_R2, INPUT);
|
pinMode(GADJ_R2, INPUT);
|
||||||
pinMode(GADJ_R1, INPUT);
|
pinMode(GADJ_R1, INPUT);
|
||||||
pinMode(GADJ_R0, INPUT);
|
pinMode(GADJ_R0, INPUT);
|
||||||
ERR_STATE = 0;
|
|
||||||
}
|
}
|
||||||
else if (GAIN_FACTOR > 0) {
|
else if (GAIN_FACTOR > 0) {
|
||||||
pinMode(GADJ_R3, OUTPUT);
|
pinMode(GADJ_R3, OUTPUT);
|
||||||
|
|
@ -113,25 +113,21 @@ void adjustGain() {
|
||||||
pinMode(GADJ_R2, INPUT);
|
pinMode(GADJ_R2, INPUT);
|
||||||
pinMode(GADJ_R1, INPUT);
|
pinMode(GADJ_R1, INPUT);
|
||||||
pinMode(GADJ_R0, INPUT);
|
pinMode(GADJ_R0, INPUT);
|
||||||
ERR_STATE = 0;
|
|
||||||
}
|
}
|
||||||
else if (GAIN_FACTOR > 1) {
|
else if (GAIN_FACTOR > 1) {
|
||||||
pinMode(GADJ_R2, OUTPUT);
|
pinMode(GADJ_R2, OUTPUT);
|
||||||
digitalWrite(GADJ_R2, LOW);
|
digitalWrite(GADJ_R2, LOW);
|
||||||
pinMode(GADJ_R1, INPUT);
|
pinMode(GADJ_R1, INPUT);
|
||||||
pinMode(GADJ_R0, INPUT);
|
pinMode(GADJ_R0, INPUT);
|
||||||
ERR_STATE = 0;
|
|
||||||
}
|
}
|
||||||
else if (GAIN_FACTOR > 2) {
|
else if (GAIN_FACTOR > 2) {
|
||||||
pinMode(GADJ_R1, OUTPUT);
|
pinMode(GADJ_R1, OUTPUT);
|
||||||
digitalWrite(GADJ_R1, LOW);
|
digitalWrite(GADJ_R1, LOW);
|
||||||
pinMode(GADJ_R0, INPUT);
|
pinMode(GADJ_R0, INPUT);
|
||||||
ERR_STATE = 0;
|
|
||||||
}
|
}
|
||||||
else if (GAIN_FACTOR > 3) {
|
else if (GAIN_FACTOR > 3) {
|
||||||
pinMode(GADJ_R0, OUTPUT);
|
pinMode(GADJ_R0, OUTPUT);
|
||||||
digitalWrite(GADJ_R0, LOW);
|
digitalWrite(GADJ_R0, LOW);
|
||||||
ERR_STATE = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ void identifyMarkers() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------------------------------------*/
|
/*------------------------------------------------*/
|
||||||
|
|
||||||
void updateGainFactor()
|
void updateGainFactor()
|
||||||
{
|
{
|
||||||
if (serialInt >= 0)
|
if (serialInt >= 0)
|
||||||
|
|
@ -65,7 +66,7 @@ void updateGainFactor()
|
||||||
EEPROM.put(GAIN_FACTOR_ADDRESS, GAIN_FACTOR);
|
EEPROM.put(GAIN_FACTOR_ADDRESS, GAIN_FACTOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
/*------------------------------------------------*/
|
/*------------------------------------------------*/
|
||||||
|
|
||||||
void updateVFol() {
|
void updateVFol() {
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,11 @@ int TRG_DUR = TRG_DUR_DEFAULT; // duration of the Z-axis pulse sent, in ms
|
||||||
int Hyst = HYST_DEFAULT; // Hysteresis value for ADC measurements
|
int Hyst = HYST_DEFAULT; // Hysteresis value for ADC measurements
|
||||||
int Debug = 0;
|
int Debug = 0;
|
||||||
long voltMeterConstant = 1125300L; // For fine tuning input voltage sense
|
long voltMeterConstant = 1125300L; // For fine tuning input voltage sense
|
||||||
// byte pP_i2c_address = 0xa0; // I2C Bus Address
|
#ifdef I2C_INPUT
|
||||||
|
byte pP_i2c_address = 0xa0; // I2C Bus Address
|
||||||
|
#endif
|
||||||
|
|
||||||
void resetEEPROM()
|
void resetEEPROM() {
|
||||||
{
|
|
||||||
resetConfig();
|
resetConfig();
|
||||||
EEPROM.put(GAIN_FACTOR_ADDRESS, GAIN_FACTOR);
|
EEPROM.put(GAIN_FACTOR_ADDRESS, GAIN_FACTOR);
|
||||||
EEPROM.put(FOLLOWER_THRESHOLD_ADDRESS, followerThrs);
|
EEPROM.put(FOLLOWER_THRESHOLD_ADDRESS, followerThrs);
|
||||||
|
|
@ -23,73 +24,53 @@ void resetEEPROM()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore config from EEPROM, otherwise reset config and write to EEPROM
|
// Restore config from EEPROM, otherwise reset config and write to EEPROM
|
||||||
void restoreConfig()
|
void restoreConfig() {
|
||||||
{
|
|
||||||
int temp;
|
int temp;
|
||||||
|
|
||||||
EEPROM.get(GAIN_FACTOR_ADDRESS, temp);
|
EEPROM.get(GAIN_FACTOR_ADDRESS, temp);
|
||||||
if (temp < 0 || temp > 4)
|
if (temp < 0 || temp > 4) {
|
||||||
{
|
|
||||||
resetEEPROM();
|
resetEEPROM();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
GAIN_FACTOR = temp;
|
GAIN_FACTOR = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
EEPROM.get(FOLLOWER_THRESHOLD_ADDRESS, temp);
|
EEPROM.get(FOLLOWER_THRESHOLD_ADDRESS, temp);
|
||||||
if (temp < 0 || temp > 5000)
|
if (temp < 0 || temp > 5000) {
|
||||||
{
|
|
||||||
resetEEPROM();
|
resetEEPROM();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
followerThrs = temp;
|
followerThrs = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
EEPROM.get(COMP_THRESHOLD_ADDRESS, temp);
|
EEPROM.get(COMP_THRESHOLD_ADDRESS, temp);
|
||||||
if (temp < 0 || temp > 5000)
|
if (temp < 0 || temp > 5000) {
|
||||||
{
|
|
||||||
resetEEPROM();
|
resetEEPROM();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
compThrs = temp;
|
compThrs = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
EEPROM.get(LOOP_DUR_ADDRESS, temp);
|
EEPROM.get(LOOP_DUR_ADDRESS, temp);
|
||||||
if (temp < 0 && temp > 1000)
|
if (temp < 0 && temp > 1000) {
|
||||||
{
|
|
||||||
resetEEPROM();
|
resetEEPROM();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
LOOP_DUR = temp;
|
LOOP_DUR = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
EEPROM.get(TRG_DUR_ADDRESS, temp);
|
EEPROM.get(TRG_DUR_ADDRESS, temp);
|
||||||
if (temp < 0 || temp > 1000)
|
if (temp < 0 || temp > 1000) {
|
||||||
{
|
|
||||||
resetEEPROM();
|
resetEEPROM();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
TRG_DUR = temp;
|
TRG_DUR = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
EEPROM.get(HYST_ADDRESS, temp);
|
EEPROM.get(HYST_ADDRESS, temp);
|
||||||
if (temp < 0 || temp > 1000)
|
if (temp < 0 || temp > 1000) {
|
||||||
{
|
|
||||||
resetEEPROM();
|
resetEEPROM();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
Hyst = temp;
|
Hyst = temp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void resetConfig()
|
void resetConfig() {
|
||||||
{
|
|
||||||
GAIN_FACTOR = GAIN_FACTOR_DEFAULT;
|
GAIN_FACTOR = GAIN_FACTOR_DEFAULT;
|
||||||
followerThrs = FOLLOWER_THRESHOLD_DEFAULT;
|
followerThrs = FOLLOWER_THRESHOLD_DEFAULT;
|
||||||
compThrs = COMP_THRESHOLD_DEFAULT;
|
compThrs = COMP_THRESHOLD_DEFAULT;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue