Offline
Newbie
Karma: 0
Posts: 11
|
 |
« on: March 26, 2013, 11:24:33 pm » |
hi... i am using arduino due. i want to check the zero crossing of the AC waveform because i want to trigger six pulse thyristor. so i need zero crossing of the AC voltage.For that, i prepared a schmitt trigger which detects the zero crossing of the AC signal which gives me square wave then i put one diode so negative pulse is discard.so i am getting only positive square pulse.this pulse have maximum value is 3.0 volt.i am giving this pulse to analog pin A0.and i have written following code.
int pin2=2,pin3=3,pin4=4,pin5=5,pin6=6,pin7=7; int sensor=A0; void setup() { Serial.begin(115200); pinMode(pin2,OUTPUT); pinMode(pin3,OUTPUT); pinMode(pin4,OUTPUT); pinMode(pin5,OUTPUT); pinMode(pin6,OUTPUT); pinMode(pin7,OUTPUT); // put your setup code here, to run once:
} void loop() { int i,c; int d[15]; for(i=1;i<=15;i++) { d = analogRead(A0); Serial.println(d); d[0]= 1023; c=d-d[i-1]; Serial.println(c); if (c>0) { goto IRFAN; } } // put your main code here, to run repeatedly: IRFAN: while(1) { //Serial.println('c'); digitalWrite(pin7,LOW); digitalWrite(pin2,HIGH); delayMicroseconds(3333); digitalWrite(pin2,LOW); digitalWrite(pin3,HIGH); delayMicroseconds(3333); digitalWrite(pin3,LOW); digitalWrite(pin4,HIGH); delayMicroseconds(3333); digitalWrite(pin4,LOW); digitalWrite(pin5,HIGH); delayMicroseconds(3333); digitalWrite(pin5,LOW); digitalWrite(pin6,HIGH); delayMicroseconds(3333); digitalWrite(pin6,LOW); digitalWrite(pin7,HIGH); delayMicroseconds(3333); } } i am taking difference of two values d and d[i-1] so i can trigger all thyristor very accurately.but when i am uploading this program, DSO is not showing me exact zero cross. i am not getting pulse at exact zero cross it is slowly moving with respect to AC waveform.so please suggest me what can i do?
|