venkates2218
Full Member level 6
venkates2218, I think your problem is not understanding how triacs and SCRs work. Think of them as a switch you turn ON with a pulse at any time there is a voltage across them but you cannot turn them OFF again until the voltage across them has fallen to zero. You have gone through various stages of getting nearer to a solution but still miss the target.
In the original design you use an optocoupler with zero crossing detector, this will only let you turn the triac ON at the point the AC reverses polarity and it will remain ON for the whole cycle. In other words you get the effect you noticed, it was on or off but had no 'mid' setting.
You then changed to a non-zero crossing optocoupler which can trigger at any time, regardless of the voltage across it. That is slightly better because it lets you chop the AC waveform to reduce the effective power but without any synchronizm to the AC waveform it will trigger randomly. If you want to use that method, you have to decide the trigger pulse position as a delay from zero crossing but you have no voltage detector to do that. That method is normally called "Phase Control" rather than PWM because the position of the pulse decides the power, not its width.
In your last code, assuming you take the output to RB0 from the emitter of the optocoupler and you ground the bottom of the 1K resistor, you get a low pulse near to zero crossing so you need to make sure you interrupt on the rising edge of the signal. However you then try to control the triac period by generating a variable width pulse. As I stated, triacs don't work like that, as soon as you trigger it ("triac_1 = 1;") it turns ON and stays ON. The delay and line "triac_1 = 0;" have no effect whatsoever. If you want to do it by phase control the delay has to be between the zero crossing point and the trigger pulse so your code is like this:
The delay can be anything from zero (maximum power) to the period of one whole AC cycle (20ms for 50Hz, 16.6mS for 60Hz) for minimum power.Code:while (1) { if (zc == 1) { //zero crossing occurred DelayMs(your delay goes here) triac_1 = 1; triac_1 = 0; zc = 0; } }
As Treez pointed out, there is another way to do it but it can be very noisy and harsh on the motor, you can turn the triac on for whole cycles, then turn it off and wait a while before turning it on again. It is rather like turning full power on and off with a manual switch and relying on the drag/load on the motor to slow it down. In theory if you get the switch timing just right you can control the speed but the rapid burst of full power stresses the motor and the switch and tends to be unreliable.
Brian.
Tried the above circuit but there is no change in speed of the motor