Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] PIC controlled triac problem, device control card design

Status
Not open for further replies.

cagabit

Newbie level 4
Joined
Nov 4, 2014
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
137
Hi,


Designing a power control board, controlling various loads. Trying to make it universal as possible, targeted 16A max load only for switching and 5A for dimming with a triac.

Using XC8 v1.38, cpu as 18F25k22, using internal crystal and PLL with 64Mhz clock.

Also this board will make some measurements and energy calculations for various purposes.


General layout is as it is:
general-layout.jpg

The power supply part is as:
power-supply.jpg

There is 7805 regulator and 100nF + 100uF decoupling capacitors after the 12V output, to get 5V DC.



By code , using phase control driving the triac and controlling the load power. As expected with resistive loads it is all ok.

The delay, for testing is constant, changing every time, no dynamic part.

From B0-pin getting a INT0 and setting a delay according to the power level. Also for testing set a pin toggle and from the oscilloscope I see a square-wave with 20ms period, as expected for the 50Hz line.


When using inductive loads like a motor strange thing happens:

When there is no load or there is a resistive load the zero-cross interrupt pin signal is 10ms / 10ms as expected but when the there is the motor , it becomes something like 6ms / 14ms ! So the triac drive starts to make errors because hte zero cross is not ok.


At the time of the motor run, checked the B0 pin signal, it is ok 10ms/10ms square wave. So some noise should be affecting inside the PIC , the interrupt.

I know this should be definitely related to Analog-Digital ground thing, so tried to separate analog and digital ground ( from the power supply , 1N4007 actually connects them), or taking out the diode 1N4007 from the supply and putting a ferrite between grounds. No luck.

Measured the power supply of 5V, with oscilloscope, seems ok , low ripple like 50mV.


Then tired to measure the 5V-ground with the EARTH ( after isolating the oscilloscope ) , and the is a huge spike starting with 250V and getting smaller for 25usecs ! So I thing the motor load is affecting the ground reference of the PIC and since the zero-cross part is dependent of the diodes of the B0 port, and the reference ground is affected, the timing of zero-cross is changes.


Tried to put a transformer based power supply also, the problem only seem to happen for the starting 500msecs or so, after the motor is running the zero-cross signal is ok, but the problem is dont want to use transformer supply because of the space.


Stuck for days.

Any ideas ? Any opinion to test ?
 

Just to check whether it's just a GND symbol mismatching on your diagram or if it's a conceptual issue, but did you electrically connected the circuit GND reference to one of the phases of the electrical mains ? There should be the Earth instead the isolated ground. If this is the case, and was not the Neutral, the motor winding can be inducing noise from the electric bus to your board, enought to trigger the Triac.
 

Just to check whether it's just a GND symbol mismatching on your diagram or if it's a conceptual issue, but did you electrically connected the circuit GND reference to one of the phases of the electrical mains ? There should be the Earth instead the isolated ground. If this is the case, and was not the Neutral, the motor winding can be inducing noise from the electric bus to your board, enought to trigger the Triac.

Not sure exactly you referring to, but:
By ground actually referring to RETURN - NEUTRAL on mains, or (-) on power supply.

The motor is connected to the mains Neutral, also the power supply ! (which labelled AGRN in schematics )
The problem is that the triac is not triggered unexpectedly but rather the uP's interrupt is changing, so the zero-cross timing and so the triac timing ... But the input of the port B0 is ok ! The change happens inside the uP, when you turn on the motor.

Tried connecting both REF ( AGRN & DGRN ) :
  1. directly
  2. trough ferrite lead ( 80ohm)
  3. open (since it is connected from the diode on the power supply actually )
 

Your power supply provide insufficient electrical insulation by RETURN path to ensure that any disturbance in the electric mains will not interfere in your circuit; it's likely another source of problem. Anyway, are you rure that both the phase and neutral connections are not swapped ?
 

Hi,

I think there is no return path for voltage for voltage measurement and zero cross curcuit.

You measure mains voltage (referenced to AGRN) via R7 and R8 to U1, but U1 is only referenced to DGRN.

Klaus
 

VR1 is wired incorrectly and C3 must be a non-polarized type.

Any difference between AGRN and DGRN will be seen at the inputs to the PIC so both the voltage measurement and zero-crossing signals will not work as expected. You really need to look at alternative ways of connecting those signals or linking (safety warning!) the two GRN points together. I think my preference would be to optically link the ZC signal and either optically link the voltage input or do some AC to DC conversion on the AGRN side of the circuit and numerically couple the measurement to the PIC.

Brian.
 

A bit out of my depth here with power circuits but inductive loads mean the voltage leads the current. Are you actually measuring what you think you are measuring?
Susan
 

It doesn't measure the current so the phase relationship isn't relevant. The two inputs to the PIC are 'raw' AC for zero crossing detection and buffered waveform for voltage measurement. The problem is the PIC ground, and hence ADC, is not at the same potential as one side of the MAINS signal. Esentially, it's a floating measurement system with no zero reference.

Zero crossing could be derived from the op-amp output if the circuit would work instead of directly from the AC but if mid-waveform can't be determined anyway, that method can't be used here. Either isolated signals have to be sent to the PIC or the AGRN and DGRN points have to be linked together.

Brian.
 

Your power supply provide insufficient electrical insulation by RETURN path to ensure that any disturbance in the electric mains will not interfere in your circuit; it's likely another source of problem. Anyway, are you rure that both the phase and neutral connections are not swapped ?

Yes the main problem should be isolating ( at least to some point ) the return path of mains. Since also the PIC supply is working on mains, any disturbed signal is coming all the way to PIC also ! There are some designs limiting the current at NEUTRAL and directly connecting LIVE, especially on electric meter designs. But did not test here !

So yes I am sure the phase and neutral are in order.

Hi,

I think there is no return path for voltage for voltage measurement and zero cross curcuit.

You measure mains voltage (referenced to AGRN) via R7 and R8 to U1, but U1 is only referenced to DGRN.

Klaus

Yes, true. But as far as I can see from similar designs, since the impedance is too high ( the measurement circuit ) , when returning from DGRN making very little disturbance, I assumed.

VR1 is wired incorrectly and C3 must be a non-polarized type.

Any difference between AGRN and DGRN will be seen at the inputs to the PIC so both the voltage measurement and zero-crossing signals will not work as expected. You really need to look at alternative ways of connecting those signals or linking (safety warning!) the two GRN points together. I think my preference would be to optically link the ZC signal and either optically link the voltage input or do some AC to DC conversion on the AGRN side of the circuit and numerically couple the measurement to the PIC.

Brian.

The critic part is reading the Voltage, dont want to use a transformer, it is bulky. Need the AC signal because it is used for some other calculations ( Vrms, Power etc ). Read some AC opto's did not have the chance to test, but rather the price is not attractive as a matter of cost.

For the zero-cross , opto way, in my opinion spending more than a watt just for ZC is bad.

(I know I am criticizing all but trying to find the optimum way, please dont take it personal :) )

Zero crossing could be derived from the op-amp output if the circuit would work instead of directly from the AC but if mid-waveform can't be determined anyway, that method can't be used here. Either isolated signals have to be sent to the PIC or the AGRN and DGRN points have to be linked together.

Tried this also; from the output of the op-amp using another, tried to get a square wave fro zero-crossing, it is kind of success but the problem is, you cant get the exact midway ( by voltage divider or volt ref ) , maybe it is because the way DC coupled by a divider before the op-amp ! The resistors are not exact enough for this. There is a design using Vref and op-amp and DC biasing before this buffer op-amp , but did not tried yet.

Brian; I did connect AGRN and DGRN together ( noted above ), without success ! The disturbance still present.
 
Last edited by a moderator:

I think it's normal operation to get multiple zero crossings when switching inductive loads, or noise from other devices is present in your local mains. One possible means is low-pass filtering of input voltage, involved phase shift can be corrected. Or use a timer that blocks zero crossing interrupts for a certain time interval.

it becomes something like 6ms / 14ms
Does this mean your detector sees zero crossings near the middle of a half period? Or just that your software gets confused by multiple triggers after the first zero crossing?
 
I think it's normal operation to get multiple zero crossings when switching inductive loads, or noise from other devices is present in your local mains. One possible means is low-pass filtering of input voltage, involved phase shift can be corrected. Or use a timer that blocks zero crossing interrupts for a certain time interval.


Does this mean your detector sees zero crossings near the middle of a half period? Or just that your software gets confused by multiple triggers after the first zero crossing?

I dont have spectrum analyzer, but with oscilloscope as far as I can setup, there is no disturbance at the Input of the ZC , pin B0 ! But the output of it ( just put a pin toggle inside the interrupt routine ) is get disturbed. And this disturbance is only some shifting: before starting the motor, the output pin is 10ms/10ms square wave, after starting it again square but the ratio is around 6ms/14ms and does not change as far as the motor stays on.

Trying to test every idea, and come across an interesting thing:
I though that the REF of the PIC is shifting but it seems that the problem is with the OSC part ! I was using 64Mhz Fosc, with 16Mhz internal crsytal. When I turn off the PLL ( so the Fosc becomes 16Mhz) all ok !! It is not affected from the motor anymore. Tried to use external crystal with loading capacitors or trying to use other frequencies, not sure for now bu I believed that I should definitely concentrate on OSC part.
 

Hi,

Brian; I did connect AGRN and DGRN together ( noted above ), without success ! The disturbance still present.
I expected that connecting AGRN and DGRN should solve the problem (but gives new safety problems).

6ms/14ms for me looks like a DC shift in zero cross measurement. Can you measure zerocross voltage waveform at AVR input pin?
Or at least the DC voltage with 0V mains input voltage (L input and N input shorted together)

***
Your latest post makes me think if it is an EMC problem....

Klaus
 

Tried many things and could not find the real cause of this.

But for just to bypass this error implemented FvM's method, although not liked the way but seems to be working for now:

Or use a timer that blocks zero crossing interrupts for a certain time interval.

Since it is a mains signal the period is known, taking a safety margin of 48-52Hz timing, just disable the INT in the last one and by any means of a timer enable the INT again before little time to the next ZC.

Hoping that noise will not cause any other trouble, fingers crossed.

Thank you for everybody, for their ideas and contributions.
 

It doesn't measure the current so the phase relationship isn't relevant.
Sorry to bang on about this but the triac turns off when the current goes to zero. Therefore the PIC is measuring voltage to know when to turn the triac on but the triac will stay on for longer after the voltage goes back to zero.
This would explain the OPs comment that a resistive load works OK but the timing of an inductive load moves to have the triac conduction on for too long.
Susan
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top