Searching \ for '[EE]: dimmer with pic can't make it work' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'dimmer with pic can't make it work'.

Exact match. Not showing close matches.
PICList Thread
'[EE]: dimmer with pic can't make it work'
2001\02\14@160158 by Andre Abelian

picon face
part 1 723 bytes content-type:text/plain; (decoded 7bit)

Hi to all engineers.

I am making a simple light dimmer for my kids and
I am having hard time to make it work with a triac.
I am using pic16c72 hardware pwm , MOC3010, and Power triac.
The pic works fine I checked it with scope when I connect it
thru opto triac the lamp suppose to turn on low and go higher brightness
all I see while PWM goes from 0-70 % blinks a few times
and stays on on higher duty cycle for load I use regular 110 v lamp.
when I connect any LED on PIC output I can see it slowly increases
the brightness I am not sure if same thing happening inside of MOC3010.
I do not know what is wrong with it any help will highly appreciated.
attached is the schematic.

Andre


part 2 8753 bytes content-type:application/octet-stream; (decode)

part 3 136 bytes
--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spam_OUTlistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body


2001\02\14@171849 by Eisermann, Phil [Ridg/CO]

flavicon
face
Uh, you cannot use PWM to control an AC lightbulb (at least not the same way
you can PWM a DC LED).

Traditionally, you should delay the phase angle at which the triac fires.Use
the PIC to detect when the AC line goes to zero. Then have a variable delay
that turns on the optoisolator after you detect the zero-crossing. The
longer the delay, the dimmer the bulb. You might want to search the web for
some application notes. there are plenty of example circuits out there.

I suppose you could use PWM if you make the period very slow in relationship
to the frequency of your line voltage. maybe 10 cycles? That would be
200msec. The idea is to turn the lightbulb on for a few cycles, then off for
a few cycles. I have no idea what effect this would have on the life of the
bulb, or if it would produce noticeable flickering. You'd still want to
measure the zero-crossing point.

I'll be happy to explain more off-list.

{Original Message removed}

2001\02\14@180634 by Olin Lathrop

face picon face
> all I see while PWM goes from 0-70 % blinks a few times
> and stays on on higher duty cycle for load I use regular 110 v lamp.

Remember that the triac will stay on once it is triggered until the next
power line zero crossing.  You need to synchronize the control signal to the
power line.


*****************************************************************
Olin Lathrop, embedded systems consultant in Devens Massachusetts
(978) 772-3129, .....olinKILLspamspam@spam@embedinc.com, http://www.embedinc.com

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservspamKILLspammitvma.mit.edu with SET PICList DIGEST in the body


2001\02\14@190424 by Russell McMahon

picon face
> I am making a simple light dimmer for my kids and
> I am having hard time to make it work with a triac.
> I am using pic16c72 hardware pwm , MOC3010, and Power triac.
> The pic works fine I checked it with scope when I connect it
> thru opto triac the lamp suppose to turn on low and go higher brightness
> all I see while PWM goes from 0-70 % blinks a few times
> and stays on on higher duty cycle for load I use regular 110 v lamp.
> when I connect any LED on PIC output I can see it slowly increases
> the brightness I am not sure if same thing happening inside of MOC3010.

Andre,

The circuit LOOKS OK in principle but is a bit marginal in design..
Bear in mind that the MOC3010 has a worst case drive requirement of 15 mA
You must design for the worst case for reliable operation.

Taking a random PIC 16xx family data sheet the spec says Vout lo will be
0.6v at 8.5mA. It's not linear but assume say 1.2volts at 15 to 20 mA.
The opto LED will drop around 1.5 volts probably
(Measure actual opto LED voltage drop when 100% on to see.)
I'm assuming a 5 volt Vcc.
(If Vcc is 3 volts you have no show :-) )
With a 220r as shown  the driving voltage = Vcc -1.2 - 1.5 = 2.3v
The current will then be about 2.3/220r ~= 10mA
This is 33% less than the 15 mA spec for the opto couplers guaranteed on
current.

Clearly the exact values will vary from those above (opto drop won't be 1.5v
and PIC low voltage will vary dynamically with current) but this shows that
the design is at best marginal.

My experience with MOC family optos is that they may well required the
guaranteed current to work. I use MOC3041s (which have zero crossing
switching) and these demand all of 15 mA to switch well. As the devices are
probably batch selected on test by the manufacturer (with better performing
parts getting a different part number) this pretty much guarantees that you
won't get lucky and get a good much better performing part than expected.

I would test the above as follows -

1.    Ground cathode of Opto LED - this will give ABOUT 15 mA - does lamp
light fully?

2.    If not, replace 220r with 100r and repeat 1. above.
       If lamp does NOT now light fully there is something else wrong.

3.    If 2 OK now try with PIC PWM. Does it work?

4    You COULD try with PIC and replacing 220r with a short circuit.
       This is "naughty" but PIC will (usually :-) ) survive such treatment
and if this doesn't work then PIC just hasn't got what it takes.
       If so, a simple transistor buffer may be needed to get enough
current drive.



     Russell McMahon
_____________________________

What can one man* do?
Donate food daily free !!! -  http://www.thehungersite.com/
Donate Vitamin A!  http://www.thechildsurvivalsite.com/
http://www.rawa.com  - one perspective on Afghanistan
http://www.changingourworld.com    http://www.easttimor.com   http://www.sudan.com

(* - or woman, child or internet enabled intelligent entity :-))

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email .....listservKILLspamspam.....mitvma.mit.edu with SET PICList DIGEST in the body


2001\02\14@192843 by Andre Abelian

picon face
Olin,

I assume power ( HOT ) thru 4,7Meg  resister should be connected to
one of pic pin then how do I synchronize it. I still do not clearly picture
it. Thanks for your help.

Andre



> > all I see while PWM goes from 0-70 % blinks a few times
> > and stays on on higher duty cycle for load I use regular 110 v lamp.
>
> Remember that the triac will stay on once it is triggered until the next
> power line zero crossing.  You need to synchronize the control signal to
the
{Quote hidden}

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email @spam@listservKILLspamspammitvma.mit.edu with SET PICList DIGEST in the body


2001\02\14@194225 by Herbert Graf

flavicon
face
> I am making a simple light dimmer for my kids and
> I am having hard time to make it work with a triac.
> I am using pic16c72 hardware pwm , MOC3010, and Power triac.
> The pic works fine I checked it with scope when I connect it
> thru opto triac the lamp suppose to turn on low and go higher brightness
> all I see while PWM goes from 0-70 % blinks a few times
> and stays on on higher duty cycle for load I use regular 110 v lamp.
> when I connect any LED on PIC output I can see it slowly increases
> the brightness I am not sure if same thing happening inside of MOC3010.
> I do not know what is wrong with it any help will highly appreciated.
> attached is the schematic.

    Umm, I think your problem is you can't use PWM with a triac. A Triac
will stay on until the current going through it goes to zero (i.e.. a zero
crossing). Usually dimming is done using phase delay triggering. The longer
you delay triggering after a zero crossing the less average power delivered
to the bulb, this is how many dimmers work (unfortunately it suffers from
alot of EMI if not designed and shielded well). The ones you can buy for a
few dollars usually consist of a variable resister, a capacitor (which with
the resistor creates a voltage divider with adjustable phase as well), a
diac (so the triac doesn't get triggered with the few volts it needs to be
triggered) and a triac. To implement this with a PIC simply detect zero
crossings, delay a while and then trigger the triac, it will shut itself off
again at the next zero crossing. Hope this helped. TTYL

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email KILLspamlistservKILLspamspammitvma.mit.edu with SET PICList DIGEST in the body


2001\02\15@011345 by Russell McMahon

picon face
> I assume power ( HOT ) thru 4,7Meg  resister should be connected to
> one of pic pin then how do I synchronize it. I still do not clearly
picture
> it. Thanks for your help.

My comments re driving levels being too low for the optocoupler used still
apply but I didn't read your comments on driving closely enough - as noted
by others, random PWM to an AC  bulb will lead to unexp3cted results. I
stsill suspect a major problem is the amount of drive.

To detect zero crossing you CAN use a high value resistor bweteen mains and
a PIC pin but this is EXTREMELY unwise for safety reasons - especially where
your family is potentially (pun only slightly intended) being connected to
the other end.
Much safer is to use a second opto coupler to detect mains zero crossing

Phase ----RRRRR---|>|-----Neutral
                               |        |
                               --|<|--  Opto diode.

This requires a high voltage capable R of suitable rating. Using a mains
rated capacitor in series with the opto (and a resistor as well) will give
less power dissipation. There are other ways to get mains zero crossing info
such as small step down transformer, current transformer using a toroid etc.
Using an opto with zero crossing function built in will make the task easier
again.

If you DO use a high value R directly from mains you must make sure that all
low voltage parts are treated as if at mains potential and be SURE that the
resistor will withstand mains voltage - ideally use two in series with each
mains rated.


ST electronics have an app note for the ST6 used as a mains lamp dimmer and
no doubt many other people do too.


regards



           Russell McMahon

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu


2001\02\15@020804 by Nigel Goodwin

flavicon
face
In message <001f01c096cd$c6d3b840$b2bcb2d1@engine2000>, Andre Abelian
<spamBeGoneengelecspamBeGonespamEARTHLINK.NET> writes
>Hi to all engineers.
>
>I am making a simple light dimmer for my kids and
>I am having hard time to make it work with a triac.
>I am using pic16c72 hardware pwm , MOC3010, and Power triac.
>The pic works fine I checked it with scope when I connect it
>thru opto triac the lamp suppose to turn on low and go higher brightness
>all I see while PWM goes from 0-70 % blinks a few times
>and stays on on higher duty cycle for load I use regular 110 v lamp.
>when I connect any LED on PIC output I can see it slowly increases
>the brightness I am not sure if same thing happening inside of MOC3010.
>I do not know what is wrong with it any help will highly appreciated.
>attached is the schematic.

You can't fed a triac with a PWM output, you have to adjust the point on
each mains cycle that you trigger the triac. Basically you need to
detect the zero-crossing point of each mains half cycle, then delay
before triggering the triac - the shorter the delay the brighter the
lamp (being careful not to delay longer than one half cycle).
--

Nigel.

       /--------------------------------------------------------------\
       | Nigel Goodwin   | Internet : TakeThisOuTnigelgEraseMEspamspam_OUTlpilsley.co.uk           |
       | Lower Pilsley   | Web Page : http://www.lpilsley.co.uk       |
       | Chesterfield    | Official site for Shin Ki and New Spirit   |
       | England         |                 Ju Jitsu                   |
       \--------------------------------------------------------------/

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestspamTakeThisOuTmitvma.mit.edu


2001\02\15@091639 by M. Adam Davis

flavicon
face
Andre, TRIACs work differently, you cannot use a PWM signal to drive a
triac.

Check out my page on Phase Controlled Dimming, which is what you'll need
to understand in order to build an AC line dimmer.

http://ubasics.com/adam/electronics/doc/phasecon.shtml

I hope this helps!

-Adam

> {Original Message removed}

2001\02\15@101053 by Olin Lathrop

face picon face
> I assume power ( HOT ) thru 4,7Meg  resister should be connected to
> one of pic pin then how do I synchronize it. I still do not clearly
picture
> it.

There has been a great deal of discussion recently about how to feed the
power signal into a PIC.  Check the archives.

Once you know what the power line is doing, you have to fire the triac at
the right times knowing it will turn off by itself at the next zero
crossing.


*****************************************************************
Olin Lathrop, embedded systems consultant in Devens Massachusetts
(978) 772-3129, olinEraseMEspam.....embedinc.com, http://www.embedinc.com

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspammitvma.mit.edu


2001\02\15@104627 by Harold M Hallikainen

picon face
       It sounds like you're using the PIC PWM output, which is not
synchronized with the AC power line. You need to detect zero cross, then
fire the triac a certain time into the half cycle to use AC line phase
control. You can't just randomly turn on the triac without getting
flashing lights.

Harold


On Wed, 14 Feb 2001 13:33:29 -0800 Andre Abelian <RemoveMEengelecEraseMEspamEraseMEEARTHLINK.NET>
writes:
{Quote hidden}

________________________________________________________________
GET INTERNET ACCESS FROM JUNO!
Juno offers FREE or PREMIUM Internet access for less!
Join Juno today!  For your FREE software, visit:
dl.http://www.juno.com/get/tagj.

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestspam_OUTspamKILLspammitvma.mit.edu


2001\02\15@141731 by Bob

flavicon
face
If your connecting the PIC to the live AC line, I suggest you use "two" 2.5Mohm
resistors in series, and maybe another two from there to ground (setup as a
voltage divider).  You'll also need to use B4 through B7 as your interrupt pin
(make sure the internal pull-up resistor is off, which should be the default I
think).  Make sure your using resistor rated high enough (most are only 100v
rating).

If you want to use B0, you'll need to fully rectify the AC first (0 to 170 "DC"
waveform), then feed it through two 2.5Mohm resistors, and I've found that
you'll have to voltage divide it by using another two 2.5Mohm resistors to
ground.  Obviously, you'll have to use a falling edge interrupt.  Be aware, that
the interrupt happens about 20 to 32us before the "actual zero crossing" event
occurs (adjust timing accordingly).  This is a bit better, as then you don't
have to worry if the wall outlet/plug strip/etc.. your plugged into is wired up
correctly (polarity insensitive).

Either way, you'll get an interrupt every 8333us on a 60hz line, and every
10,000us on a 50hz line.  Read the data sheet on the PIC your using to find out
how to setup & clear the appropriate interrupts.

Remember, in this configuration, EVERYTHING on the circuit should be considered
at line potential.  Choose/build your circuit interface and housing (plastic
box, plastic tactile buttons, or plastic body potentiometer w/ plastic knob,
etc) accordingly.

PIC port (B0 or B4 Thru B7)
|
|    2.5M     2.5M
|__/\/\/\/\__/\/\/\/\___Ground
|
|    2.5M     2.5M
|__/\/\/\/\__/\/\/\/\___Hot DC or AC


If your already using a transformer to power your PIC (like a 120VAC to 12VAC,
and then through a filter cap and regulator), you could also use the AC or DC
output side of that (for DC ZC, put another diode between the positive side of
the filter cap and the bridge, and feed a resistor to the PIC port from between
the bridge and that diode).  Obviously, the lower output voltage of the
transformer will cause you to detect the ZC even earlier (again, adjust your
timing accordingly).

You can use TMR1 to turn on/off a CCP pin, when it matches the CCP register pair
(calculated and set, in your main routine), to turn on your triac opto.  You can
then turn it off, as the first thing you do after saving critical registers, in
your zero crossing interrupt (works for a B0 interrupt, don't know about B4
though B7 interrupts).  Note:  Using the CCP pin "does require" that you know
about the ZC before it actually happens, or you won't be able to turn off the
triac before the next half cycle (it would always be full on otherwise).

Otherwise, you can use TMR0 at a 1:32 prescale (at 4mhz PIC speed) to generate
an interrupt to turn on the triac (at 4mhz, it's nearly the entire 1/2 cycle
time range of 8.3ms, and not much jitter).  You'd just need to set TMR0 to an
appropriate value during the ZC interrupt (255 = full on, 128 = half power, 0 =
nearly off).  You can either leave the port on, and turn it off right before ZC
like described above, or if your application is not having to do anything else,
just wait for about 30us after turning it on (in your interrupt routine), and
then turn it off again.  Using the TMR0 technique would also allow you to
develop this on an 16F84 instead (flashable), and would allow you to fairly
easily migrate this to a really cheap 12C71, or the one your using now, later on
if you wanted to.


{Original Message removed}

2001\02\15@152104 by Eisermann, Phil [Ridg/CO]

flavicon
face
       On the subject of how to detect zero-crossing: I always get a funny
feeling in the pit of my stomach when connecting a +5V device to the AC line
via a resistor.

       Yes, I know we just hashed this out (once again) in the input clamp
thread.  I'm not necessarily worried about the PIC, but about people. I
always suggest using an opto-isolator. Especially when, as the original post
said, he's building something for his kids. So the cost isn't going to be
much of an issue. Plus, it protects the builder, especially if he's going to
be probing it with a scope or DVM.

       I always use a H11AA814, or some variant thereof, to detect AC
power. Even through Digi-key, these are $0.50 or $0.60 in single quantities.
They are made for this kind of thing. Toss in two resistors, and you have
the digital circuit isolated again. Or, as was already mentioned, if the
circuit is powered via a transformer, then connect the resistors to the
output of the transformer, before the rectifier.

       Just my personal opinion, of course.

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestTakeThisOuTspamspammitvma.mit.edu


2001\02\15@162421 by Patrick J

flavicon
face
yes Phil, I agree totally with you !
I hate to connect any +5V device directly to the powerline.. kinda feels like if it will blow up in my face the first chance it gets :-)

{Original Message removed}

2001\02\19@141901 by Andre Abelian

picon face
Phil,

I think I liked your idea using phototransistor specially
I have NEC phototransistor maybe 1000 of them.
I like to know what  schematic are you using with it?
speaking of direct connection I already modified
the schematic and connected direct. I am using emulator and
I do not mind if my probe gets damaged at list I will learn
some thing. I just checked pic input pin and it is pulsing this is what I
did

                       btfss    PORTB,0        ; check zero crossing pin
(input)
                       goto    $ - 1                ; if not high try again
                       bsf      PORTB,1        ; turn this pin high for
test (output)
                       btfsc    PORTB,0        ; check for low
                       goto    $ - 1                ; if not low try again
                       bcf       PORTB,1        ; turn this pin low for
test


after I run this code I checked PORTB,1 is pulsing this means hardware
connection is fine. But what I do not understand btfsc PORTB,0 when it skips
it may not be 100% zero it could be 0,7 volt higher or lower.
zero crossing it should be zero volt. right after this code I add delay then
or without any delay
I turn the traic on I do not see any change or little change. To  my
understanding traic stays on
until it sees next zero volt. my question  is " how to detect zero crossing
with pic "?
any help will highly appreciated.

Andre



>         On the subject of how to detect zero-crossing: I always get a
funny
> feeling in the pit of my stomach when connecting a +5V device to the AC
line
> via a resistor.
>
>         Yes, I know we just hashed this out (once again) in the input
clamp
> thread.  I'm not necessarily worried about the PIC, but about people. I
> always suggest using an opto-isolator. Especially when, as the original
post
> said, he's building something for his kids. So the cost isn't going to be
> much of an issue. Plus, it protects the builder, especially if he's going
to
> be probing it with a scope or DVM.
>
>         I always use a H11AA814, or some variant thereof, to detect AC
> power. Even through Digi-key, these are $0.50 or $0.60 in single
quantities.
{Quote hidden}

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email RemoveMElistservKILLspamspammitvma.mit.edu with SET PICList DIGEST in the body


More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...