Gordon Williams | 11 May 23:32

[PIC] CCP1 Glitches in noisy environment (RC Tx)

Hi All,

I'm having problems tracking down the reason of some glitches occurring on
the CCP1 output and it is driving me a bit crazy.

I'm putting some smarts into a basic RC transmitter.  I've replaced the
current chip producing the pulse train to the RF section with a daughter
board and added a cell phone LCD, some switches and Serial port for input
and output.  The serial port and LCD (spi) work fine and they don't have any
glitches.  The 5 ADC readings for the joysticks (4) and battery voltage also
work well with only 1 bit of noise on a 10 bit reading (referenced to the
power and gnd lines).

The PIC that I am using is the 16F886.  Its supply is a 78L05 on the main
board and I have a 10uf Tant and three 0.1uF on the power lines on the
daughter board.  The daughter board is single sided with a ground plane pour
under the PIC and every else where I could.  Because I don't have ADC
problems or serial or spi errors that noise must be reasonably constrained,
I think.

I'm using CCP1 (pin C2) to produce the PPM that goes to the RF section.  It
is the standard PPM protocol (each channel pulse is 1 to 2 ms wide including
the following 0.3 ms pulse, repeated every 20ms).

Timer1 runs freely.  With a CCP1 interrupt (my only interrupt) I update
CCPR1 with the duration until the next transition high or low and the
CCP1CON bits to set the next transition in the correct direction.  My main
program clears a flag and that is all.

Most of the time it works perfectly and looks like:
(Continue reading)

Vasile Surducan | 12 May 13:49

Re: [PIC] CCP1 Glitches in noisy environment (RC Tx)

You have a huge noise there, try to see why. Almost 2Vpp of noise is a
real mess.
It's possible that sometime the PWM dutycycle be longer that PWM period?
Only then the CCP output remains high. Maybe a compiler problem ?

Wesley-Basil-Vasile

On 5/12/08, Gordon Williams <g_will <at> cyberus.ca> wrote:
> Hi All,
>
> I'm having problems tracking down the reason of some glitches occurring on
> the CCP1 output and it is driving me a bit crazy.
>
> I'm putting some smarts into a basic RC transmitter.  I've replaced the
> current chip producing the pulse train to the RF section with a daughter
> board and added a cell phone LCD, some switches and Serial port for input
> and output.  The serial port and LCD (spi) work fine and they don't have any
> glitches.  The 5 ADC readings for the joysticks (4) and battery voltage also
> work well with only 1 bit of noise on a 10 bit reading (referenced to the
> power and gnd lines).
>
> The PIC that I am using is the 16F886.  Its supply is a 78L05 on the main
> board and I have a 10uf Tant and three 0.1uF on the power lines on the
> daughter board.  The daughter board is single sided with a ground plane pour
> under the PIC and every else where I could.  Because I don't have ADC
> problems or serial or spi errors that noise must be reasonably constrained,
> I think.
>
> I'm using CCP1 (pin C2) to produce the PPM that goes to the RF section.  It
> is the standard PPM protocol (each channel pulse is 1 to 2 ms wide including
(Continue reading)

Gordon Williams | 12 May 14:36

Re: [PIC] CCP1 Glitches in noisy environment (RC Tx)


: You have a huge noise there, try to see why. Almost 2Vpp of noise is a
: real mess.
: It's possible that sometime the PWM dutycycle be longer that PWM period?
: Only then the CCP output remains high. Maybe a compiler problem ?

I should have been clearer about the part of the CCP module that I was
using.  I'm using the "compare" rather than the "pwm" part.

I don't think that it is a compiler problem as the effect is random and
nothing else appears to be affected.  I can't see it just jumping off
somewhere else in the program and not having an effect on either the Timer 1
or the CCPR1 register.

I need to look more carefully at the noise on the 5 V section of the
daugther board.  It is buried in the transmitter box and a PIA to get at.
Because the ADCs are noise free, my assumption was that it was fairly noise
free.

How much noise on the power lines is acceptable?

If the noisy supply voltage stays between 2.0 and 5.5 volts, is that OK? Or
does the noise component need to be kept below some value p-p?

Regards,

Gordon Williams

: On 5/12/08, Gordon Williams <g_will <at> cyberus.ca> wrote:
: > Hi All,
(Continue reading)

Richard Prosser | 12 May 21:50

Re: [PIC] CCP1 Glitches in noisy environment (RC Tx)

Gordon,
You're not just running out of stack or something like that are you?
Have you checked stack usage?

Otherwise, could the RF be getting back into the chip via an
unprotected pin. Do you have ferrite beads / caps on all input (&
possibly output ?) pins if the RF level is so high? Once the
protection diodes start conducting all sorts of strange things can
happen.

RP

2008/5/13 Gordon Williams <g_will <at> cyberus.ca>:
>
>
> : You have a huge noise there, try to see why. Almost 2Vpp of noise is a
> : real mess.
> : It's possible that sometime the PWM dutycycle be longer that PWM period?
> : Only then the CCP output remains high. Maybe a compiler problem ?
>
> I should have been clearer about the part of the CCP module that I was
> using.  I'm using the "compare" rather than the "pwm" part.
>
> I don't think that it is a compiler problem as the effect is random and
> nothing else appears to be affected.  I can't see it just jumping off
> somewhere else in the program and not having an effect on either the Timer 1
> or the CCPR1 register.
>
> I need to look more carefully at the noise on the 5 V section of the
> daugther board.  It is buried in the transmitter box and a PIA to get at.
(Continue reading)

David VanHorn | 12 May 23:21

Re: [PIC] CCP1 Glitches in noisy environment (RC Tx)

> Otherwise, could the RF be getting back into the chip via an
> unprotected pin. Do you have ferrite beads / caps on all input (&
> possibly output ?) pins if the RF level is so high? Once the
> protection diodes start conducting all sorts of strange things can
> happen.

If the field is strong enough, diodes will start to rectify the RF and
can give you spurious inputs like RESET.
--

-- 
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

Gordon Williams | 13 May 06:07

Re: [PIC] CCP1 Glitches in noisy environment (RC Tx)

Richard and David,

The stack is OK.

The noise appears to be coming in on the 5v supply and/or ground line(s)
from the main board.  There is no separate ground for the analog, digital
and RF sections.  They are all lumped together.  The RF runs directly off of
the battery voltage, 9.6 volts nom.  At the battery with the scope I have
about 2 volts p-p of noise.

I put a 1 ohm resistor in the supply line expecting that it would make an RC
filter with the caps on the daughter board because the noise is 72 Mhz.  It
improved things slightly - maybe.

After doing a bit of research, it looks like the 10uF Tant won't do much for
noise at this frequency because of the ESR.  The three 0.1uF ceramics should
do OK.

I have some ferrite beads on hand that I would like to try out.  They are
axial single beads BL01RN1
http://www.electrokit.se/download/0900766b80098a6d.pdf

Putting one on the tip of the scope probe and then measuring the noise
across the battery terminals dropped the noise by 1/2.

Should I be putting a ferrite bead on both the supply and ground line to the
daughter board?

Would it be a good idea to add a 1uf ceramic as well?

(Continue reading)

Vasile Surducan | 13 May 06:31

Re: [PIC] CCP1 Glitches in noisy environment (RC Tx)

On 5/12/08, Gordon Williams <g_will <at> cyberus.ca> wrote:
> Richard and David,
>
> The stack is OK.
>
> The noise appears to be coming in on the 5v supply and/or ground line(s)
> from the main board.  There is no separate ground for the analog, digital
> and RF sections.  They are all lumped together.  The RF runs directly off of
> the battery voltage, 9.6 volts nom.  At the battery with the scope I have
> about 2 volts p-p of noise.
>
> I put a 1 ohm resistor in the supply line expecting that it would make an RC
> filter with the caps on the daughter board because the noise is 72 Mhz.  It
> improved things slightly - maybe.
>
> After doing a bit of research, it looks like the 10uF Tant won't do much for
> noise at this frequency because of the ESR.  The three 0.1uF ceramics should
> do OK.
>
> I have some ferrite beads on hand that I would like to try out.  They are
> axial single beads BL01RN1
> http://www.electrokit.se/download/0900766b80098a6d.pdf
>
> Putting one on the tip of the scope probe and then measuring the noise
> across the battery terminals dropped the noise by 1/2.

What scope do you have and how are your probes (1:1, 1:10?)
0.9Vpp noise directly on battery terminals is very weird.
I think you have a ground problem there or measuring problems or toy
scope or all of them. When you are measuring noise, you must move your
(Continue reading)

Gordon Williams | 13 May 17:09

Re: [PIC] CCP1 Glitches in noisy environment (RC Tx)

Here are some readings across the battery just after the battery connector.
The battery is NiCad.  I've taken the spring hook clip off of the probe end.
The ground lead is about 20 cm long.  The scope that I am using is a
Bitscope.  The probe and scope front end are good to 100 MHz bandwidth.  The
sample rate is 25 Mhz.

If I attach the ground lead to the negative battery terminal but leave the
probe free I get 20 mV of noise.  If I touch the probe to the ground lead
connection I get 60 mV of noise (should be short circuit).  Leaving the gnd
lead attached and I put the probe on REF. I get 20 mV of noise.  Taking the
lead off and leaving it on ref there is < 5 mV of noise.  This is using the
1x probe and 130mv range.

Across the battery
For different settings I get different readings:

10x probe, AC
+/-Range             Noise Vp-p
1.3V  0.69
6.0   0.94
12.0  1.6

1x probe, AC
130 mV    0.06 noise
600 mV    0.08
1.2 V       0.13
3.16        0.15

As you can see, they aren't consistent.  Both 1x and 10x noise appears to
increase with range setting.  Both essentially double from the lowest to the
(Continue reading)

Gordon Williams | 16 May 03:18

Re: [PIC] CCP1 Glitches in noisy environment (RC Tx)

I got rid of the RF noise by removing the crystal and to my surprise I'm
still getting glitches.  There is now a non-measurable amount of noise as
far as I can detect.

The glitch happens when the ISR returns to the main program.  The number of
instruction cycles matches the time delay to the glitch exactly.  I even put
in a time delay in the ISR to confirm that.  This point is a long way away
from any pin being turned on or off.

Anyone heard of anything like this on a 16f886 or similar device?

Regards,

Gordon Williams

--

-- 
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

Gordon Williams | 20 May 20:04

Re: [PIC] CCP1 Glitches in noisy environment (RC Tx)

I eventually found the problem after a lot of long days.

When assigning to the compare register CCPR1 (2 bytes) the low byte was
written first followed by the high byte.  After the low byte was written
there was a match with Timer1 that caused another interrupt when one should
not have happened.

The solution is to write the high byte first followed by the low byte.

Regards,

Gordon Williams

----- Original Message ----- 
From: "Gordon Williams" <g_will <at> cyberus.ca>
To: "Microcontroller discussion list - Public." <piclist <at> mit.edu>
Sent: Thursday, May 15, 2008 9:18 PM
Subject: Re: [PIC] CCP1 Glitches in noisy environment (RC Tx)

: I got rid of the RF noise by removing the crystal and to my surprise I'm
: still getting glitches.  There is now a non-measurable amount of noise as
: far as I can detect.
:
: The glitch happens when the ISR returns to the main program.  The number
of
: instruction cycles matches the time delay to the glitch exactly.  I even
put
: in a time delay in the ISR to confirm that.  This point is a long way away
: from any pin being turned on or off.
:
(Continue reading)

Rich | 13 May 07:51

Re: [PIC] CCP1 Glitches in noisy environment (RC Tx)

Usually increasing the power supply impedance (one ohm resistor) will worsen 
the noise problem.  Low ESR  caps on the supply may help.  I have not been 
following this so I do not know if the board has a ground and power plane. 
But if you can put a 1 ohm resistor in series with the power line, then you 
can put an insulated wire with a ferrite bead.  If it is an RF problem you 
need to shunt it out with a series LC that is resonant to the RF frequency. 
The series LC network is a low impedance at resonance, and therefore will 
attenuate the RF considerably.  The formula for LC resonance is commonly 
available.  The resistive element in the LC network should result in a lower 
Q and thus a broader resonance band.  Also, if the circuit is powered by a 
battery, a post battery regulator circuit is a good idea for RF noise 
control.  If you try using a low impedance regulated supply in place of the 
battery as a test to see if the problem is attenuated, then you may evaluate 
the post battery regulated idea.
Cheers

----- Original Message ----- 
From: "Gordon Williams" <g_will <at> cyberus.ca>
To: "Microcontroller discussion list - Public." <piclist <at> mit.edu>
Sent: Tuesday, May 13, 2008 12:07 AM
Subject: Re: [PIC] CCP1 Glitches in noisy environment (RC Tx)

> Richard and David,
>
> The stack is OK.
>
> The noise appears to be coming in on the 5v supply and/or ground line(s)
> from the main board.  There is no separate ground for the analog, digital
> and RF sections.  They are all lumped together.  The RF runs directly off 
> of
(Continue reading)


Gmane