Zero Crossing

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Derrihj
Posts: 61
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 12 times
Been thanked: 3 times
Contact:

Zero Crossing

Postby Derrihj » Thu Aug 01, 2019 12:48 am

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.
Attachments
Zero Crossing Triac Firing_Dimmer.fcfx
(14.75 KiB) Downloaded 30 times

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8440
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2412 times
Been thanked: 3450 times
Contact:

Re: Zero Crossing

Postby medelec35 » Thu Aug 01, 2019 3:29 pm

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.
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

Derrihj
Posts: 61
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 12 times
Been thanked: 3 times
Contact:

Re: Zero Crossing

Postby Derrihj » Thu Aug 01, 2019 4:38 pm

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.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8440
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2412 times
Been thanked: 3450 times
Contact:

Re: Zero Crossing

Postby medelec35 » Thu Aug 01, 2019 5:40 pm

Do you have a schematic of your microcontroller connected to the AC of side the microscope?
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

Derrihj
Posts: 61
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 12 times
Been thanked: 3 times
Contact:

Re: Zero Crossing

Postby Derrihj » Thu Aug 01, 2019 7:06 pm

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.
Attachments
IMG_20190801_225023.jpg
IMG_20190801_225023.jpg (91.48 KiB) Viewed 1276 times

Derrihj
Posts: 61
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 12 times
Been thanked: 3 times
Contact:

Re: Zero Crossing

Postby Derrihj » Fri Aug 02, 2019 1:27 pm

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.
Attachments
Zero Crossing REVB.fcfx
(15.05 KiB) Downloaded 33 times

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8440
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2412 times
Been thanked: 3450 times
Contact:

Re: Zero Crossing

Postby medelec35 » Fri Aug 02, 2019 9:20 pm

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.
These users thanked the author medelec35 for the post:
Derrihj (Fri Aug 02, 2019 10:38 pm)
Rating: 5.26%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

Derrihj
Posts: 61
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 12 times
Been thanked: 3 times
Contact:

Re: Zero Crossing

Postby Derrihj » Fri Aug 02, 2019 10:39 pm

Thanks medelec35 i will be waiting for your circuit too.

Derrihj
Posts: 61
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 12 times
Been thanked: 3 times
Contact:

Re: Zero Crossing

Postby Derrihj » Sat Aug 03, 2019 12:57 am

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.

jgu1
Posts: 1097
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1000 times
Been thanked: 255 times
Contact:

Re: Zero Crossing

Postby jgu1 » Sat Aug 03, 2019 6:52 am

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.

johnsondav
Posts: 186
Joined: Thu Jun 28, 2012 7:29 pm
Location: Durham
Has thanked: 92 times
Been thanked: 181 times
Contact:

Re: Zero Crossing

Postby johnsondav » Sat Aug 03, 2019 11:45 am

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.19 KiB) Downloaded 43 times
These users thanked the author johnsondav for the post (total 2):
medelec35 (Sat Aug 03, 2019 4:32 pm) • chipfryer27 (Sat Aug 03, 2019 6:45 pm)
Rating: 10.53%
 

User avatar
Steve001
Valued Contributor
Valued Contributor
Posts: 1086
Joined: Wed Dec 31, 2008 3:37 pm
Has thanked: 440 times
Been thanked: 492 times
Contact:

Re: Zero Crossing

Postby Steve001 » Sun Aug 04, 2019 8:15 pm

Hi all,

Another zero crossing here if you are interested.

https://www.matrixtsl.com/mmforums/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-what-is-a-vfd-line-reactor/

https://literature.rockwellautomation.com/idc/groups/literature/documents/wp/drives-wp016_-en-p.pdf

Steve
These users thanked the author Steve001 for the post (total 3):
medelec35 (Sun Aug 04, 2019 9:53 pm) • jgu1 (Sun Aug 11, 2019 3:18 pm) • EtsDriver (Sun Aug 11, 2019 10:31 pm)
Rating: 15.79%
 
Success always occurs in private and failure in full view.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8440
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2412 times
Been thanked: 3450 times
Contact:

Re: Zero Crossing

Postby medelec35 » Sun Aug 04, 2019 9:55 pm

Hi Derrihj,
You have a missed part of the circuit out.
Can you also include the +5V supply to the microcontoller?
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

Derrihj
Posts: 61
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 12 times
Been thanked: 3 times
Contact:

Re: Zero Crossing

Postby Derrihj » Mon Aug 05, 2019 2:07 pm

OK my circuit worked very well but i made some changes on it and in the code too and its working fine.
These users thanked the author Derrihj for the post:
medelec35 (Mon Aug 05, 2019 2:55 pm)
Rating: 5.26%
 

jgu1
Posts: 1097
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1000 times
Been thanked: 255 times
Contact:

Re: Zero Crossing

Postby jgu1 » Sun Aug 11, 2019 3:18 pm

Hi Steve!

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

Thank`s

Br Jorgen
These users thanked the author jgu1 for the post:
Steve001 (Tue Aug 13, 2019 12:53 pm)
Rating: 5.26%