Thanks, I see what your saying,
It will take me some study time to get a grasp on doing it the correct way, with Integrals etc so to keep the ball rolling so to speak I have tested my circuit & found that it appears to work really well.
I found a sketch & modified things to tune my circuit & I can get from 12V AC to 240V AC with the way I have it now, I have been playing around like a child dimming. flashing etc to see how it all works.
It will not go to 0V though.
It is giving me some indication of how this phase control works so it's not a waste of time at least.
I found that the cooling & heating time constant of the lamp glass is far to slow, in the sketch attached the Lamp will ramp or dim up & down & the glass temperature does not alter much at all.
I just quickly tested an LDR circuit & this can follow the light intensity up & down without an issue with a lot less delay in the sketch than shown. I think this may be the best bet to control the light intensity rather than the temperature of the lamp glass which is way to slow to respond.
I know it's rough but it works?
Cheers, see sketch below:
/*Modified Sketch:
Willeng 18/7/2014
Interupt Pin 2 Mega
*/
int TRIGGER_PULSE = 3; // Output to Opto Triac pin
int POWER = 128; // Power level (1-128) 1 = ON, 128 = OFF (1 = 240V AC & 128 = 12V AC with my circuit)
void setup()
{
pinMode(TRIGGER_PULSE, OUTPUT); // Set the Trigger Pulse as output:
attachInterrupt(0, zero_crosss_int, FALLING);
}
void zero_crosss_int() // function to be fired at the zero crossing:
{
// Firing angle calculation :: 50Hz-> 10ms (1/2 Cycle)
// (10000us - 10us) / 128 = 78 (Approx) (I am using 71 as this tunes my circuit better & can achieve full power down to 12V AC)
int power = (71*POWER);
delayMicroseconds(power); // Off cycle
digitalWrite(TRIGGER_PULSE, HIGH); // triac firing
delayMicroseconds(10); // triac On propogation delay
digitalWrite(TRIGGER_PULSE, LOW); // triac Off
}
void loop()
{
POWER = 115;
delay(10);
POWER = 105;
delay(75);
POWER = 95;
delay(75);
POWER = 85;
delay(75);
POWER = 75;
delay(75);
POWER = 65;
delay(75);
POWER = 55;
delay(75);
POWER = 45;
delay(75);
POWER = 35;
delay(75);
POWER = 25;
delay(75);
POWER = 15;
delay(75);
POWER = 1;
delay(75);
POWER = 15;
delay(75);
POWER = 25;
delay(75);
POWER = 35;
delay(75);
POWER = 45;
delay(75);
POWER = 55;
delay(75);
POWER = 65;
delay(75);
POWER = 75;
delay(75);
POWER = 85;
delay(75);
POWER = 95;
delay(75);
POWER = 105;
delay(75);
POWER = 115;
delay(75);
POWER = 128;
delay(10);
}