Power supply for microprocessor assistance

Thread Starter

skybox53

Joined Dec 26, 2010
4
Enclosed is a schematic of a power supply I designed to source a 12 volt DC 1.5 amp motor and a 5 volt requirment for a 16F887 microprocessor. I'm using two supply rails with a common ground. The input seems adequate (18 volt DC 3.5 amp) and I'm reading 12 and 5 volts on the regulator outputs. The microprocessor VDD readings also indictae 5 volts and I can jump from the 12 volt rail to power the motor. However, I 'm struggling getting the microprocessor to run on the PCB.

The programming syntex works on the proto board with both the external and internal oscillators and I'm following the manufacturer's perscribed components for the oscillator. I also tried the internal OSC with no success on the PCB.

I'm trying to eliminate possible problems and need another set of eyes on the power supply to ensure I'm not missing something.

Sure would appreciate some assistance.

Roger
 

Attachments

ErnieM

Joined Apr 24, 2011
8,377
If you have a PICkit or such see if you can run just the PIC off the programmer power (no external supply). That eliminates one area of concern. If you can, see if the debugger will step thru your code.

If not, post the complete schematic and the test code.
 

Thread Starter

skybox53

Joined Dec 26, 2010
4
All VDD connections on the processor are connected to 5 Volt supply.

What I was hoping is for someone to evaluate the power supply circuit provided to see if there are any design flaws based on the input and regulated outputs.

Thx

Roger
 

ErnieM

Joined Apr 24, 2011
8,377
The power supply circuit looks basically OK. The cap values are a bit weird, bit as long as the 12V regulator is stable into 0.1uF it is OK.

You place a lot of cap on the 5V supply, I imagine to make it very stable for the PIC. However, large value caps such as that (electrolytic, correct?) have a very poor high frequency response. Thus one will usually use a large cap with a 0.1 in parallel. I have also seem an additional (third) cap of .001 there as well, especially when trying to make sensitive A2D measurements with the PIC.

However, I would expect this to work as is. And welcome to the forums!

BTW: (Not to take anything away from skybox) I wish all those who recommend starting with just a breadboard, chips and some wire to learn micro controllers to note the problems this approach can have.
 

JohnInTX

Joined Jun 26, 2012
4,787
Without the skiz we don't know but here's my $0.02:

What is the rate of rise of Vdd with 470uf on the output of the reg? If you are using PWRT to reset the PIC Vdd must rise .05V/msec min. I'd rather see the 470 on the regulator inputs with distributed decoupling as Mr. Chips says. Make sure Vdd has time to drop to 0 volts when cycling the power.

Double check the config bits for oscillator type, PWRT enable/disable etc. Disable the brown-out detector for now. Is the watchdog on but not being fed? Review sec 12 of the databook.

Is the code built for debugging with PKx or RealICE when you don't have a debugger connected?

What's MCLR/? It has to be high. Have you tried applying power then pulling it low then high to give an external reset? If there is an RC on MCLR/, is there a diode across R to discharge the cap (if its any great size?)

Check that the oscillator is running. Even with a DVM you can see roughly 1/2 Vdd if its running.

Write a few lines of code that do nothing but write 00h to TRISE and then to PORTE. When the chip runs, PORTE pins will go from floating around to a hard 0.
 

John P

Joined Oct 14, 2008
2,026
I think the capacitors are all wrong. You want a large one on the high-voltage input to the voltage regulators, and small ones on the outputs. As installed, that 470uF cap is wasted--just when do you expect it to deliver any charge? I hope you don't plan to overload the 5V regulator and hope it'll save you! If that happens, you have major problems. What I can see happening is that the motor will draw a surge of current, the input with its magnificent .33uF will sag, and you may not have enough voltage to run the processor. One way around this could be to put a good-sized cap on the 5V regulator input, with a diode delivering current from the supply. Then if the motor goes into a near-short condition, the logic power can run off the cap until conditions return to normal.
 

Thread Starter

skybox53

Joined Dec 26, 2010
4
This is a project that has a sliding door controlled by relays with hall switches to limit travel. The door open and closes based on ambient light via LDR.

I changed the output cap to 1uf but still won't oscillate. I enclosed a copy of the schematic and PCB layout. The hall switches connect to C1 an C0. Both work fine. With volatge applied I can put a magnet in proximity and change the voltage from high to low. Q3 works with a LDR and it too operates as designed. With light 5 volts, and dark 0 volts. LDR connects to BO and utilizes interrupt when light level changes. I can jump 5 volts to C0 and C1 and the relays energise as expected and the door operates. (validating the 12 volt supply) The crystal is 4 Mhz digi-key X006-ND with 20 pf caps. As stated, the input to the power regulators is 18 Volt DC 3.5 amps. Also, as mentioned in earlier post, the micro is 16F887.

The code runs pefect on breadboard with PicBasic Pro. I exteded the ouputs and inputs to the hardware (door switches and LDR) from the breadboard and it woked flawlessly. I'm someone perplexed at this point so appreciate any assistance.
Roger
 

Attachments

ErnieM

Joined Apr 24, 2011
8,377
The LDR to B0 would be my only concern for the in-between state where the light is almost enough to change the state level, and it goes to half Vdd. That could cause uncontrolled current in the PIC. But at this stage I don't think that is a killer for you (just fix it before you box it up).

The oscillator can stop you dead, but you state you tried the internal oscillator to no use. (I would use the internal osc anyway as I don't see anything here needing precise time so the crystal is a waste.)

Since your code works on the breadboard you have some other issue with the wiring.

Do you do in circuit serial programming (ICSP)? You have those pins free and a successful program tells you much.

Sorry to say my best advice is to recheck the wiring (which I am sure you have done dozens of times already). Don't assume anything is OK, verify it is OK. Verify the schematic to the PIC spec too (but it looked fine to me).
 

Thread Starter

skybox53

Joined Dec 26, 2010
4
I want to thank everyone who participated in helping me resolve the problem I was having. The suggestions and advice surely helped in getting the project operational, especially with the power supply caps and the BO connection. Ernie, although B0 did work it wasn't quite right. The issue was how it responded to the interrupt - leading edge/falling edge. In this application, I needed it to respond to a change of state so I moved the connection to B4 and set the appropriate registers - works fine now.

Something else I learned about the internal oscillator settings when using the editor Microcode Studio (PICBasic). The model the editor uses for the 16F887 is set up for the default of 4 Mhz. So, if you code the setting in the program for 4 Mhz everything works fine. However, if you need a internal 8 Mhz oscillator simply changing the "define" statement to 8 Mhz in the code won't work, you'll get a timeout error from the editor when compiling. The solution is to find the model file the program uses for that particular micro, make a copy of it to preserve the original, then make the appropriate changes - 4 to 8 Mhz and a baud rate that produces less than a 5% error rate. Finally, you'll have to move the revised file to where Microcode Studio sees it then recompile the program. A special thanks to Darrel Taylor, a moderator over at microengineering (PICBasic), for pointing this out. As a result of our conversation he put together a how-to video that is extremely helpful. Here is the link for those who use MicroCode Studio:

http://support.melabs.com/DT/INTOSC_ICD/INTOSC_ICD.html

This was my first micro project from conception to designing a PCB. Once the modeling was completed the challenge was to design the PCB and hope that the transition from theory to practical worked. In this case for me it did with a few modifications. Fortunately, the changes could be implemented without shelling out more money for a mistake in the PCB design (PCBs cost money). I also learned that it can be a frustrating experience when some needed information is not available in reference material. This is where forums such “All About Circuits” come into play - people willing to share their experiences with others.

Thanks again

Roger
 
Top