Searching \ for '[pic] Differences between RA0..RA3, RA4, and RB0..' 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: 'Differences between RA0..RA3, RA4, and RB0..'.

Exact match. Not showing close matches.
PICList Thread
'[pic] Differences between RA0..RA3, RA4, and RB0..'
2005\11\07@205142 by M Graff

flavicon
face
Greetings!  This is my first post to piclist, so be gentle please.  :)

I'm building a phase controlled lighting system (yes, for a holiday
light display) and am running into difficulties.  I'm using a 16F648A
since I had a lot of those lying around.

I have the following port config:

triac drive outputs:
       RA0 -- triac 0
       RA1 -- triac 1
       RA2 -- triac 2
       RA3 -- triac 3
       RA4 -- triac 4
       RB3 -- triac 5
       RB4 -- triac 6
       RB5 -- triac 7

other inputs / outputs:
       RA5 is configured for mclr and tied to VCC through 10k
       RA6 and RA7 are configured for outputs.  Otherwise currently unused and
not connected.  I'm reserving them for external crystal osc should I
need more than the 4 Mhz internal one can offer.
       RB0 -- zero cross (input)
       RB1 -- serial RX (input, connected to MAX202)
       RB2 -- serial TX (output, connected to MAX202)
       RB6 -- error LED (output)
       RB7 -- heartbeat LED (output)

Each of the triac boards I have built are driving MC3011 isolators
through a 330R tied to VCC.  These are random phase optos since I need
to turn off the triacs connected through them at points other than zero
cross.

I can fiddle with the triacs on RA0 through RA3 just fine -- I can dim
them, they do not flicker, they are stable at all brightness variations.
 However, RA4 and RB3..5 are causing me headaches.

The triac board is acting like an on/off switch instead of a phase
controlled output -- that is, if I turn RA4 on at half power, the device
attached to it sees full power.  Interestingly enough, if I measure the
voltage being output from the triac without load it appears to scale
correctly, but attaching a load to it causes it to ramp to full 120 VAC.

I have swapped triac boards (each board contains four triacs) and the
problem follows the port, not the triac board.  That is, no matter which
triac RA0 is connected to all is working, and no matter which triac RB3
is connected to it does not behave correctly.

Are there any electrical differences between these pins that could be
causing this problem?  Measuring the average DC voltage with a meter
shows nothing odd (except on RA4, but I suspect that is due to it being
an open collector) and I do not have easy access to an oscilliscope to
examine actual waveforms.

I have built two of these devices so far (both in the same box, powered
from the same power supply and fed from the same zero cross detector)
and both behave exactly the same.  I have installed bypass caps across
VCC/GND on all chips.  I only state that because that's always my first
question to people who have odd behavior :)

Anyone have a clue to loan me?

--Michael

2005\11\07@210040 by Mauricio Jancic

flavicon
face
RA4 it's not working because it has an open collector output. Attach a pull
up to it and it will work.

RB3 its not working because you probably programmed the PIC with low voltage
program support enabled and that overrides the use of RB3 as an I/O PIN

Regards,

Mauricio Jancic
Janso Desarrollos
Microchip Consultant Program Member
spam_OUTinfoTakeThisOuTspamjanso.com.ar
http://www.janso.com.ar
+54 11 4542 3519

2005\11\07@211334 by Jinx

face picon face
> Each of the triac boards I have built are driving MC3011
> isolators through a 330R tied to VCC.  These are random
> phase optos since I need to turn off the triacs connected
> through them at points other than zero cross

Hi Michael, why's that ? z-c is most often the preferred option
for various reasons (EMF, power surges, bulb life etc)

2005\11\07@211816 by Jinx

face picon face
> Each of the triac boards I have built are driving MC3011
> isolators through a 330R tied to VCC.  These are random
> phase optos since I need to turn off the triacs connected
> through them at points other than zero cross

BTW, I immediately assumed "on" re z-c. I believe it is not
possible to (simply ?) force a triac off. You can fairly easily
control when it runs on (by timing from the preceeding z-c
point), but not when it turns off, which I think is a few volts
+ve approaching the next z-c point

2005\11\07@213247 by M Graff

flavicon
face
Mauricio Jancic wrote:
> RA4 it's not working because it has an open collector output. Attach a pull
> up to it and it will work.

I'll try that.

> RB3 its not working because you probably programmed the PIC with low voltage
> program support enabled and that overrides the use of RB3 as an I/O PIN

Here's the __CONFIG line:

       include "P16F648A.inc"

       __CONFIG _BOREN_OFF & _CP_OFF & _DATA_CP_OFF & _PWRTE_OFF & _WDT_OFF &
_LVP_OFF & _MCLRE_ON & _INTOSC_OSC_NOCLKOUT

I'm probably over-stating the options, but I tend to side on safety.

--Michael

2005\11\07@213411 by M Graff

flavicon
face
Jinx wrote:

>> Each of the triac boards I have built are driving MC3011
>> isolators through a 330R tied to VCC.  These are random
>> phase optos since I need to turn off the triacs connected
>> through them at points other than zero cross
>
>
>
> Hi Michael, why's that ? z-c is most often the preferred option
> for various reasons (EMF, power surges, bulb life etc)
>

Because I am attempting to adjust the brightness of the lamps as well as
their state.  That is, I have 64 levels of brightness ranging from
full-on to full-off.

I also have other triac boards which will do their own zero cross
turn-on/off, but even driving a bulb at 1/4 power (one pulse every
1/120th of a second) causes flicker.  Phase control allows me to avoid
the flicker.

--M

2005\11\07@215440 by Jinx

face picon face
> Because I am attempting to adjust the brightness of the lamps as
> well as their state.  That is, I have 64 levels of brightness ranging
> from full-on to full-off

Ah, I see what you mean. You're using an opto that doesn't have
a z-c detector built in and will be doing the phase control yourself

The topic has come up before, have a look here

http://www.piclist.com/techref/bulbs.htm

includes the link to

http://www.piclist.com/techref/microchip/lampdim.htm

2005\11\08@050737 by Gerhard Fiedler

picon face
M Graff wrote:

> Are there any electrical differences between these pins that could be
> causing this problem?  Measuring the average DC voltage with a meter
> shows nothing odd (except on RA4, but I suspect that is due to it being
> an open collector) and I do not have easy access to an oscilliscope to
> examine actual waveforms.

There are some subtle differences between the port circuits; see the
manual. (Except for RA4, but you know that.) But they don't normally cause
such differences. A scope really would help here...

Are you sure that your code treats the pins equally? Can you make them
wiggle slowly, something like 5 seconds on/5 seconds off, so that you can
check with a meter?

Gerhard

2005\11\08@074832 by olin piclist

face picon face
M Graff wrote:
> __CONFIG _BOREN_OFF & _CP_OFF & _DATA_CP_OFF & _PWRTE_OFF & _WDT_OFF &
> _LVP_OFF & _MCLRE_ON & _INTOSC_OSC_NOCLKOUT
>
> I'm probably over-stating the options, but I tend to side on safety.

Then why turn off brown out reset and the power up timer?  I always keep
these on unless there is a specific reason not to.


******************************************************************
Embed Inc, Littleton Massachusetts, (978) 742-9014.  #1 PIC
consultant in 2004 program year.  http://www.embedinc.com/products

2005\11\08@110244 by M Graff

flavicon
face
Olin Lathrop wrote:
> M Graff wrote:
>
>>__CONFIG _BOREN_OFF & _CP_OFF & _DATA_CP_OFF & _PWRTE_OFF & _WDT_OFF &
>>_LVP_OFF & _MCLRE_ON & _INTOSC_OSC_NOCLKOUT
>>
>>I'm probably over-stating the options, but I tend to side on safety.
>
>
> Then why turn off brown out reset and the power up timer?  I always keep
> these on unless there is a specific reason not to.

Inexperience.  I'll turn them back on next time I flash the devices.
Thanks!

--Michael

2005\11\08@111451 by M Graff

flavicon
face
Gerhard Fiedler wrote:
> There are some subtle differences between the port circuits; see the
> manual. (Except for RA4, but you know that.) But they don't normally cause
> such differences. A scope really would help here...
>
> Are you sure that your code treats the pins equally? Can you make them
> wiggle slowly, something like 5 seconds on/5 seconds off, so that you can
> check with a meter?

So, it turns out I had a think-o.

Basically, I was getting the interrupt indicating zero-cross and
immediately turning off the triacs and reloading the time-to-turn-on
counters.  More or less, this macro, every time I got a zero cross:

twiddle macro n
       movfw        initial#v(n)        ; triacN
       movwf        current#v(n)
       bz                _fzc#v(n)on
       bsf                triac#v(n)
       goto        _fzc#v(n)off
_fzc#v(n)on:
       bcf                triac#v(n)
_fzc#v(n)off:
       endm

It turns out that I forgot that a triac cannot turn OFF at random times;
they only turn off when no (or, it turns out little) current is flowing.
 Once I remembered this basic TRIAC knowledge after getting pointers
from other list members, I discovered that I could turn off the first
four triacs "in time" -- before the sine wave was high enough to cause
the TRIAC to insist that it wanted to be on.  The others I could not.

Since I know the frequency of the timer1 interrupt I am using to divide
up the wave, I simply counted them and when "too many" have passed I
turn all the triacs off.  This means they will all start out as off on
the next zero-cross, and I can then decide when to turn them on again.
As an optimization, if the TRIAC is full-on, I never turn it off so I
don't have to handle that specially in the high-speed-needed timer1
interrupt routine.

Using this, I am able to get approximately 26 (non-equal) brightness
steps.  I don't have any sort of calibration yet, other than an eyeball,
but I now have all eight TRIACS doing the "same thing" without any
additional hardware.  RA4, even though it is open collector, only has to
sink, not source, so I just don't worry about adding a pull-up there.

Thanks to everyone for all their help on this.  I've actually gradated
college with a computer engineering major about 12 years ago and the
most electronics I've touched since then is to rewire my UPS to use deep
cycle marine batteries.  I've decided microcontrollers are "fun" again,
and I wanted to make a cool holiday light display, so they seemed to be
a natural match.  I'm just a bit rusty.  :)

--Michael

2005\11\08@120544 by William Chops Westfield

face picon face

On Nov 8, 2005, at 8:14 AM, M Graff wrote:
>
> It turns out that I forgot that a triac cannot turn OFF at random
> times; they only turn off when no (or, it turns out little) current is
> flowing.  Once I remembered this basic TRIAC knowledge after getting
> pointers from other list members, I discovered that I could turn off
> the first four triacs "in time" -- before the sine wave was high
> enough to cause the TRIAC to insist that it wanted to be on.  The
> others I could not.

You can't turn off 8 triacs (about 50 instructions with the macro you
mentioned) in between the time that you got the zero-cross interrupt
and the time the current rises high enough that turning off the gate
no longer results in the triac being off for the next cycle?  That
seems ... odd; I would have thought you'd have quite a lot of
instuctions
worth of time to work in...

Does the zero-cross detect circuit detect the falling edge or rising
edge
of the zero cross?  Could you switch it?

BillW

2005\11\08@123230 by M Graff

flavicon
face
William Chops Westfield wrote:
> You can't turn off 8 triacs (about 50 instructions with the macro you
> mentioned) in between the time that you got the zero-cross interrupt
> and the time the current rises high enough that turning off the gate
> no longer results in the triac being off for the next cycle?  That
> seems ... odd; I would have thought you'd have quite a lot of instuctions
> worth of time to work in...
>
> Does the zero-cross detect circuit detect the falling edge or rising edge
> of the zero cross?  Could you switch it?

It doesn't detect the ACTUAL zero cross, but something CLOSE to it.  It
is using a 6N138 fed directly from the full-wave rectified A/C input
with 20k series resistance.  I suspect the turn-on characteristics of
the zero-cross detection circuit doesn't leave enough margin.

I intend to eventually drive it with a higher frequency crystal,
probably 20 Mhz.  I'll also have purchased a scope at that point so I
can debug this stuff myself, rather than having to cart the whole
project off to where a friend works every time I run across a problem
like this.  I want to crank up the speed mostly to make more divisions,
and to "calibrate" the divisions I'm using for equal power.  The other
main reason is so I can feed it faster than 19200, even though 19200 is
enough to change eight values 192 times/sec using the trivial protocol
I'm using, which is greater than 120 Hz anyway.

I'll eventually post full schematics and so on for others to peek at and
give feedback.  I'd like to make PCBs for the whole project as well.
I'm using TRIAC boards from SimpleIO right now, and don't like they way
they ran their traces.  They're ok for a quick prototype, though.

--Michael

2005\11\08@140035 by Jan-Erik Soderholm

face picon face
M Graff wrote :

> It doesn't detect the ACTUAL zero cross, but something CLOSE
> to it.

I made something simmilar, and had an interrut on
both "sides" of the zero cross by switching between
rising and falling edge on each interrupt. The one right
before teh z/c was used to switch all triacs off, and the
interrupt right after the z/c was uses to start the "phase-timers".

> I want to crank up the speed mostly to make more
> divisions, and to "calibrate" the divisions I'm using for
> equal power.

Are that the timings from the z/c for each step ?

I calculated them in advanced (in Excel I think) and
put them in a table in the PIC. So s simple table-
lookup fetched the delay from the z/c for each step
in the range. No advanced calculations needed, they
would be exacly the same each time anyway, not ?

Jan-Erik



2005\11\08@141006 by Jan-Erik Soderholm

face picon face
Another thought...

You don't realy have to switch the Triac "off" at or
close to the x/c point, it can be done very soon after
the Triac has been turned "on", since it will stay "on"
by itself anyway. Note this can be a problem with
low power lamps and (some older) Triacs with a
rellatively high "hold current" (or whatever it was called).
They might  turn off to soon and it wil be a problem
to dim the lamp at low light levels.

Jan-Erik.



2005\11\12@094435 by Bill & Pookie

picon face
Sounds like you might be turning off the outputs one at a time at zero
crossing.  You could turn off a bank at a time in order to do it faster.

Bill

{Original Message removed}

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