PDA

View Full Version : Power problems



menta
- 27th July 2008, 16:09
this is mostly hardware related, but maybe someone can help.

I'm using PIC16F877A as described in this circuit :
http://dj-gil.com/PIC/posts/SCHEMATIC4.pdf

When I use the programmer to power the circuit everything is ok.
But when I use the the 7805 to power the circuit I get junk on my LCD and nothing works.
Any ideas ?

BTW, the transformer is standard adjustable DC adaptor so it aleady has diode bridge inside.


Thanks.

mackrackit
- 27th July 2008, 17:03
BTW, the transformer is standard adjustable DC adaptor so it aleady has diode bridge inside.


What is the voltage out of the transformer?
May not be high enough.
What is the 7805 voltage when circuit is on (LCD)

menta
- 27th July 2008, 17:26
transformer output without load is ~16V.
7805 output is 4.95 while its on.

I have another circuit usining the same parts, with one change, I use the PIC Kit2 demo board with 16f887 which works ok.
When I use its 5V power for the second circuit I get the same results.

gringobomba14
- 27th July 2008, 18:02
Menta, 4.95V is good. Whats the current rating on the transformer? I can see maybe over an amp of current straight off without studying the schematic for longer than a few minutes. Perhaps there is just not enough current to power the LCD? Failing that, what is the current rating for your 7805? Depending on the package they're good for between 250mA and about 500mA. Try putting 2 in parallel (If the tranny has an output of greater than 1500mA)

skimask
- 27th July 2008, 18:38
In that schematic, I don't see anything connected to MCLR. If MCLR is floating, or worse grounded, the program might not get the chance to start.
Try adding a +5v line to the MCLR pin on the '887 and see what happens.
The program may already have the MCLR pin configured as an I/O, but we won't know without seeing the actual program itself.

Also, are you using an 887 or 877A? Because there is no 887A...

menta
- 27th July 2008, 18:54
Yes, its 16f877A, my mistake.
I tried connecting the MCLR pin to the +5v but it didn't help.
It also didn't help using 2x 7805.
Its very strange because I have another circuit just exact to this one but using a 887 on a demo board.
BTW, if I use the programmer voltage output (just + and - ) and connect them to the circuit its also working ok.

gringobomba14
- 27th July 2008, 19:00
You don't have enough current. Can't be anything else then. Do you have a multimeter? whats the current drain on the circuit?

skimask
- 27th July 2008, 19:00
Yes, its 16f877A, my mistake.
I tried connecting the MCLR pin to the +5v but it didn't help.
It also didn't help using 2x 7805.
Its very strange because I have another circuit just exact to this one but using a 887 on a demo board.
BTW, if I use the programmer voltage output (just + and - ) and connect them to the circuit its also working ok.

Are you using the same program between the 887 on the demo board and the 877A in the circuit? If so, it won't work.

menta
- 27th July 2008, 19:16
The program is working when I use the programmer as power supply.
I of course compiled the program differently for each controller.
I have multimeter, What is the best way to check the current ?
serially to the + ?

skimask
- 27th July 2008, 19:18
The program is working when I use the programmer as power supply.
I of course compiled the program differently for each controller.
I have multimeter, What is the best way to check the current ?
serially to the + ?
That's practically the only way to measure it (short of using a series resistor).
Connect the meter in-line with the positive supply and the positive on the circuit.
Make SURE your meter can handle an amp or more.
If it can't handle that, you'll either smoke your meter or just blow a fuse.

menta
- 27th July 2008, 19:27
I will.
If I use the second circuit 7805 output and connect it to the first circuit (with the 16f887) it is working ok. (it has same parts including the LCD)

menta
- 27th July 2008, 21:55
i'm using a code to print 1,2,3... to the LCD
I see that it prints the numbers but also print junk,
So I guess something is making noise on the LCD input.
Tried with a resistor to the ground and some 22pF capacitors, but it doesnt help.

gringobomba14
- 27th July 2008, 22:39
Yes, serially connect the meter to +, set it to 10 Amps. Why not do the following. Use 1 7805 for the display and another 7805 for the PIC. you can place the circuits in parallel if you so wish. you will need a third 7805 (maybe) for the 2803. Keep us informed if you can

menta
- 27th July 2008, 22:52
Guys,
I have a another circuit with 1 7805 that push the PIC16f887 and the same LCD type.
I think its something else.

skimask
- 28th July 2008, 02:28
Post some code!!!

languer
- 28th July 2008, 06:34
You should have the MCLR set per the 16F877A datasheet. Note that the 16F887 "has a noise filter in the MCLR Reset path. The filter will detect and ignore small pulses.". This along with the different clock circuits on the 887 makes enough of a difference.

A simple test code which works on both the 877A and 887, as previously suggested, will also provide some insight.

menta
- 28th July 2008, 07:42
languar I didn't get you point.


DEFINE OSC 8
a var byte
a=0
TRISB=$0
test:
SEROUT PORTB.0,4,[254,128,#a]
a=a+1
pause 1000
goto test

end

languer
- 28th July 2008, 08:17
What I am trying to say is that the 887 and 877A are not exactly identical. The MCLR input (something that can be associated with such problems) are quite different on both devices. My suggestion is to connect the MCLR to Vdd on the 877A using the R-C-R circuitry in the datacheet.

Also, the OSC input circuitry are not the same on both devices. Do both circuits you have (i.e. working 887 and non-working 877A) use the same external crystal circuit, or does the 887 uses the internal oscillator?

The code you have posted works on the 887, but not on the 877A? Is this correct?

menta
- 28th July 2008, 09:07
I tried to connect the MCLR stright to the +5V. Didnt help. Will try with RCR.
887 use internal OSC while the 877A use an external.
The code works perfect on both devices when using the USB programmer to power up the circuit.
When I use the 7805 to power the 877A, it fails. 887 is running with the same 7805 with no problems.
I see that the program run, I see it print something every 1 second, It start to print 1,2 and then it print junk every 1 sec. Thats why I think the LCD get some noise. I tried with R-C to the ground, but it doesn't help.

gringobomba14
- 28th July 2008, 16:55
With regard to this circuit, take the 2803 out of the circuit and try it. If it still doesn't work, it's not power related, then we can look at noise somewhere. Have you got a photo of this setup?

Archangel
- 28th July 2008, 17:23
Hi Menta,
You know, the schematic you posted has 1 rather serious omission, in that it is sending AC and not DC to the regulators. Did you install a bridge between the transformer and the regulators? Cause ME-THINKS AC ain't going to work.

menta
- 28th July 2008, 17:40
From my first post


BTW, the transformer is a standard adjustable DC adaptor so it already has diode bridge inside.


I'm not using anything beside the PIC and the LCD.

gringobomba14
- 28th July 2008, 18:02
noise my friend, seems the only option at this stage.

gringobomba14
- 28th July 2008, 18:22
or your display is messed up. Checked the leads into the display?

Just out of curiosity, what is the rating on the tranny? and what was the total current draw on the circuit?

skimask
- 28th July 2008, 18:56
And once again, it sounds like it's time to go back to the drawing board with a 'blinky led'...
Yes I know it supposedly works fine on the '887 demo board, that's great.
Add an LED to the 877A board and get that working, then build back up to a clone of the 887 demo board.

menta
- 28th July 2008, 19:48
Guys,
Everything is working perfect when I use the programmer power.
A ~700 lines code.
The problem is very simple when connecting outside power source.

menta
- 28th July 2008, 20:43
I build a temporary new board and it works ok.
Maybe something is wrong with the other board.
I might build it fro scratch again.
Thanks.

skimask
- 28th July 2008, 20:43
Guys,
Everything is working perfect when I use the programmer power.
A ~700 lines code.
The problem is very simple when connecting outside power source.

Does it run if you manually RESET (pull MCLR to ground) it after power up?
If so, put a capacitor across MCLR and ground, and a resistor between Vdd and MCLR.
The problem might be that MCLR is coming up faster than Vdd.
An R/C across MCLR might slow it up just enough to meet the chip's MCLR timings.

menta
- 28th July 2008, 20:51
On the temporary board the led was blinking very fast (suppose to have 1 sec pause)
Only when I set MCLR to +5v it started to run ok.

gringobomba14
- 28th July 2008, 21:00
Sounds like bad soldering or bad connections. Glad you have it sorted though. External power source making it work points to sever current loss accross your tranny/7805 circuit. Could it be your bridge rectifier is shot in the tranny? low power output?

skimask
- 28th July 2008, 21:19
On the temporary board the led was blinking very fast (suppose to have 1 sec pause)
Only when I set MCLR to +5v it started to run ok.

The LED was probably dumping your +5v line repeatedly causing a brown out causing your PIC to reset making it look like it was blinking really fast (which it probably was). If your MCLR was floating (i.e. not connected), same thing may happen (i.e. brown out triggers MCLR just by chance). Connecting MCLR to Vdd might've help alleviate the situation, but sounds to me like a temporary fix.
Not a good practice to leave MCLR floating, unless you are absolutely sure it's tied internally (which I'm not sure the 16F877A has that exact option).
Add an extra resistor inline with your LED (make it really dim), pull the +5v off of MCLR and see what happens (less current flow across the LED, less load on the main +5v rail, etc).
Then maybe try adding another capacitor between Vdd and Vss...can never have too much of that...

languer
- 28th July 2008, 21:21
Never mind

gringobomba14
- 28th July 2008, 22:02
Dammit!!!! Didn't spot the MCLR pin wasn't connected in the schematic. Maybe need new glasses!!!!!!

menta
- 28th July 2008, 22:34
Well, I really dont know what do more.
On the test board everything was ok. The LED was blinking, the LCD shows the numbers.
Now I wrap it again and it aint work, unless I touch the 8Mhz crystal with my hand ;-0

menta
- 28th July 2008, 22:43
And ofcourse, if using the programmer power , everything is ok (with MCLR stright to the +5v)

skimask
- 29th July 2008, 03:44
Well, I really dont know what do more.
On the test board everything was ok. The LED was blinking, the LCD shows the numbers.
Now I wrap it again and it aint work, unless I touch the 8Mhz crystal with my hand ;-0

That usually indicates a missing ground and/or pullup or pulldown somewhere, likely on MCLR, or missing cap's between Vdd and Vss (both pairs and across the pairs).

languer
- 29th July 2008, 05:31
Look at the grounds. Make sure they are very nice, short, and fat traces (or wires). The traces (or wires) from the crystal to the PIC should be as short as possible. The capacitors on the crystal should also be as close as possible to the PIC, with direct connection to GND. Pay good attention to the MCLR connection (follow the datasheet, they did not went through all that trouble for no reason).

This is what I tried to explain before. The 877A has external MCLR and external oscillator (the 887 has the capability to run both of them internally - not good comparison).

menta
- 29th July 2008, 08:53
How do you explain that when using the power from the programmer, everything is OK ?

skimask
- 29th July 2008, 13:38
How do you explain that when using the power from the programmer, everything is OK ?
The programmer may hold MCLR low while Vdd comes up and release MCLR after a few milliseconds. Put a 'scope on it and see if you can see anything.

menta
- 29th July 2008, 18:39
I'm not using all programmer legs, just + and -

mvs_sarma
- 29th July 2008, 19:14
You are loading the 12V motor supply with regulator and on a 12V transformer.(16V~ on open circuit). when the motor is loaded, the transformer saturates probably and all the derived power supplies might go noisy.

Try to provide a separate supply for the 12V load. Things should improve.

mackrackit
- 29th July 2008, 19:18
Just for giggles.

If you do not have a scope or frequency meter. Use you DVM set for AC and se what the the voltage is from the programmer vs the out put of the 7805.

If you can measure frequency the take that measurement.

menta
- 29th July 2008, 21:59
Its amazing,
When I use the test board (http://dj-gil.com/PIC/posts/math.jpg) everything is ok.
When I put in the wireWrap board (http://dj-gil.com/PIC/posts/WW1.jpg)
(http://dj-gil.com/PIC/posts/WW2.jpg) its not working.

skimask
- 29th July 2008, 22:11
Its amazing,
When I use the test board (http://dj-gil.com/PIC/posts/math.jpg) everything is ok.
When I put in the wireWrap board (http://dj-gil.com/PIC/posts/WW1.jpg)
(http://dj-gil.com/PIC/posts/WW2.jpg) its not working.

Just because it works on the 'test board' and it doesn't work on the 'wirewrap board', doesn't mean you schematic/parts are correct for that particular application.
I don't see any capacitors across Vdd/Vss on the 'test board', but that doesn't mean there aren't any there (i.e. stray capacitance).
I see a single resistor leading over to MCLR, but no capacitor, again, doesn't mean there isn't any capacitance on MCLR (albiet stray caps). And it also doesn't specifically mean that you have to have a capacitor across MCLR to ground, but it sure doesn't hurt.
It also doesn't mean that your wiring, no matter how many times you've checked it, is correct and without fault.
It also doesn't mean that the program you wrote for your '877 is actually going to run on your '887, or the other way around, without any changes in the source at all. the 16F877A is an old chip, the 16F887 is a new chip. A lot of differences between the 2.
Maybe your programmer's power supply is a lot smoother than the other power supply you're using.
Maybe your other power supply can't handle the extra load and dumps causing a reset, maybe it doesn't come up fast enough to satisfy the PIC, maybe it comes up too fast.
1650 different reasons why stuff don't work. I think we've isolated like 3 possibilities...

menta
- 29th July 2008, 22:45
I think i'm not going to use the 877A.
Too much trouble comparing to the 887.
I spent 2 days on this issue and I still can't understand why it works or not.
Thanks.

menta
- 29th July 2008, 22:55
btw, I've reached a point where my WW board is working, only when I use LONG wires to the external crystal.
I guess this cause some kind of induction which makes it do work.
I was using a very expensive wire (some kind of wire used in plans, teflon isolation, non melting) and it didn't work. Only when I used some simple 26 AWG wire it is working.
go figure.

Archangel
- 30th July 2008, 01:18
btw, I've reached a point where my WW board is working, only when I use LONG wires to the external crystal.
I guess this cause some kind of induction which makes it do work.
I was using a very expensive wire (some kind of wire used in plans, teflon isolation, non melting) and it didn't work. Only when I used some simple 26 AWG wire it is working.
go figure.
Hi Menta,
every piece of wire, every component, every circuit board trace, exibits properties of both capacitance and inductance ( which means they act to some degree as both a capacitor and a coil ). The Oscillator in the PIC requires just a certain amount of each, or it will not work. When you use a crystal, you must use the correct value capacitors in the circuit or again, it will not work.<br>
That said, imagine the long wires running parallel to one another. every mm of that wire adds capacitance to the circuit, probably why it works with the long wires and not the short ones. One big however is, the long wires also work as coils and will throw off the frequency of the Oscillator. So as Skimask pointed out, put in the capacitors, on very short wires and enjoy your success.

skimask
- 30th July 2008, 02:16
btw, I've reached a point where my WW board is working, only when I use LONG wires to the external crystal.
I guess this cause some kind of induction which makes it do work.
I was using a very expensive wire (some kind of wire used in plans, teflon isolation, non melting) and it didn't work. Only when I used some simple 26 AWG wire it is working.
go figure.

Are you using any cap's on your crystal at all?
In fact, are there any capacitors anywhere on your circuit board?

menta
- 30th July 2008, 06:23
At first I used capacitors on each device just like the book.
Crystal to PIC with 2x 22pF cap.
Did everything nice smooth and easy. All looked very good.
The whole problem was due to that 2 wires to the Cystal.
Thanks.

gringobomba14
- 30th July 2008, 07:19
Morning Menta,

The 877A is a bit tempremental at times. I use it for a lot of projects, and I find that some times it works under strange conditions when it shouldn't. We've established that you have a resistor between VDD and MCLR, try wiring the MCLR direct to the 5V line. You will need 18pF or 22pF caps on that crystal. Back to super short leads and the caps between the xtal and ground on both sides. It's not just because we say it, it's because thats how they work.....
Your transformer (I noticed you never answered what the rating is/was) probably has a lot of noise on it, so try putting a 470uF cap accross the output of the tranny and if possible, accross the output of the 7805. That will smooth out any ripples that may be around. Just because it SAYS it has a complete DC output doesn't mean it's true.
Hope that helps some

menta
- 30th July 2008, 22:55
1M resistor in parallel to the crystal has solved the problem.
Thank all.
Menta.