Author Topic: How do I choose the correct components for PIC16F88 power & oscillation circuit?  (Read 558 times)

0 Members and 1 Guest are viewing this topic.

Offline Teza

  • Contributor
  • Posts: 36
  • Country: no
This might be so basic that you may want to tear your hair of, sorry for that.
 
I have a few of the PIC 16F88 and LM7805, and need to order components for it's basic connecting.
I am looking at the scematic from the online book:
https://learn.mikroe.com/ebooks/picmicrocontrollersprogramminginassembly/back-matter/appendix-b-examples/
 

 
Even that I know the values of the components in the schematic, I don't know what components to order. I am thinking on the capasitors on the power circuit and the quartz crystal circuit.
 
I plan on ordering from Farnell, but there are a huge number of different components there, and I am in need for some tip on how to choose the correct types of components.
 
I checked the datasheet for the PIC 16F88, but also here I get the values with more, but still don't know what components to order.


 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 6155
The PIC's Timer 1 Oscillator on the T1OSI, T1OSO pins has absolutely *NOTHING* to do with its primary oscillator on the OSC1, OSC2 pins.   See datasheet section 4.2 Crystal Oscillator/Ceramic Resonators for typical values for the capacitors from OSC1, OSC2 to Vss.

The actual capacitance can be calculated from the crystal manufacturer's specified load capacitance.  In a Pierce oscillator the crystal 'sees' a load capacitance of the two capacitances to ground (at either side of it), effectively in series.  If they are identical, the capacitance to ground must therefore be double the specified load capacitance.  The actual capacitor value chosen must allow for the stray capacitance of the tracks, PIC pins and inside the PIC, so its usual to use the next lower preferred value.  Its usually fairly non-critical (within a factor of two) unless you need the crystal frequency to be as close as possible to its nominal value.

For the regulator, consult its datasheet for the minimum capacitor values to use and any other constraints (e.g. minimum ESR).   If there is more than 1" of track or wiring between the regulator's output capacitor and the PIC, or if the output capacitor is an electrolytic, a 0.1uF ceramic capacitor between Vdd and Vss at the PIC is recommended.   If there is a significant length of wire between the reservoir capacitor fed by the bridge rectifier and the regulator, it should have a separate input capacitor >= its minimum recommended value.

The reservoir capacitor has to be big enough to keep the regulator input above its dropout voltage between consecutive peaks of the full wave rectified supply from the bridge.  Q=CV and Q=It.  t in this case is 1/100 second, and V is the maximum drop you can tolerate from the peak output of the bridge down to the regulator dropout voltage.  You also need to  allow for low mains input voltage, so assume that the secondary voltage will only be 90% of its nominal value for this calculation, or if using a measured no-load peak voltage from the bridge, you need to measure the mains voltage, anc scale the peak voltage from the bridge in proportion to the nominal voltage of your mains supply divided by its actual value, before applying the 90% factor to allow for brownouts.

Once you have capacitor values, its just a matter of finding a supplier and ordering them, but watch out for minimum order charges.  If you have any doubts post a link to the distributor and their part numbers of the parts you have chosen to this topic and ask us to check them.
« Last Edit: July 26, 2017, 11:17:11 pm by Ian.M »
 
The following users thanked this post: Teza

Offline perieanuo

  • Regular Contributor
  • *
  • Posts: 110
  • Country: fr
When you choose your crystal, in datasheet you find the optimal value for capacitors.so you choose caps from quartz datasheet.regards,Pierre


Envoyé de mon iPad en utilisant Tapatalk
 
The following users thanked this post: Teza

Offline Teza

  • Contributor
  • Posts: 36
  • Country: no
@Ian.M
Oscillator:
I have no knoewledge at all about this, but is doing my best to understand your reply, forgive me if I get it wrong.
From what I understand the PIC 16F88 (and others) must have some quite accurate components mounted within some specificated restrictions, to get it to work properly.

Maby the easiest and best option for me is to use some kind of external clock/calendar chip, connected to OSC1 to avoid complicated beginner errors?
If so, is there a recomended chip I can order for this? (It is for general training use circuits to learn to use the PIC.)

Regarding the regulator, I'll have to find a detasheet and dive into this based on your input.

-----

My question was originally a bit more intended to:
What kind of component to use, like; Ceramic Capacitors, Film Capacitors, Aluminium Electrolytic Capacitors or any other types?
Voltage, is 15V ok or should I use 50V? (max 12V input, if supported by the LM7805)
 

Offline perieanuo

  • Regular Contributor
  • *
  • Posts: 110
  • Country: fr
Start with the 4 MHz crystal and after you learn a bit you can put a RTC  connected not to oscillator input but to I/O digital ports or don't put crystal and use internal oscillator for learning.I suggest you put the 4 MHz quartz and after if you want add some other stuff.regards,Pierre


Envoyé de mon iPad en utilisant Tapatalk
 

Offline perieanuo

  • Regular Contributor
  • *
  • Posts: 110
  • Country: fr
Capacitors the big ones you put electrolytic ones and the little ones ceramics (100nF and for quartz also ceramics those like 22-27 pF)


Envoyé de mon iPad en utilisant Tapatalk
 

Offline mariush

  • Super Contributor
  • ***
  • Posts: 3174
  • Country: ro
  • .
A bit unrelated to the actual question, but I spotted this issue in the schematic.

You have a single 100uF capacitor after the bridge rectifier (the four diodes that convert the AC voltage from transformer, to DC voltage).
Depending on how much current your project uses and the voltage of your transformer, 100 uF may not be enough.

A bridge rectifier converts the AC voltage (Vac) to DC voltage, resulting in voltage with a peak value  Vdc peak equal to

Vdc peak = sqrt(2) x Vac - 2 x Vdiode  = ~ 1.414 x V ac - 2 x 0.7v

So if your transformer outputs 6v AC , then the peak DC voltage will be Vdc peak = 1.414 x 6 - 1.4 = ~ 7v

But remember, this is a peak voltage...  you need to add a capacitor after the bridge rectifier in order to keep the minimum voltage above some threshold.
How big that minimum capacitance value needs to be depends on how much current your project will use.

By itself, without anything connected to it, the microcontroller will probably use less than 1mA, especially at such low frequency.  However, the linear regulator you chose itself (7805) probably needs at least around 3mA in order to output a stable 5v at its output.

So let's say you want at least 50mA , enough for the microcontroller and a few leds or something like that.
In order for a typical 7805 linear regulator to output 5v, the input voltage must be at least around 6.5v to 7v - the minimum voltage depends on how much current you need, for low current amounts like 50mA the minimum voltage is lower... let's go with 6.5v

So you have the peak dc voltage of 7v, you need at least 6.5v at any time, and you have a current of 50mA (0.05A) ... you can approximate the capacitance you need with this formula:

C (in Farads) =  Current / [  2 x (AC mains frequency) x (V dc peak - Vdc minimum) ]

For your values , C = 0.05A / [2 x 60Hz x (7v - 6.5v) ] = 0.05A / 60 =  8.333e-4 Farads , or around 83 uF  (unless i'm too tired and i got some zeroes wrong)

So for 50mA a single 100uF may be enough, but you may make this circuit and then reuse it with a more complex microcontroller circuit that uses more current and then you may be surprised that the circuit resets itself or has problems and you may not think of the linear regulator being the problem.

 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 6155
The PIC16F88 internal oscillator runs at up to 8MHz and also any power of 2 divisor of that frequency down to 125KHz, with +/-2% accuracy at room temperature.   As such, unless you are doing precise time-keeping or asynchronous serial communications, there is little point in using a crystal of 8MHz or under with a PIC16F88.   For general purpose use, I would therefore suggest a 16MHz or 20Mhz crystal, the latter being this PIC's maximum rated clock speed.  If you fit individual turned pin sockets where the crystal is to go, you can plug in different frequency crystals to suit your application, using the same load capacitors for all of them.   With no crystal and the PIC configured for INTOSC with I/O, the typical load capacitors are small enough that even with  them left in circuit, the pins in question can still be used for digital I/O.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf