Quantcast
Channel: MSP430 Technical Forums
Viewing all articles
Browse latest Browse all 2077

Problems with interruption

$
0
0

i want to do a phase control with a lamp and my tiva, i copied this program

 

int AC_LOAD = PD_0; // Output to Opto Triac pin
int dimming = 115; // Dimming level (0-128) 0 = ON, 128 = OFF
 
void setup()
{
pinMode(PD_0, OUTPUT); // Set the AC Load as output
pinMode(PD_0, INPUT);
 
attachInterrupt(PD_0, zero_crosss_int, RISING); // Choose the zero cross interrupt # from the table above
}
 
void zero_crosss_int() // function to be fired at the zero crossing to dim the light
{
// Firing angle calculation :: 50Hz-> 10ms (1/2 Cycle)
// (10000us - 10us) / 128 = 75 (Approx)
int dimtime = (64*dimming); 
delayMicroseconds(dimtime); // Off cycle
digitalWrite(AC_LOAD, HIGH); // triac firing
delayMicroseconds(10); // triac On propogation delay
digitalWrite(AC_LOAD, LOW); // triac Off
}
 
void loop()
 
{
}
 
but when is running the light is flashing then i copied the same program to an arduino and it woks
 
int AC_LOAD = 8; // Output to Opto Triac pin
int dimming = 115; // Dimming level (0-128) 0 = ON, 128 = OFF
void setup()
{
pinMode(8, OUTPUT); // Set the AC Load as output
attachInterrupt(1, zero_crosss_int, RISING); // Choose the zero cross interrupt # from the table above
}
void zero_crosss_int() // function to be fired at the zero crossing to dim the light
 
{
 
// Firing angle calculation :: 50Hz-> 10ms (1/2 Cycle)
// (10000us - 10us) / 128 = 75 (Approx)
int dimtime = (64*dimming); 
delayMicroseconds(dimtime); // Off cycle
digitalWrite(AC_LOAD, HIGH); // triac firing
delayMicroseconds(10); // triac On propogation delay
digitalWrite(AC_LOAD, LOW); // triac Off
}
 
void loop()
{
}
 

i think that the problem its the interrupt because in the osciloscope shows disrupted signals and when i conected the arduino works fine

what is the problem?


Viewing all articles
Browse latest Browse all 2077

Trending Articles