Skip to content

Commit

Permalink
Removed debug serial output, fixed voltage reference divisor
Browse files Browse the repository at this point in the history
  • Loading branch information
pyr0ball committed Jan 9, 2019
1 parent 19aa237 commit 39a0181
Showing 1 changed file with 2 additions and 23 deletions.
25 changes: 2 additions & 23 deletions ATmega48_Piezo_Sensor/ATmega48_Piezo_Sensor.ino
Expand Up @@ -100,19 +100,13 @@ void adjustState() {
void adjustVoltage() {

if (ADJ_STATE < 0) {
Serial.print("adjustVoltage:");
Serial.println(ADJ_STATE);
Serial.println("--------------------");
ERR_STATE = 1;
}
if (ADJ_STATE = 0) {
pinMode(VADJ_R3, INPUT);
pinMode(VADJ_R2, INPUT);
pinMode(VADJ_R1, INPUT);
pinMode(VADJ_R0, INPUT);
Serial.print("adjustVoltage:");
Serial.println(ADJ_STATE);
Serial.println("--------------------");
ERR_STATE = 0;
}
if (ADJ_STATE > 0) {
Expand All @@ -121,42 +115,27 @@ void adjustVoltage() {
pinMode(VADJ_R2, INPUT);
pinMode(VADJ_R1, INPUT);
pinMode(VADJ_R0, INPUT);
Serial.print("adjustVoltage:");
Serial.println(ADJ_STATE);
Serial.println("--------------------");
ERR_STATE = 0;
}
if (ADJ_STATE > 1) {
pinMode(VADJ_R2, OUTPUT);
digitalWrite(VADJ_R2, LOW);
pinMode(VADJ_R1, INPUT);
pinMode(VADJ_R0, INPUT);
Serial.print("adjustVoltage:");
Serial.println(ADJ_STATE);
Serial.println("--------------------");
ERR_STATE = 0;
}
if (ADJ_STATE > 2) {
pinMode(VADJ_R1, OUTPUT);
digitalWrite(VADJ_R1, LOW);
pinMode(VADJ_R0, INPUT);
Serial.print("adjustVoltage:");
Serial.println(ADJ_STATE);
Serial.println("--------------------");
ERR_STATE = 0;
}
if (ADJ_STATE > 3) {
pinMode(VADJ_R0, OUTPUT);
digitalWrite(VADJ_R0, LOW);
Serial.print("adjustVoltage:");
Serial.println(ADJ_STATE);
Serial.println("--------------------");
ERR_STATE = 0;
}
if (ADJ_STATE > 4) {
Serial.print("adjustVoltage:");
Serial.println(ADJ_STATE);
Serial.println("--------------------");
ERR_STATE = 1;
}
}
Expand Down Expand Up @@ -185,9 +164,9 @@ void loop() {

// Check voltage of first and second stages and compare against thresholds
folRead = analogRead(V_FOLLOW_PIN);
VRef = folRead * (5.0 / 1023.0);
VRef = (folRead * 5.0) / 1024.0;
vadjRead = analogRead(VADJ_SENSE_PIN);
VAdj = vadjRead * (5.0 / 1023.0);
VAdj = (vadjRead * 5.0) / 1024.0;
diffAdjL = VAdj - senseLowThrs;
diffAdjH = senseHighThrs - VAdj;

Expand Down

0 comments on commit 39a0181

Please sign in to comment.