Skip to main content
Non-breaking space before units, fixed units and removed thanks as per SE policy
Source Link
Greenonline
  • 3.2k
  • 7
  • 37
  • 49

The sample code is this:

Sample code for Edgar Bonet

I have questions. I need to integrate the analog sine wave of 60Hz60 Hz, this signal described in the next picture, adding an offset near 2.5v5 V, because I can damage the Arduino board with the negative signal cycle. Internally on the Arduino board, I remove this offset, multiplying by 2, and subtracting 1.

V1=analogRead(A0)*2/1023.0-1.0;

The sampling period must be at least fs=300hzfs=300 Hz, T=1/fs and V1 is the signal I need integrate.

What modifications can I make to Edgar Bonet's code?

Thank you very much.

enter image description hereSchematic and waveform

The sample code is this:

Sample code for Edgar Bonet

I have questions. I need to integrate the analog sine wave of 60Hz, this signal described in the next picture, adding an offset near 2.5v, because I can damage the Arduino board with the negative signal cycle. Internally on the Arduino board, I remove this offset, multiplying by 2, and subtracting 1.

V1=analogRead(A0)*2/1023.0-1.0;

The sampling period must be at least fs=300hz, T=1/fs and V1 is the signal I need integrate.

What modifications can I make to Edgar Bonet's code?

Thank you very much.

enter image description here

The sample code is this:

Sample code for Edgar Bonet

I have questions. I need to integrate the analog sine wave of 60 Hz, this signal described in the next picture, adding an offset near 2.5 V, because I can damage the Arduino board with the negative signal cycle. Internally on the Arduino board, I remove this offset, multiplying by 2, and subtracting 1.

V1=analogRead(A0)*2/1023.0-1.0;

The sampling period must be at least fs=300 Hz, T=1/fs and V1 is the signal I need integrate.

What modifications can I make to Edgar Bonet's code?

Schematic and waveform

Rollback to Revision 2
Source Link

The sample code is this:

Sample code for Edgar Bonet

Thank for everything. This is my new circuit for Arduino input. Considerably improved in the coupling of impedancesI have questions.

I must clarify certain things, my proyect is an Cosine-Mode Controller for SCR Converters, look the referense paper IEEE.

I need to integrate the analog sine wave of 60Hz, this signal described in the next picture, The op.amp isolates the mid-point voltage at the junction of R3 & R4 from the AC-AC adapter and voltage divider. This significantly reduces the impedance of the voltage source, resulting in enhanced performance.

Addingadding an offset near 2.5v, because I can damage the Arduino board with the negative signal cycle. Internally on the Arduino board, I remove this offset, multiplying by 2, and subtracting 1.

Vac_input=analogReadV1=analogRead(A0)*2/1023.0-1.0;

The sampling period must be at least fs=300hz, T=1/fs and V1 is the signal I need integrate.

And this is my oldWhat modifications can I make to Edgar Bonet's code,

unsigned long time1=0.0;
float Vac_input,Vb_integral,Valpha,Vc,Vd,Ve,Vf;
const float Vpeak_detector=1;
const float deltaT=0.1;
const float T=1.0e6/60.0;
float Vb_last; 
int time2=0,time3=0;

void setup() {
Serial.begin(9600);
pinMode(A0,INPUT);
pinMode(A1,INPUT);  
pinMode(12,OUTPUT);
pinMode(13,OUTPUT);

}

void loop() {

 deltaT=(micros()-time1);
time1=micros();  
  //Vac_input=sin(2*3.1416/T*micros());   //Asuming the sine wave

Vac_input=analogRead(A0)*2.0/1023.0-1.0; //Analog input

 //Vb_integral=cos(2*3.1416/T*micros());    // Asuming the integral

Vb_integral=(deltaT/1.0e6*Vac_input*377.0+Vb_last);

Vpeak_detector=1;// peak detector [P.D]
Vc=Vpeak_detector+Vb_integral;
Vd=Vpeak_detectord-Vb_integral;
Valpha=analogRead(A1)/1023.0*2; // control variable Valpha(potenciometer)
Vb_last=Vb_integral;

if (Vc>Valpha){
Ve=0;}else{Ve=1;time2=micros();}

if (Vd>Valpha){
Vf=0;}else{Vf=1;time3=micros();}

if (Ve==Vf){if(time2>time3){Ve=0;digitalWrite(13,LOW);Vf=1;digitalWrite(12,HIGH);}else{Ve=1;digitalWrite(13,HIGH);Vf=0;digitalWrite(12,LOW);}}else{
if(Ve==1){digitalWrite(13,HIGH);}else{digitalWrite(13,LOW);};
if(Vf==1){digitalWrite(12,HIGH);}else{digitalWrite(12,LOW);}}

}    

References

link of paper IEEE http://www.mediafire.com/file/nomyxva2w90dau2/Paper+IEEE.pdf?

Thank you very much. Thank you very much.

enter image description hereenter image description here

The sample code is this:

Sample code for Edgar Bonet

Thank for everything. This is my new circuit for Arduino input. Considerably improved in the coupling of impedances.

I must clarify certain things, my proyect is an Cosine-Mode Controller for SCR Converters, look the referense paper IEEE.

I need to integrate the analog sine wave of 60Hz, this signal described in the next picture, The op.amp isolates the mid-point voltage at the junction of R3 & R4 from the AC-AC adapter and voltage divider. This significantly reduces the impedance of the voltage source, resulting in enhanced performance.

Adding an offset near 2.5v, because I can damage the Arduino board with the negative signal cycle. Internally on the Arduino board, I remove this offset, multiplying by 2, and subtracting 1.

Vac_input=analogRead(A0)*2/1023.0-1.0;

The sampling period must be at least fs=300hz, T=1/fs and V1 is the signal I need integrate.

And this is my old code,

unsigned long time1=0.0;
float Vac_input,Vb_integral,Valpha,Vc,Vd,Ve,Vf;
const float Vpeak_detector=1;
const float deltaT=0.1;
const float T=1.0e6/60.0;
float Vb_last; 
int time2=0,time3=0;

void setup() {
Serial.begin(9600);
pinMode(A0,INPUT);
pinMode(A1,INPUT);  
pinMode(12,OUTPUT);
pinMode(13,OUTPUT);

}

void loop() {

 deltaT=(micros()-time1);
time1=micros();  
  //Vac_input=sin(2*3.1416/T*micros());   //Asuming the sine wave

Vac_input=analogRead(A0)*2.0/1023.0-1.0; //Analog input

 //Vb_integral=cos(2*3.1416/T*micros());    // Asuming the integral

Vb_integral=(deltaT/1.0e6*Vac_input*377.0+Vb_last);

Vpeak_detector=1;// peak detector [P.D]
Vc=Vpeak_detector+Vb_integral;
Vd=Vpeak_detectord-Vb_integral;
Valpha=analogRead(A1)/1023.0*2; // control variable Valpha(potenciometer)
Vb_last=Vb_integral;

if (Vc>Valpha){
Ve=0;}else{Ve=1;time2=micros();}

if (Vd>Valpha){
Vf=0;}else{Vf=1;time3=micros();}

if (Ve==Vf){if(time2>time3){Ve=0;digitalWrite(13,LOW);Vf=1;digitalWrite(12,HIGH);}else{Ve=1;digitalWrite(13,HIGH);Vf=0;digitalWrite(12,LOW);}}else{
if(Ve==1){digitalWrite(13,HIGH);}else{digitalWrite(13,LOW);};
if(Vf==1){digitalWrite(12,HIGH);}else{digitalWrite(12,LOW);}}

}    

References

link of paper IEEE http://www.mediafire.com/file/nomyxva2w90dau2/Paper+IEEE.pdf

Thank you very much.

enter image description here

The sample code is this:

Sample code for Edgar Bonet

I have questions. I need to integrate the analog sine wave of 60Hz, this signal described in the next picture, adding an offset near 2.5v, because I can damage the Arduino board with the negative signal cycle. Internally on the Arduino board, I remove this offset, multiplying by 2, and subtracting 1.

V1=analogRead(A0)*2/1023.0-1.0;

The sampling period must be at least fs=300hz, T=1/fs and V1 is the signal I need integrate.

What modifications can I make to Edgar Bonet's code?

Thank you very much.

enter image description here

deleted 36 characters in body
Source Link

The sample code is this:

Sample code for Edgar Bonet

Thank for everything. This is my new circuit for Arduino input. Considerably improved in the coupling of impedances.

I must clarify certain things, my proyect is an Cosine-Mode Controller for SCR Converters, look the referense paper IEEE. I don't need calculate the voltage.

I need to integrate the analog sine wave of 60Hz, this signal described in the next picture, The op.amp isolates the mid-point voltage at the junction of R3 & R4 from the AC-AC adapter and voltage divider. This significantly reduces the impedance of the voltage source, resulting in enhanced performance.

Adding an offset near 2.5v, because I can damage the Arduino board with the negative signal cycle. Internally on the Arduino board, I remove this offset, multiplying by 2, and subtracting 1.

Vac_input=analogRead(A0)*2/1023.0-1.0;

The sampling period must be at least fs=300hz, T=1/fs and V1 is the signal I need integrate.

And this is my old code,

unsigned long time1=0.0;
float Vac_input,Vb_integral,Valpha,Vc,Vd,Ve,Vf;
const float Vpeak_detector=1;
const float deltaT=0.1;
const float T=1.0e6/60.0;
float Vb_last; 
int time2=0,time3=0;

void setup() {
Serial.begin(9600);
pinMode(A0,INPUT);
pinMode(A1,INPUT);  
pinMode(12,OUTPUT);
pinMode(13,OUTPUT);

}

void loop() {

 deltaT=(micros()-time1);
time1=micros();  
  //Vac_input=sin(2*3.1416/T*micros());   //Asuming the sine wave

Vac_input=analogRead(A0)*2.0/1023.0-1.0; //Analog input

 //Vb_integral=cos(2*3.1416/T*micros());    // Asuming the integral

Vb_integral=(deltaT/1.0e6*Vac_input*377.0+Vb_last);

Vpeak_detector=1;// peak detector [P.D]
Vc=Vpeak_detector+Vb_integral;
Vd=Vpeak_detectord-Vb_integral;
Valpha=analogRead(A1)/1023.0*2; // control variable Valpha(potenciometer)
Vb_last=Vb_integral;

if (Vc>Valpha){
Ve=0;}else{Ve=1;time2=micros();}

if (Vd>Valpha){
Vf=0;}else{Vf=1;time3=micros();}

if (Ve==Vf){if(time2>time3){Ve=0;digitalWrite(13,LOW);Vf=1;digitalWrite(12,HIGH);}else{Ve=1;digitalWrite(13,HIGH);Vf=0;digitalWrite(12,LOW);}}else{
if(Ve==1){digitalWrite(13,HIGH);}else{digitalWrite(13,LOW);};
if(Vf==1){digitalWrite(12,HIGH);}else{digitalWrite(12,LOW);}}

}    

References

link of paper IEEE http://www.mediafire.com/file/nomyxva2w90dau2/Paper+IEEE.pdf

Thank you very much.

enter image description here

The sample code is this:

Sample code for Edgar Bonet

Thank for everything. This is my new circuit for Arduino input. Considerably improved in the coupling of impedances.

I must clarify certain things, my proyect is an Cosine-Mode Controller for SCR Converters, look the referense paper IEEE. I don't need calculate the voltage.

I need to integrate the analog sine wave of 60Hz, this signal described in the next picture, The op.amp isolates the mid-point voltage at the junction of R3 & R4 from the AC-AC adapter and voltage divider. This significantly reduces the impedance of the voltage source, resulting in enhanced performance.

Adding an offset near 2.5v, because I can damage the Arduino board with the negative signal cycle. Internally on the Arduino board, I remove this offset, multiplying by 2, and subtracting 1.

Vac_input=analogRead(A0)*2/1023.0-1.0;

The sampling period must be at least fs=300hz, T=1/fs and V1 is the signal I need integrate.

And this is my old code,

unsigned long time1=0.0;
float Vac_input,Vb_integral,Valpha,Vc,Vd,Ve,Vf;
const float Vpeak_detector=1;
const float deltaT=0.1;
const float T=1.0e6/60.0;
float Vb_last; 
int time2=0,time3=0;

void setup() {
Serial.begin(9600);
pinMode(A0,INPUT);
pinMode(A1,INPUT);  
pinMode(12,OUTPUT);
pinMode(13,OUTPUT);

}

void loop() {

 deltaT=(micros()-time1);
time1=micros();  
  //Vac_input=sin(2*3.1416/T*micros());   //Asuming the sine wave

Vac_input=analogRead(A0)*2.0/1023.0-1.0; //Analog input

 //Vb_integral=cos(2*3.1416/T*micros());    // Asuming the integral

Vb_integral=(deltaT/1.0e6*Vac_input*377.0+Vb_last);

Vpeak_detector=1;// peak detector [P.D]
Vc=Vpeak_detector+Vb_integral;
Vd=Vpeak_detectord-Vb_integral;
Valpha=analogRead(A1)/1023.0*2; // control variable Valpha(potenciometer)
Vb_last=Vb_integral;

if (Vc>Valpha){
Ve=0;}else{Ve=1;time2=micros();}

if (Vd>Valpha){
Vf=0;}else{Vf=1;time3=micros();}

if (Ve==Vf){if(time2>time3){Ve=0;digitalWrite(13,LOW);Vf=1;digitalWrite(12,HIGH);}else{Ve=1;digitalWrite(13,HIGH);Vf=0;digitalWrite(12,LOW);}}else{
if(Ve==1){digitalWrite(13,HIGH);}else{digitalWrite(13,LOW);};
if(Vf==1){digitalWrite(12,HIGH);}else{digitalWrite(12,LOW);}}

}    

References

link of paper IEEE http://www.mediafire.com/file/nomyxva2w90dau2/Paper+IEEE.pdf

Thank you very much.

enter image description here

The sample code is this:

Sample code for Edgar Bonet

Thank for everything. This is my new circuit for Arduino input. Considerably improved in the coupling of impedances.

I must clarify certain things, my proyect is an Cosine-Mode Controller for SCR Converters, look the referense paper IEEE.

I need to integrate the analog sine wave of 60Hz, this signal described in the next picture, The op.amp isolates the mid-point voltage at the junction of R3 & R4 from the AC-AC adapter and voltage divider. This significantly reduces the impedance of the voltage source, resulting in enhanced performance.

Adding an offset near 2.5v, because I can damage the Arduino board with the negative signal cycle. Internally on the Arduino board, I remove this offset, multiplying by 2, and subtracting 1.

Vac_input=analogRead(A0)*2/1023.0-1.0;

The sampling period must be at least fs=300hz, T=1/fs and V1 is the signal I need integrate.

And this is my old code,

unsigned long time1=0.0;
float Vac_input,Vb_integral,Valpha,Vc,Vd,Ve,Vf;
const float Vpeak_detector=1;
const float deltaT=0.1;
const float T=1.0e6/60.0;
float Vb_last; 
int time2=0,time3=0;

void setup() {
Serial.begin(9600);
pinMode(A0,INPUT);
pinMode(A1,INPUT);  
pinMode(12,OUTPUT);
pinMode(13,OUTPUT);

}

void loop() {

 deltaT=(micros()-time1);
time1=micros();  
  //Vac_input=sin(2*3.1416/T*micros());   //Asuming the sine wave

Vac_input=analogRead(A0)*2.0/1023.0-1.0; //Analog input

 //Vb_integral=cos(2*3.1416/T*micros());    // Asuming the integral

Vb_integral=(deltaT/1.0e6*Vac_input*377.0+Vb_last);

Vpeak_detector=1;// peak detector [P.D]
Vc=Vpeak_detector+Vb_integral;
Vd=Vpeak_detectord-Vb_integral;
Valpha=analogRead(A1)/1023.0*2; // control variable Valpha(potenciometer)
Vb_last=Vb_integral;

if (Vc>Valpha){
Ve=0;}else{Ve=1;time2=micros();}

if (Vd>Valpha){
Vf=0;}else{Vf=1;time3=micros();}

if (Ve==Vf){if(time2>time3){Ve=0;digitalWrite(13,LOW);Vf=1;digitalWrite(12,HIGH);}else{Ve=1;digitalWrite(13,HIGH);Vf=0;digitalWrite(12,LOW);}}else{
if(Ve==1){digitalWrite(13,HIGH);}else{digitalWrite(13,LOW);};
if(Vf==1){digitalWrite(12,HIGH);}else{digitalWrite(12,LOW);}}

}    

References

link of paper IEEE http://www.mediafire.com/file/nomyxva2w90dau2/Paper+IEEE.pdf

Thank you very much.

enter image description here

deleted 4 characters in body
Source Link
Loading
I made some adjustments to my question
Source Link
Loading
edited body; edited title
Source Link
dda
  • 1.6k
  • 1
  • 12
  • 18
Loading
Source Link
Loading