i think this is my 3rd post on this topic.... But i need an urgent help.. I have done my program and had the output from arduino. I have problem that the firing point is faster then usual. . I am using a potentiometer to vary the pulse position... wen i start varying the potentiometer, the skips around 30 degrees. Eg, at 90 degree's of the sine.. i m getting 60 degrees displayed on my LCD... I have included the pic of my output pulse on 0 degrees.. I hope I can guided on this... this is my output pic and code...
#include <LiquidCrystal.h>
/*
The circuit:
*LCD RS pin to digital pin 8
*LCD Enable pin to digital pin 9
*LCD D4 pin to digital pin 4
*LCD D5 pin to digital pin 5
*LCD D6 pin to digital pin 6
*LCD D7 pin to digital pin 7
*LCD R/W pin to ground
*/
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
byte degree[8] = {
B00110,
B01001,
B01001,
B00110,
B00000,
B00000,
B00000,
};
int zcdPin = 0; //pin 2
int potPin = A0;
int sensorValue = 0;
int outputValue = 0;
int alpha;
int d;
int scrPin1 = 10;
int scrPin2 = 11;
void setup (){
lcd.begin (16, 2);
lcd.print("FYP 2012/2013");
lcd.createChar(1, degree);
attachInterrupt (0, ZCHandler, FALLING);
}
void loop (){
sensorValue = analogRead(potPin);
alpha = sensorValue/5.68;
d = (sensorValue*5)*1.955;
lcd.setCursor(0,1);
lcd.print("a:");
lcd.print(alpha);
lcd.write(1);
lcd.setCursor(8,1);
lcd.print("d:");
lcd.print(d);
lcd.print("ms");
}
void ZCHandler(){
digitalWrite(scrPin2, LOW);
delayMicroseconds(d);
digitalWrite(scrPin2, HIGH);
delayMicroseconds(1000);
digitalWrite(scrPin2, LOW);
}