I was able to design the system and write a program to measure the effective voltage from eight channels with the help of an analog multiplexer CD4051B. In another thread I found information that in order to determine the rough value of the effective voltage you should multiply the peak voltage by the square root of 2. So I did. However, I have a problem. The system without connecting any test leads indicates correctly 0V, but after connecting the cable with 230VAC voltage to one of the eight TEZ 1.5 / D 230/6 transformers, the system reads at the 169V input, and on other unconnected it indicates about 16V. What could be wrong? Below is the program and circuit diagram (resistors in the dividers are 4.7k).
[code:1:d5ce73d7f3]
#define WA A1
#define WB A2
#define WC A3
void setup() {
// put your setup code here, to run once:
pinMode(A0,INPUT);
pinMode(WA,OUTPUT);
pinMode(WB,OUTPUT);
pinMode(WC,OUTPUT);
Serial.begin(9600);
}
/*
* ustawieniee kanału multipleksera
*/
void set_kanal(byte nr){
switch(nr){
case 0:{set_0();}break;
case 1:{set_1();}break;
case 2:{set_2();}break;
case 3:{set_3();}break;
case 4:{set_4();}break;
case 5:{set_5();}break;
case 6:{set_6();}break;
case 7:{set_7();}break;
default:{res();}break;
}
delay(20);
}
void set_0(){
digitalWrite(WA,LOW);
digitalWrite(WB,LOW);
digitalWrite(WC,LOW);
//Serial.print("Odczyt z zero:\t\t");
}
void set_1(){
digitalWrite(WA,HIGH);
digitalWrite(WB,LOW);
digitalWrite(WC,LOW);
//Serial.print("Odczyt z jeden:\t\t");
}
void set_2(){
digitalWrite(WA,LOW);
digitalWrite(WB,HIGH);
digitalWrite(WC,LOW);
//Serial.print("Odczyt z dwa:\t\t");
}
void set_3(){
digitalWrite(WA,HIGH);
digitalWrite(WB,HIGH);
digitalWrite(WC,LOW);
//Serial.print("Odczyt z trzy:\t\t");
}
void set_4(){
digitalWrite(WA,LOW);
digitalWrite(WB,LOW);
digitalWrite(WC,HIGH);
//Serial.print("Odczyt z cztery:\t\t");
}
void set_5(){
digitalWrite(WA,HIGH);
digitalWrite(WB,LOW);
digitalWrite(WC,HIGH);
//Serial.print("Odczyt z piec:\t\t");
}
void set_6(){
digitalWrite(WA,LOW);
digitalWrite(WB,HIGH);
digitalWrite(WC,HIGH);
//Serial.print("Odczyt z szesc:\t\t");
}
void set_7(){
digitalWrite(WA,HIGH);
digitalWrite(WB,HIGH);
digitalWrite(WC,HIGH);
//Serial.print("Odczyt z siedem:\t\t");
}
void res(){
digitalWrite(WA,LOW);
digitalWrite(WB,LOW);
digitalWrite(WC,LOW);
delay(5);
}
double get_voltage(){
long czas_start=millis();
long teraz=0;
int _max=0;
int pomiar=0;
while(teraz_max){
_max=pomiar;
}
}
return map(_max,0,1024,0,240)/sqrt(2); //obliczenie watości skutecznej
}
void loop() {
for(byte i=0;i