Novice question on how to set sampling rate of a PIC data logger

Thread Starter

Beetle_X

Joined Nov 2, 2012
63
I believe it is stated that the PIC18F452-I/P does not have a oscillator of any kind which does seem stupid but that is how it is worded. They do not say that it does not have a crystal. None of the micro controllers have a crystal but most of them have a tank circuit to time the instruction cycles, correct? The way it is worded ,the PIC18F452-I/P does not have a oscillator of any kind so the timer 'counter' has nothing to count unless a external one is added. Here's link to google books that spits it right out.https://books.google.com/books?id=rH1_DwAAQBAJ&pg=PA29&lpg=PA29&dq=PIC18FXX2+clock+speed&source=bl&ots=Rb4LSFn45p&sig=ACfU3U3Djv8yTY17fxGSmW6N4m8nlSHSKA&hl=en&ppis=_e&sa=X&ved=2ahUKEwjZ57O17pznAhWrdN8KHQMoBvUQ6AEwAnoECAoQAQ#v=onepage&q=PIC18FXX2%20clock%20speed&f=false

Edit: Also the PIC18F4520 states in the specs that it does have a internal oscillator while the PIC18F452 does not state this.
 
Last edited:

OBW0549

Joined Mar 2, 2015
3,566
The way it is worded ,the PIC18F452-I/P does not have a oscillator of any kind so the timer 'counter' has nothing to count unless a external one is added.
All of the PIC18Fxx2 have an internal oscillator; see page 19 of the data sheet. In fact, ALL PICs, of all PIC families, have an internal oscillator system of one sort or another, NO EXCEPTIONS.

The difference between the PIC18F4520 and the PIC18F452 is that the former has an internal RC oscillator (the INTIO option) which can generate the MCU's internal clock signal without any external components whatsoever, whereas the latter does not. But both parts, like nearly all other PICs, have an internal oscillator which can generate the MCU's clock by adding one or more external components (low, medium or high-frequency crystals, an external RC combination, or simply be driven from an external oscillator if desired.

Your statement that "the PIC18F452-I/P does not have a oscillator of any kind" is absolute, utter nonsense. I've no idea how you possibly could have gotten yourself so thoroughly confused on the matter of PIC oscillators, but you certainly have.

READ THE DATA SHEETS!
 
Last edited:

Thread Starter

Beetle_X

Joined Nov 2, 2012
63
I thank you taking a interest on this subject. I have really learned a lot.
On page 19 of the data sheet it only uses the terms 'crystal' or 'external' and INTIO does not come up in a search.The crystal and capacitor are part of the oscillator. A inductor/resistor and a capacitor are part of another style of oscillator.
So if parts of the oscillator are missing it can't function hence it is only 1/2 of a oscillator.
 

MrChips

Joined Oct 2, 2009
27,659
There is nothing out of the ordinary of the oscillator circuitry in the PIC18F452. It is no different from most Microchip PICs that I have seen. Call it 1/2 of an oscillator, or 3/4 or 7/8 or 15/16, it is still an oscillator to me. The manufacturer has been so kind and generous to leave it up to the user to decide how he/she wants to configure the clock using external input, crystal, or simple RC components.

Some other MCUs have the RC components built-in so that you can be up and running without external components. That hardly makes it any different from the other options. Either way, time-keeping functions are still doable.
 

OBW0549

Joined Mar 2, 2015
3,566
On page 19 of the data sheet it only uses the terms 'crystal' or 'external' and INTIO does not come up in a search.
Duh! That's because you're looking at the PIC18F452 data sheet, which does not have the INTIO option-- just like I said above. Try looking at the PIC18F4520 data sheet instead.

The crystal and capacitor are part of the oscillator.
Yup. They are the frequency-determining elements of the oscillator circuit. And they're external for two reasons: first, because integrating a crystal and capacitors into an integrated circuit package is extremely awkward; and second, they're external so you can choose what frequency you want the PIC to run at. You would like the option to choose operating frequency yourself, right?

A inductor/resistor and a capacitor are part of another style of oscillator.
I know of no PIC that uses an "inductor/resistor and a capacitor" in its oscillator circuit. NONE.

So if parts of the oscillator are missing it can't function hence it is only 1/2 of a oscillator.
So what? You find hooking up a crystal and loading caps to the PIC's oscillator pins following the directions right there in the data sheet to be too much of a challenge, too big a hurdle to get over? Get used to it, everybody else has.

OBTW: note that the self-contained INTIO oscillator in the PIC18F4520 is not suitable for applications-- like data logging-- that require accurate timekeeping:

intio.png
 

MrChips

Joined Oct 2, 2009
27,659
Exactly. The internal RC oscillator is for applications that do not require accurate and stable timing functions.
If you want to build a data logger with time-of-day features (e.g. time stamp), then you need

1) MCU with low power SLEEP or STOP modes
2) MCU that has a RTC (real time clock) that can run on an external 32768Hz crystal even when the CPU is stopped, or at least run in low power mode.
 

Thread Starter

Beetle_X

Joined Nov 2, 2012
63
The zero on the end of the part number makes it a different part, You posted the data sheet for the 452 and now you switched to the 4520 data sheet. One of the differences is whether the 452 has a stand alone and complete oscillator. It's cousin ,the 4520 does. I don't have the 4520 so I have to use a external oscillator. There is no work around for a missing piece of vital hardware.

I guess my point is not understood. The pic18F452 does not have a complete means to synchronize the cpu. Names are given to things by what they do. 1/2 of a oscillator can not function as a oscillator so it can not live up to it's name. It's only a moot point if you are not trying to program the 452 with no zero at the end.

Back to the subject of the thread; could a comparator knock down a value in a register to get a slower sampling rate?
 

OBW0549

Joined Mar 2, 2015
3,566
One of the differences is whether the 452 has a stand alone and complete oscillator. It's cousin ,the 4520 does. I don't have the 4520 so I have to use a external oscillator.
WRONG. You do not need an external oscillator. All you need to do is connect a crystal of the desired oscillator frequency, and its loading capacitors, to the PIC's oscillator pins:

xtal.png

This stuff is really, really, REALLY easy. Stop making it hard for yourself.

And with that, I'm done here.
 

BobTPH

Joined Jun 5, 2013
6,051
Where did you get the idea to use the 18f452 in the first place? This is a very old PIC that is "Not recommended for new designs" by Microchip.

It costs way more than more recent PICs that are higher performance and have many more features (like an internal RC oscillator.) You can get a 32-bit PIC for less money (not that I am recommending that.)

Hopefully, you now understand that your application is going to require an external crystal no matter what microcontroller you use.

I have a feeling that, at your level of expertise, you might be better off using Arduino, where these details have already been taken care of for you.

Bob
 
Top