Page 1 of 1

Zero Crossing

Posted: Thu Aug 01, 2019 12:48 am
by Derrihj
Hi there please i need your help am trying to design a dimmer circuit for some microscope 12vac 3Amp Light bulb,am planing on using phase angle control.This is my circuit discription: Ac mains 220vac through two resistors 47k one on neutral side another one on live side is suplied to a bridge made of 4 diodes IN4007,the output is fed to PC817 Opto for AC mains isollation,pin 4 of PC817 to GND and pin 5 of PC817 to pin 5(PORTA2) of PIC12F683 microcontroller which is the INT0 pin and this INT0 pin is connected to +5v through 10k resistor for an external interrupt detection on its falling edge,PIN 6(PORTA1) is connected to a 10k POT with an intention to change the output siginal to the input of the DIAC MOC3021 to dim its inside LED which Diac output drives the outside gate of the triac BT139 which triac has 12v AC on its MT2 to output it to MT1 when trigered.i have written part of the code and in simulation ive represented zero crossing with an active low button that when pressed an LED connected to pin 7(PORTA0) is turned on to show DIAC ON SIGINAL i have used 2 seconds for it2 ON TIME in simulation sothat i can see its reaction but in real circuit it will be smaller say arround 250us.the help am looking for here is on the 10k pot, how do i code it that i can dim the output triac inorder to dim the 12v 3Amp bulb connected to its MT1?i have attached my code below please help coz i need this project for my Dad's microscope to suplise him as soon as he gets back from his business trip.

Re: Zero Crossing

Posted: Thu Aug 01, 2019 3:29 pm
by medelec35
Hi Derrihj,
If it was me I would use a FET rather than a triac.
With a triac, you are delaying the waveform to the gate so it switches on sometime during the positive and negative 1/2 cycles.
The triac will then switch off as the AC waveform goes towards zero since the current is reduced beyond the holding current.
This puts a strain on the bulb as its lighting from cold at a high +ve or -ve voltage depending on how much the waveform is delayed going into the gate.
If you use a bridge rectifier, the +ve and -ve is connected to a FET.
Then if the FET shorts the bridge rectifier, there is a low AC path across the two ACs of the bridge rectifier.
Therefore the bulb can be turned on at the start of AC waveform and turned off after a period of time.
E.g after 5ms and bulb will be at half brightness, but there is less stress on it.
I can help you with a circuit if you are interested?
In your flowchart, you are calling the interrupt macro.
You can't do that.
Only the interrupt is allowed to call the macro.
I will take a better look at the flowchart when I get more time.

Re: Zero Crossing

Posted: Thu Aug 01, 2019 4:38 pm
by Derrihj
Yes please i want to learn please help me with full circuit of how its done and full code with pot regulation so that i build the circuit and test it this will be good to me.Thanks God Bless u.

Re: Zero Crossing

Posted: Thu Aug 01, 2019 5:40 pm
by medelec35
Do you have a schematic of your microcontroller connected to the AC of side the microscope?

Re: Zero Crossing

Posted: Thu Aug 01, 2019 7:06 pm
by Derrihj
No what i had wanted in the first place was to control the time between the zero cross and the firing pulse to the triac gate by the Random Phase Driver, THE Diac (MOC3021) signal from the PIC12F683.The bigest intention was to read the value of the 10k pot one side of it connected to +5v and the other to GND and the middle pin to analog input of 12F683 and then map its value between 1ms to 10ms delay to provide the triac gate signal delay after the natural line commutation (Zero Crossing).I was to connect 12vac 3Amp to MT2 of driven triac BT139 and connect a 12vac 3amp Bulb to MT1 of BT139.So, that was my plan and its the code i was looking for but then u came up with a better idea so am just waiting for your design sothat a learn new techinics basically thats what am looking for so u can make your design based on that.so generally ac 220v mains is to go to bridge diode thru two 47k one to N and another to L then its output + & - to input of PC817 then also ac mains to be connected to a 3Amp 220 - 12vac stepdown transformer then output of PC817 pin 4 to GND pin 5 to int0 pin of 12F683 which pin has a 10k resistor to +5v, then 10k pot to any anolog input of 12F683 then any other pin of 12F683 to Diac +ve input pin 1 thru 100 ohms resistor and its pin 2 to GND and then pin 4 of MOC3021 to gate of triac BT139 then MT2 of triac to one end of 12vac transformer secondary and a 20 or 22 ohm resistor from MT2 of triac to pin 6 of MOC3021 besically a 2W resistor and MT1 to one terminal of bulb and the other terminal of bulb to other side of transformer secondary.so that is it. Thank you sir.

Re: Zero Crossing

Posted: Fri Aug 02, 2019 1:27 pm
by Derrihj
Sir i have recoded my program i would like you to go through it and see if it works.I have added a small delay of 2ms right after zero crossing occured and maped my 10k pot to create a delay to the triac gate firing pulse between 1ms to 7ms.Please see if it works now.Thank you once again I LOVE LEARNING.

Re: Zero Crossing

Posted: Fri Aug 02, 2019 9:20 pm
by medelec35
Hi Derrihj,
The circuit I have is for FET controlling of a 230V AC motor.
Motor runs far quieter than if controlled via a triac.
I will see if I can adapt the circuit for the much lower voltage of the light bulb.

I have just looked at your Flowchart.
It looks like it should work with the Bridge and opto.

Re: Zero Crossing

Posted: Fri Aug 02, 2019 10:39 pm
by Derrihj
Thanks medelec35 i will be waiting for your circuit too.

Re: Zero Crossing

Posted: Sat Aug 03, 2019 12:57 am
by Derrihj
But in my case what do u think should be the gate resistor value connected from MT2 of BT139 to pin 6 of MOC3021? and how do they calculate its value.

Re: Zero Crossing

Posted: Sat Aug 03, 2019 6:52 am
by jgu1
Hi Martin!

Sorry Derrijh for the break in, I Will do it short and not disturb any more :wink: .

Martin you tell that you have a diagram for a 230v motor driver with FET. I am really interested to have a look If you will share please. I have a case where I use a frequency inverter for driving a 3phase motor, But it make to much noise.

Br Jorgen.

Re: Zero Crossing

Posted: Sat Aug 03, 2019 11:45 am
by johnsondav
Hi Everyone

Hope you do not mind me joining your conversation. I have a circuit here that I used for a PID controller. It comprises a H11A1M zero detect chip that turns on only at the zero-crossing point via T1. However, this needs some extra control to produce something that fits a PIC controller. The NE555 generates a 1ms pulse, but will not trigger again until the next zero cross point is reached. This makes counting the 50Hz waveform a breeze and frees up PIC time to do the things you want. This will give you 100 pulses every second (10ms apart). You can also use the output to trigger your TRIAC under PIC control. You can also use some maths to calculate power output based upon the pulses counted or when the TRIAC is turn on. I am sure you can extract the relevant bits you need.

Here is the circuit:
Power & zero Cross 1ms pulse circuit.pdf
(48.08 KiB) Downloaded 290 times

Re: Zero Crossing

Posted: Sun Aug 04, 2019 8:15 pm
by Steve001
Hi all,

Another zero crossing here if you are interested.

viewtopic.php?f=54&t=16363&hilit=zero+crossing#p67589

PS there are pics that do have zero crossing detection built in.

Just a suggestion dont want to confuse the issue.
why not use DC and a fet ? and PWM - this elevates the latch current issues that martin described above. You may see the bulb appear to be "flickering" not good if you looking through a microscope.

@ Jorgen

3 phase motor invertors use fet's / igbt's in the output stages and they do sound horrible especially at low speed.
Have a look at 3 phase line reactors and put one in the output to the motor
This will reduce the dv/dt motor spikes and the motor temperature and noise

https://www.motioncontroltips.com/faq-w ... e-reactor/

https://literature.rockwellautomation.c ... _-en-p.pdf

Steve

Re: Zero Crossing

Posted: Sun Aug 04, 2019 9:55 pm
by medelec35
Hi Derrihj,
You have a missed part of the circuit out.
Can you also include the +5V supply to the microcontoller?

Re: Zero Crossing

Posted: Mon Aug 05, 2019 2:07 pm
by Derrihj
OK my circuit worked very well but i made some changes on it and in the code too and its working fine.

Re: Zero Crossing

Posted: Sun Aug 11, 2019 3:18 pm
by jgu1
Hi Steve!

First seen your reply now. Thank you for the tip. I Will read your att.

Thank`s

Br Jorgen