ds2438 stuff, vesense+ and - swapped
This commit is contained in:
parent
6b64fa50a4
commit
268fe0fdc0
File diff suppressed because it is too large
Load Diff
@ -902,11 +902,8 @@ F 3 "~" H 16000 7400 50 0001 C CNN
|
|||||||
$EndComp
|
$EndComp
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
15050 6500 15050 6100
|
15050 6500 15050 6100
|
||||||
Wire Wire Line
|
|
||||||
3700 900 4150 900
|
|
||||||
Text Notes 5050 750 0 105 ~ 0
|
Text Notes 5050 750 0 105 ~ 0
|
||||||
One Wire
|
One Wire
|
||||||
Connection ~ 3700 900
|
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
4150 900 4150 1050
|
4150 900 4150 1050
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
@ -1595,8 +1592,6 @@ Wire Wire Line
|
|||||||
1550 11500 1550 11550
|
1550 11500 1550 11550
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
5300 10950 5300 10900
|
5300 10950 5300 10900
|
||||||
Text GLabel 5300 10900 1 50 Input ~ 0
|
|
||||||
VCC
|
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
5300 11300 5300 11250
|
5300 11300 5300 11250
|
||||||
$Comp
|
$Comp
|
||||||
@ -1625,8 +1620,6 @@ F 4 "C375452" H 5300 11450 50 0001 C CNN "LCSC_PART_NUMBER"
|
|||||||
$EndComp
|
$EndComp
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
4050 10900 4050 10850
|
4050 10900 4050 10850
|
||||||
Text GLabel 4050 10850 1 50 Input ~ 0
|
|
||||||
VCC
|
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
4050 11250 4050 11200
|
4050 11250 4050 11200
|
||||||
$Comp
|
$Comp
|
||||||
@ -1655,8 +1648,6 @@ F 4 "C205441" H 4050 11400 50 0001 C CNN "LCSC_PART_NUMBER"
|
|||||||
$EndComp
|
$EndComp
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
2900 10900 2900 10850
|
2900 10900 2900 10850
|
||||||
Text GLabel 2900 10850 1 50 Input ~ 0
|
|
||||||
VCC
|
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
2900 11250 2900 11200
|
2900 11250 2900 11200
|
||||||
$Comp
|
$Comp
|
||||||
@ -1685,8 +1676,6 @@ F 4 "C375452" H 2900 11400 50 0001 C CNN "LCSC_PART_NUMBER"
|
|||||||
$EndComp
|
$EndComp
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
9500 10950 9500 10900
|
9500 10950 9500 10900
|
||||||
Text GLabel 9500 10900 1 50 Input ~ 0
|
|
||||||
VCC
|
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
9500 11300 9500 11250
|
9500 11300 9500 11250
|
||||||
$Comp
|
$Comp
|
||||||
@ -1703,8 +1692,6 @@ F 4 "C205441" H 9500 11450 50 0001 C CNN "LCSC_PART_NUMBER"
|
|||||||
$EndComp
|
$EndComp
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
6600 10950 6600 10900
|
6600 10950 6600 10900
|
||||||
Text GLabel 6600 10900 1 50 Input ~ 0
|
|
||||||
VCC
|
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
6600 11300 6600 11250
|
6600 11300 6600 11250
|
||||||
$Comp
|
$Comp
|
||||||
@ -1733,8 +1720,6 @@ F 4 "C205441" H 6600 11450 50 0001 C CNN "LCSC_PART_NUMBER"
|
|||||||
$EndComp
|
$EndComp
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
7900 10950 7900 10900
|
7900 10950 7900 10900
|
||||||
Text GLabel 7900 10900 1 50 Input ~ 0
|
|
||||||
VCC
|
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
7900 11300 7900 11250
|
7900 11300 7900 11250
|
||||||
$Comp
|
$Comp
|
||||||
@ -2835,8 +2820,6 @@ F 4 "C17590" H 1700 11050 50 0001 C CNN "LCSC_PART_NUMBER"
|
|||||||
$EndComp
|
$EndComp
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
1700 11250 1700 11200
|
1700 11250 1700 11200
|
||||||
Text GLabel 1700 10850 1 50 Input ~ 0
|
|
||||||
VCC
|
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
1700 10900 1700 10850
|
1700 10900 1700 10850
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
@ -2882,9 +2865,9 @@ F 4 "C163067" H 21150 7700 50 0001 C CNN "LCSC_PART_NUMBER"
|
|||||||
1 21150 7700
|
1 21150 7700
|
||||||
0 1 1 0
|
0 1 1 0
|
||||||
$EndComp
|
$EndComp
|
||||||
Text GLabel 21000 7750 3 50 Input ~ 0
|
|
||||||
Rsense+
|
|
||||||
Text GLabel 21300 7750 3 50 Input ~ 0
|
Text GLabel 21300 7750 3 50 Input ~ 0
|
||||||
|
Rsense+
|
||||||
|
Text GLabel 21000 7750 3 50 Input ~ 0
|
||||||
Rsense-
|
Rsense-
|
||||||
Text GLabel 19000 10500 0 50 Input ~ 0
|
Text GLabel 19000 10500 0 50 Input ~ 0
|
||||||
Rsense+
|
Rsense+
|
||||||
@ -3148,10 +3131,10 @@ Wire Wire Line
|
|||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
5300 5500 6250 5500
|
5300 5500 6250 5500
|
||||||
$Comp
|
$Comp
|
||||||
L Device:R R?
|
L Device:R R55
|
||||||
U 1 1 60231A96
|
U 1 1 60231A96
|
||||||
P 7300 6450
|
P 7300 6450
|
||||||
F 0 "R?" V 7093 6450 50 0000 C CNN
|
F 0 "R55" V 7093 6450 50 0000 C CNN
|
||||||
F 1 "10k" V 7184 6450 50 0000 C CNN
|
F 1 "10k" V 7184 6450 50 0000 C CNN
|
||||||
F 2 "Resistor_SMD:R_0805_2012Metric_Pad1.15x1.40mm_HandSolder" V 7230 6450 50 0001 C CNN
|
F 2 "Resistor_SMD:R_0805_2012Metric_Pad1.15x1.40mm_HandSolder" V 7230 6450 50 0001 C CNN
|
||||||
F 3 "~" H 7300 6450 50 0001 C CNN
|
F 3 "~" H 7300 6450 50 0001 C CNN
|
||||||
@ -3167,4 +3150,21 @@ Wire Wire Line
|
|||||||
Connection ~ 7300 6600
|
Connection ~ 7300 6600
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
7300 6600 7700 6600
|
7300 6600 7700 6600
|
||||||
|
Connection ~ 3700 900
|
||||||
|
Wire Wire Line
|
||||||
|
3700 900 4150 900
|
||||||
|
Text GLabel 1700 10850 1 50 Input ~ 0
|
||||||
|
PWR_PUMP_CONVERTER
|
||||||
|
Text GLabel 2900 10850 1 50 Input ~ 0
|
||||||
|
PWR_PUMP_CONVERTER
|
||||||
|
Text GLabel 4050 10850 1 50 Input ~ 0
|
||||||
|
PWR_PUMP_CONVERTER
|
||||||
|
Text GLabel 5300 10900 1 50 Input ~ 0
|
||||||
|
PWR_PUMP_CONVERTER
|
||||||
|
Text GLabel 6600 10900 1 50 Input ~ 0
|
||||||
|
PWR_PUMP_CONVERTER
|
||||||
|
Text GLabel 7900 10900 1 50 Input ~ 0
|
||||||
|
PWR_PUMP_CONVERTER
|
||||||
|
Text GLabel 9500 10900 1 50 Input ~ 0
|
||||||
|
PWR_PUMP_CONVERTER
|
||||||
$EndSCHEMATC
|
$EndSCHEMATC
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
#define DS2438_TEMPERATURE_DELAY 10
|
#define DS2438_TEMPERATURE_DELAY 10
|
||||||
#define DS2438_VOLTAGE_CONVERSION_DELAY 8
|
#define DS2438_VOLTAGE_CONVERSION_DELAY 8
|
||||||
|
|
||||||
#define DEFAULT_PAGE0 uint8_t[8] { \
|
#define DEFAULT_PAGE0(var) uint8_t var[8] { \
|
||||||
0b00001011 /* X, ADB=0, NVB=0, TB=0, AD=1, EE=0, CA=1, IAD=1 */, \
|
0b00001011 /* X, ADB=0, NVB=0, TB=0, AD=1, EE=0, CA=1, IAD=1 */, \
|
||||||
0, /* Temperatur */ \
|
0, /* Temperatur */ \
|
||||||
0, /* Temperatur */ \
|
0, /* Temperatur */ \
|
||||||
|
@ -46,6 +46,8 @@ void DS2438::begin(){
|
|||||||
if (validAddress(searchDeviceAddress)) {
|
if (validAddress(searchDeviceAddress)) {
|
||||||
if (validFamily(searchDeviceAddress)) {
|
if (validFamily(searchDeviceAddress)) {
|
||||||
memcpy(_address,searchDeviceAddress,8);
|
memcpy(_address,searchDeviceAddress,8);
|
||||||
|
//DEFAULT_PAGE0(defaultConfig);
|
||||||
|
//writePage(0, defaultConfig);
|
||||||
deviceFound = true;
|
deviceFound = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,9 +86,26 @@ void DS2438::update() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!readPage(0, data)){
|
if (!readPage(0, data)){
|
||||||
|
|
||||||
Serial.println("Error reading zero page ds2438 channel a");
|
Serial.println("Error reading zero page ds2438 channel a");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Serial.print(data[0],16);
|
||||||
|
Serial.print(" ");
|
||||||
|
Serial.print(data[1],16);
|
||||||
|
Serial.print(" ");
|
||||||
|
Serial.print(data[2],16);
|
||||||
|
Serial.print(" ");
|
||||||
|
Serial.print(data[3],16);
|
||||||
|
Serial.print(" ");
|
||||||
|
Serial.print(data[4],16);
|
||||||
|
Serial.print(" ");
|
||||||
|
Serial.print(data[5],16);
|
||||||
|
Serial.print(" ");
|
||||||
|
Serial.print(data[6],16);
|
||||||
|
Serial.print(" ");
|
||||||
|
Serial.println(data[7],16);
|
||||||
|
|
||||||
|
|
||||||
if (doTemperature) {
|
if (doTemperature) {
|
||||||
_temperature = (double)(((((int16_t)data[2]) << 8) | (data[1] & 0x0ff)) >> 3) * 0.03125;
|
_temperature = (double)(((((int16_t)data[2]) << 8) | (data[1] & 0x0ff)) >> 3) * 0.03125;
|
||||||
@ -116,17 +135,63 @@ void DS2438::update() {
|
|||||||
|
|
||||||
int16_t upperByte = ((int16_t)data[6]) << 8;
|
int16_t upperByte = ((int16_t)data[6]) << 8;
|
||||||
int16_t lowerByte = data[5];
|
int16_t lowerByte = data[5];
|
||||||
int16_t fullByte = (upperByte | lowerByte);
|
int16_t fullByte = (int16_t)(upperByte | lowerByte);
|
||||||
_current = ((float)fullByte) / (4096.0f * _currentShunt);
|
float fullByteb = fullByte;
|
||||||
|
_current = (fullByteb) / ((4096.0f * _currentShunt));
|
||||||
_error = false;
|
_error = false;
|
||||||
|
Serial.print(data[0],16);
|
||||||
|
Serial.print(" ");
|
||||||
|
Serial.print(data[1],16);
|
||||||
|
Serial.print(" ");
|
||||||
|
Serial.print(data[2],16);
|
||||||
|
Serial.print(" ");
|
||||||
|
Serial.print(data[3],16);
|
||||||
|
Serial.print(" ");
|
||||||
|
Serial.print(data[4],16);
|
||||||
|
Serial.print(" ");
|
||||||
|
Serial.print(data[5],16);
|
||||||
|
Serial.print(" ");
|
||||||
|
Serial.print(data[6],16);
|
||||||
|
Serial.print(" ");
|
||||||
|
Serial.println(data[7],16);
|
||||||
|
Serial.println("-");
|
||||||
|
|
||||||
if (!readPage(7, data)){
|
if (readPage(7, data)){
|
||||||
PageSeven_t *pSeven = (PageSeven_t *) data;
|
PageSeven_t *pSeven = (PageSeven_t *) data;
|
||||||
int16_t CCA = pSeven->CCA0 | ((int16_t) pSeven->CCA1) << 8;
|
int16_t CCA = pSeven->CCA0 | ((int16_t) pSeven->CCA1) << 8;
|
||||||
int16_t DCA = pSeven->DCA0 | ((int16_t) pSeven->DCA1) << 8;
|
int16_t DCA = pSeven->DCA0 | ((int16_t) pSeven->DCA1) << 8;
|
||||||
|
|
||||||
|
|
||||||
Serial.printf("DCA: %d. CCA: %d\n", DCA, CCA);
|
Serial.printf("DCA: %d. CCA: %d\n", DCA, CCA);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (readPage(1, data)){
|
||||||
|
PageOne_t *pSeven = (PageOne_t *) data;
|
||||||
|
Serial.print(data[0],16);
|
||||||
|
Serial.print(" ");
|
||||||
|
Serial.print(data[1],16);
|
||||||
|
Serial.print(" ");
|
||||||
|
Serial.print(data[2],16);
|
||||||
|
Serial.print(" ");
|
||||||
|
Serial.print(data[3],16);
|
||||||
|
Serial.print(" ");
|
||||||
|
Serial.print(data[4],16);
|
||||||
|
Serial.print(" ");
|
||||||
|
Serial.print(data[5],16);
|
||||||
|
Serial.print(" ");
|
||||||
|
Serial.print(data[6],16);
|
||||||
|
Serial.print(" ");
|
||||||
|
Serial.println(data[7],16);
|
||||||
|
Serial.println(pSeven->ICA);
|
||||||
|
float Ah = pSeven->ICA / (2048.0f * _currentShunt);
|
||||||
|
Serial.println(Ah);
|
||||||
|
Serial.println("=");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double DS2438::getTemperature() {
|
double DS2438::getTemperature() {
|
||||||
|
@ -54,6 +54,8 @@ void print_wakeup_reason(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool whatever = true;
|
||||||
|
|
||||||
void setAll2Off() {
|
void setAll2Off() {
|
||||||
digitalWrite(OUTPUT_PUMP0, LOW);
|
digitalWrite(OUTPUT_PUMP0, LOW);
|
||||||
digitalWrite(OUTPUT_PUMP1, LOW);
|
digitalWrite(OUTPUT_PUMP1, LOW);
|
||||||
@ -82,7 +84,7 @@ void setup() {
|
|||||||
|
|
||||||
setAll2Off();
|
setAll2Off();
|
||||||
|
|
||||||
Serial.begin(115200);
|
Serial.begin(9600);
|
||||||
|
|
||||||
//Increment boot number and print it every reboot
|
//Increment boot number and print it every reboot
|
||||||
++bootCount;
|
++bootCount;
|
||||||
@ -93,7 +95,7 @@ void setup() {
|
|||||||
print_wakeup_reason();
|
print_wakeup_reason();
|
||||||
|
|
||||||
/* activate power pump and pump 0 */
|
/* activate power pump and pump 0 */
|
||||||
digitalWrite(OUTPUT_PUMP, HIGH);
|
|
||||||
digitalWrite(OUTPUT_SENSOR, HIGH);
|
digitalWrite(OUTPUT_SENSOR, HIGH);
|
||||||
|
|
||||||
delay(1);
|
delay(1);
|
||||||
@ -111,6 +113,9 @@ void setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
whatever = !whatever;
|
||||||
|
digitalWrite(OUTPUT_PUMP, whatever?HIGH:LOW);
|
||||||
|
delay(2000);
|
||||||
digitalWrite(OUTPUT_PUMP0, HIGH);
|
digitalWrite(OUTPUT_PUMP0, HIGH);
|
||||||
|
|
||||||
for(int j=0; j < 5 && temp.getDeviceCount() == 0; j++) {
|
for(int j=0; j < 5 && temp.getDeviceCount() == 0; j++) {
|
||||||
@ -121,7 +126,7 @@ void loop() {
|
|||||||
|
|
||||||
for(int j=0; j < 5 && (0 == battery.isFound()); j++) {
|
for(int j=0; j < 5 && (0 == battery.isFound()); j++) {
|
||||||
delay(10);
|
delay(10);
|
||||||
// Serial.println("Reset 1wire bat");
|
Serial.println("Reset 1wire bat");
|
||||||
battery.begin();
|
battery.begin();
|
||||||
battery.update();
|
battery.update();
|
||||||
}
|
}
|
||||||
|
BIN
sheets/DS2438.pdf
Normal file
BIN
sheets/DS2438.pdf
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user