Skip to content

Commit

Permalink
Version 1.0
Browse files Browse the repository at this point in the history
Removed analog multiplexer for complexity reasons and commented flow
current out.
  • Loading branch information
Simsso committed Mar 20, 2016
1 parent e505ef1 commit 64c3d33
Showing 1 changed file with 4 additions and 37 deletions.
41 changes: 4 additions & 37 deletions Sensor-Arduino/Sensor-Arduino.ino
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,11 @@
#define dataLinkRX 3
#define dataLinkTX 4



// analog multiplexer control signals
#define analogMuxS0 5
#define analogMuxS1 6
#define analogMuxS2 7

// analog multiplexer enable signal
#define analogMuxE 8

// analog multiplexer data
#define analogMuxData A5


#define currentPhase1Pin A0
#define currentPhase2Pin A1
#define currentPhase3Pin A2
#define flowCurrrentPin 0 // analog mux pin
#define busVoltagePin 1 // analog mux pin
// #define flowCurrrentPin A5
#define busVoltagePin A5

#define flowSensorInterrupt 0 // 0 = digital pin 2

Expand Down Expand Up @@ -172,11 +158,11 @@ boolean readSensorData() {
break;
case 3:
// BUS Spannung
sensorValue = (float)read4051AnalogPin(busVoltagePin);
sensorValue = (float)analogRead(busVoltagePin);
break;
case 4:
// Current Primary
sensorValue = (float)read4051AnalogPin(flowCurrrentPin);
sensorValue = 0; // (float)analogRead(flowCurrrentPin);
break;
case 5:
// Temp PFC
Expand Down Expand Up @@ -289,22 +275,3 @@ float measureCurrent(byte analogPin) { // analogPin [0..7]
}
return 0;
}

int read4051AnalogPin(int pin) {
// select multiplexer input
digitalWrite(analogMuxS0, pin & 1);
digitalWrite(analogMuxS1, pin & 2 >> 1);
digitalWrite(analogMuxS2, pin & 4 >> 2);

// enable
digitalWrite(analogMuxE, LOW);
delayMicroseconds(5);

// read value
int val = analogRead(analogMuxData);

// disable
digitalWrite(analogMuxE, HIGH);

return val;
}

0 comments on commit 64c3d33

Please sign in to comment.