|
|
View previous topic :: View next topic |
Author |
Message |
Micha
Joined: 01 Apr 2014 Posts: 3 Location: Belgique
|
unexpected PWM signal on PIN B3 with 18F46K22 |
Posted: Tue Apr 01, 2014 2:50 pm |
|
|
Hello,
I am using PCH version 4.130 to program a PIC 18F46K22.
I have strange problem.
I generate PWM signals on RC1 and RC2, and this works well.
Code: |
// Sets CCP1 for PWM
setup_ccp1(CCP_PWM);
// Sets CCP2 for PWM
setup_ccp2(CCP_PWM);
|
However, i noticed that an unexpected PWM signal appears also on the pin RB3. However it should not appear...
The magnitude of the voltage of the PWM is about 0.6 V.
Do you have any idea why this signal might appear?
RB3 is an alternate PIN for CCP2.
In the CCS compiler help, for CCP1, it is said:
"Some chips also have fuses which allows to multiplex the ccp/pwm on different pins. So check the fuses to see which pin is set by default. Also fuses to enable/disable pwm outputs."
As i understand, fuse "CCP2B3" allows to enable a PWM on PIN B3, but i did not used it.
Is there maybe a fuse to _disable_ the multiplexing of the PWM on PIN B3 ? I did not find it in the CCSS documentation.
I am pretty stuck with this issue, i would be very interested by your expert opinion.
Best regards,
Micha |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Wed Apr 02, 2014 1:24 am |
|
|
I'd suggest leak through. Remember that the switching is a MOSFET multiplexer, which has some impedance (several Mohm), when 'off'. If the pin is left set as an input, with nothing driving it (a thing you should never really do - all pins _should_ have something driving them - either set as outputs, or with an external resistor driving them....), then the off impedance of the multiplexer, is probably a few mega ohms, and assuming the input impedance is similar, and you are measuring with something like a 10MR input impedance scope, then some leakage may well be visible.
Alternatively (worse), it is possible the multiplexer has been damaged. On chips where high voltage spike events have happened (things like driving a solenoid, and not trapping the flyback externally, but relying on the internal diodes), one result can be an increase in leakage inside the chip...
Then finally, are you sure the signal is not being coupled externally on your board?. |
|
|
gpsmikey
Joined: 16 Nov 2010 Posts: 588 Location: Kirkland, WA
|
|
Posted: Wed Apr 02, 2014 8:12 am |
|
|
Along the lines of what Ttelmah was saying - you don't show a schematic, so the question is what is (if anything) connected to RB3? Is that an open pin or is there something connected? If it is open, what happens to that .6v signal you see if you put say a 10k resistor to ground so the pin is not floating? It does sound like a crosstalk issue of some sort, but without knowing what kind of load is on that pin it is tough to figure if there is an internal problem or it is just floating (which it should not be doing).
mikey _________________ mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3 |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Wed Apr 02, 2014 8:46 am |
|
|
I have to agree with the others it could be crosstalk however you should post your 'fuses'(all of them) as well as a schematic or at least what's connected to RB3 as it's muxed with ADC, COMP and other peripherals.
uC defaults ADC pins to the ADC , so 'noise' could be getting in there.
hth
jay |
|
|
Micha
Joined: 01 Apr 2014 Posts: 3 Location: Belgique
|
|
Posted: Wed Apr 02, 2014 2:44 pm |
|
|
Hello!
Firstly, thank you for your three kind answers and for your time. I really appreciate your help!
The pin RB3 is not floating. It is only connected to the input of an optocoupler (pin 5 of a CNY74-4H). A resistance of 56 Ohm is connected between pin 6 of the CNY74-4H and the ground.
http://www.vishay.com/docs/83526/83526.pdf
Normally, i should have in output of pin RB3 a signal changing from time to time from 0V to 5 V and conversely.
If i let floating the pin RB3, the signal i get in output from RB3 is perfect.
But if connect RB3 to the optocoupler, then the small "PWM noise" of 0.6 V appears instead of the 0 - 5 V signal expected.
So the logical conclusion seems to be that the "PWM noise" is created somewhere between the RB3 output and the optocoupler input.
BUT, if i replace output RB3 by another pin of the PIC, PIN_D0 for example, and connect this PIN D0 to the optocoupler output exactly through the electrical PCB path normally followed by the current in output of RB3, i get the right signal 0-5V. So it let me think that the issue is not in the PCB, but is rather related to the output RB3 of the PIC...
Here are the fuses used:
Code: |
#fuses HSH, NOWDT, PUT, BROWNOUT, NOLVP, NOPBADEN
|
Now, if i connect a 10 kOhms resistor between PIN RB3 and the ground (instead of the optocoupler) as gpsmikey requested, i have the right signal 0-5V.
I can also tell that i am using a free sample PIC from Microchip. Maybe this sample could be damaged? A good test would be to try with another PIC (but i have to order a new one to test this assumption).
Best regards,
Micha |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Wed Apr 02, 2014 4:03 pm |
|
|
Quote: | But if connect RB3 to the optocoupler, then the small "PWM noise" of 0.6 V appears instead of the 0 - 5 V signal expected. |
What is RB3 set as?
If it's set as input, then it's essentially floating up to the ~0v6 you're observing.
In other words you've got your answer.
Mike |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Wed Apr 02, 2014 5:36 pm |
|
|
I'm thinking the 56r current limiting resistor of the optocoupler is too low a value. Rough math says it might try to pull 50ma from the PIC whereas 20ma is about the limit, so it could stress the I/O circuitry.
I'd try 150r and see what you observe.
hth
jay |
|
|
Micha
Joined: 01 Apr 2014 Posts: 3 Location: Belgique
|
|
Posted: Sun Apr 06, 2014 2:49 pm |
|
|
Hello,
For Mike, pin RB3 is always well set as an output, not as an input.
For Jay, with a 150 Ohm resistor instead of 56 Ohm, the problem is the same: the unexpected PWM signal is still there.
I will try to replace the PIC, and tell you what happens.
Thank you again for your help
Micha |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|