Chopping AC for AC motor Speed Control

I am working on a project of Speed Control of AC Induction Motor. I am using the circuit Shown below.

The circuit is working perfectly. I am getting Zero crosses at my interrupt pin 21 of Arduino Mega 2560. I am firing TRIAC using TRIAC Gate driver by sending gate pulses at pin 26. The motor speed changes too, but not like it should.
I measured the time between any two zeros and found it to be 9952 microsecs, doubling it and converting it to frequency, I got 50.24 Hz which makes sense as my circuit is connected to 240V 50Hz mains. So zero crosses are correctly received.
In my program, ‘time’ variable gives duration after any zero cross, at which we want to Chop off our AC.
By using delayMicroseconds(time); I make it pause for time microseconds and then fire the triac, so when value of time increases from 0 to 9952, the speed of motor should have decreased linearly but this is not case(I would not have then needed to post this, would I :slight_smile: ), The speed of the motor changes erraticly, it starts with 0 when time is 0 then it increases when time is about 4000-5000 and then it decreases to 0 when time is near 9900.
Please inform me if there is any problem in my code or what. I cannot use Oscilloscope to check how its AC is being chopped off as I dont have it. So do suggest me something else, Please help me.

#include <avr/io.h>
#include <avr/interrupt.h>

int LED=13;       //For Checking
int detectIpt=2;  //zero cross detect Interrupt number
int zeroCrossIptPin=21;//zero cross detection interrupt pin#
int gateTPin=26;  //Digital Pin for Gate Triggering

unsigned long time=0;
void setup()      // set up pins  
{  
  pinMode(zeroCrossIptPin, INPUT);    // Interrupt pin Mode 
  digitalWrite(21, HIGH); // pull up

  pinMode(LED, OUTPUT)  ;             // LED Pin Mode  
  pinMode(gateTPin, OUTPUT)  ;        // Gate Trigger Pin Mode
  digitalWrite(LED, LOW);
  digitalWrite(gateTPin, LOW); 
  //set up zero crossing interrupt
  attachInterrupt(detectIpt,zeroCrossingInterrupt, RISING);    
  //Calls zeroCrossingInterrupt on rising signal
  Serial.begin(9600);     // opens serial port,
}
void loop(){Serial.println(time);}
void zeroCrossingInterrupt()//zero cross detect   
{ 
    delayMicroseconds(time);
    digitalWrite(LED, HIGH);
    digitalWrite(gateTPin, HIGH);
    delayMicroseconds(200);
    digitalWrite(LED, LOW);
    digitalWrite(gateTPin, LOW);
    time1++;
  }

That's a very poor way to control the speed of a single phase induction motor, and may cause it
to overheat. Once the amount of slip increases beyond a small percentage the current will
rise dramatically.

Also trying to use a triac to switch a highly inductive load is not a great idea, since triacs switch
off at zero current, which for inductors will be at maximum voltage.

VFD is the correct way to control induction motors, VFDs vary the frequency and voltage in
proportion leading to the current / torque being roughly constant and low slip operation at
every speed.

I appreciate your concern mark, however VFD's are expensive so I can't use them. Secondly, I still don't have the answer I wanted i.e what's wrong with my program, why is it not working as it should? :frowning:

They you are probably stuck. For induction motor you use a VFD - your circuit works for universal
motors.

I recall that delay don't work in interrupt routine.
Try creating another function with codes of "zeroCrossingInterrupt()" and call this function from the interrupt routine.

http://www.engblaze.com/we-interrupt-this-program-to-bring-you-a-tutorial-on-arduino-interrupts/

Extracted from the above link:

Putting it all together

There are a few final things to keep in mind when implementing interrupts.

First, keep in mind that whatever you use your ISR for, it’s good practice to keep it short, because while the ISR is executing, it’s holding up the rest of your program. If you have lots of interrupts, this can slow things to a crawl. Also, by “the rest of your program”, we do mean everything: Arduino functions like millis() won’t increment, and delay() won’t work within an ISR.

"delay" doesn't, but "delayMicroseconds" does.

yes delayMicroseconds() is not the reason, the thing is firing takes place but not like it should, tell me what I don't know

tell me what I don't know

First, tell us what you do know.

legend4h:
tell me what I don't know

The astronomer Jeremiah Horrocks was born in Toxteth (which was then in Lancashire) in about 1618, and died aged only 22.

If you want to change the speed, you need to vary the frequency.

Maybe you should consider a different type of motor.

What is the application/ end result you want?

MarkT told you the problem.

Also trying to use a triac to switch a highly inductive load is not a great idea, since triacs switch
off at zero current, which for inductors will be at maximum voltage.

What you do is change the motor or the method of controlling it.
Your choice.

Using Frequency Drive is way too expensive for me, is there any way to vary frequency using arduino, do inform me

why is it not working as it should?

How do you think it "should" work ?

"Using Frequency Drive is way too expensive for me, is there any way to vary frequency using arduino, do inform me"

Yes, the arduino can vary frequency, but then the power drivers to present that to the motor will be way to expensive.

Use a DC motor.

Maybe I forgot, but what is this motor intended to do? What is the application?

The motor is used below de-Freezer and expels heat of heat exchager which is infront of it.
About How it should behave part, when I get a zero Interrupt, and I give pulse to Triac Gate driver with Just a microsec delay duration, the Triac should be fired at that time and motor should run at almost full speed but rather the motor is almost as if stopped or moving too slowly, When I give pulse with a delay of almost 4ms after zerocross, it runs at full speed even though its speed should be slow(half speed) at the moment(since This means chopping of AC signal at 90 degree or 270 deg phase angle.) At the end of 8 ms , just before the appearance of another zero, when I give pulse , it runs slow and it is only here that it works like it should since most of AC signal has been chopped off.

The motor is used below de-Freezer and expels heat of heat exchager which is infront of it.

As you've been told, use another type of motor, like DC or Universal.

pulse to Triac Gate driver with Just a microsec delay duration, the Triac should be fired at that time and motor should run at almost full speed

Check the spec's for your triac, the current through the triac is probably well below the holding current
and will turn off.

You didn't tell us the motor rating and type (CSCR, shaded pole etc).

Hi,

To clear up your understanding of Triac control.

In my program, 'time' variable gives duration after any zero cross, at which we want to Chop off our AC.

No No No, look at your graph diagrams..
You are not turning the Triac OFF, you are turning it ON, so it conducts for the rest of the half cycle and then turns off due to zero current flow.

And as everyone has said, VSD is really the only way to control your induction motor, especially for fan control if I understand your last post.

Tom.... :slight_smile:

Have the same project like this one but for a universal motor, still a work on progress.