Little question about PIC16F

Thread Starter

FBorges22

Joined Sep 11, 2008
109
Greetings to all,

I have a little question about PIC16F877A microcontroller in a project that I am working on.

What are the maximum possible baud rate that I can achieve with this microcontroller with serial peripheral running in a clock of 20MHz?

If I understood correctly this microcontroller can achieve a baud-rate of 57600 bauds in the serial port (PIC16F877A datasheet, page 116).

Question is: Is possible to reach a 115200 baud-rate with this microcontroller?

Thanks,
FBorges22
 

Thread Starter

FBorges22

Joined Sep 11, 2008
109
Interesting table...

Can I use a 22.1184MHz crystal in this model? It would be better because I could reduce the margin of error even more!
 

leftyretro

Joined Nov 25, 2008
395
Bye the way, "baud rate error at 115.200Kbps is 1.36%" does not mean that 1.36% of the data will be corrupted. It just means that the mid bit sampling timing used to process a single character's data bits will be off from 'perfect' mid bit sampling point by that amount.

As asynchronous data timing is reset with each start bit, this is not an accumulating timing error. 1.36% timing error is nothing to be concerned about nor worth changing crystal frequency to try and improve it.

Lefty
 

Thread Starter

FBorges22

Joined Sep 11, 2008
109
If I try to use a 22.1184MHz crystal could cause damage to the uC? Because the datasheet says 20MHz limit... Another option is to use the 14.7654 crystal. However there is still something else that is concerning me to implement this solution.

The application that I am trying to build with the PIC16F is a spectral analyzer using the LabVIEW to monitor the quality of the Power Line.

This application consists in monitor a spectrum ranging to 0Hz and 2.5kHz in a fundamental frequency of 60Hz. Is possible to do this using this micro controller? Even if I use a 14.7654MHz crystal?

To do that I must send a single byte to the microcontroller and he must return another containing the information acquired from the internal A/D converter. Do you think that he is fast enough to do that?
 

eblc1388

Joined Nov 28, 2008
1,542
Another option is to use the 14.7654 crystal.
Your application requires intensive MCU power so its best to use the fastest crystal you can possibly use. If you want zero baudrate error, you can use 18.432MHz crystal. This is a very common crystal and you should have no problem obtaining it.
 

Thread Starter

FBorges22

Joined Sep 11, 2008
109
So if I use the 18.432MHz crystal can I build my power line spectral analyzer with no problems? In theory the PIC´s A/D converter is very fast... over 20us if I am not mistaken. According to the Nyquist theorem the measurement of a 60Hz sine wave signal is perfectly viable.
 

Thread Starter

FBorges22

Joined Sep 11, 2008
109
The resolution of the A/D is 10-bits and I think that is enough for my application. However I will only use 8-bits to measure the waveform.

Can I build the hardware with this circuit?
 

Attachments

Last edited:

nanovate

Joined May 7, 2007
666
The A/D is 10-bits but you rarely actually get the full 10-bits due to noise, INL , DNL, Vref drift and quantization errors-- especially if you are sampling very fast.

You need to add bypass caps on your PIC. What is the source impedance of the signal you are measuring?

Are you hooking up to the line voltage directly?
 

Thread Starter

FBorges22

Joined Sep 11, 2008
109
No, no... Of course not... I am using a signal conditioner to reduce the power line voltage to 110V to 1.5V(RMS).

The signal conditioner is composed by a 110V/12V transformer and a couple of resistors, zener diodes and a LM741 opamp to ajust the zero balance of the signal conditioner...

I am still projecting the circuit. Soon I will put here.

Obs: The figure annexed to this message contains a screenshot describing the application that I am trying to do with this PIC.
 

Attachments

Last edited:

eblc1388

Joined Nov 28, 2008
1,542
Hi FBorges22,

In your schematic, I would perfer to use two 18~22pF for the 18.432MHz crystal instead of 33pF.

You'll need pull up resistor on PIC MCLR pin or else the PIC will go crazy.

In the signal conditioner, my opinion is to shift the zero point up by 2.2V or more so you will not clip your negative signal as the peak for 1.5V rms is 2.12V. I think this is also what nanovate really meant by shifting the 1.5V signal.

Looks like you will be using the 5V input as your ADC reference so shifting 2.5V would be a good choice.
 

Thread Starter

FBorges22

Joined Sep 11, 2008
109
So if I follow all those tips my spectral analyzer is perfectly viable with this architecture?

Here is the fixed diagram. What do you think? Is he correct now?
 

Attachments

Last edited:

nanovate

Joined May 7, 2007
666
I would suggest using an external voltage reference for both the 2.5V offset and the A/D Vref if you really want max effective resolution. The LM7805 is good but you can have 100mV of output voltage shift in response to a transient. This translates to several output codes in the A/D (even in 8-bit mode). You want your reference voltages as stable and drift free as possible. You also want to have some bulk capacitance and a bypass cap near the VCC pin of the PIC-- something like a 22uF tantalum and a 0.1uF X7R ceramic capacitor.

Also I'd include a ICSP header on the board so that you can re-program on the fly if necessary.
 

Thread Starter

FBorges22

Joined Sep 11, 2008
109
Okay,

I redraw my diagram and I add some of the things that you suggest. However, I did not add the ISP programming capability in this board not yet. And I also added the signal conditioner circuit to get the AC signal from the power line. What do you think of him?

 

Attachments

eblc1388

Joined Nov 28, 2008
1,542
You don't need another 7805 to generate the VREF voltage. What you'll need is a 5V reference diode/module that is small and precise. You have to ask someone here for a particular part number. I only know of TL431 but there are more modern parts I don't know of that would do just the same function.

The 741 Opamp will not function with just 5V total supply voltage. You'll need a rail-to-rail Opamp for this one. Or you can power the Opamp from the +12V supply. In this case, you are correct to add a 5V voltage clamp to the Opamp output.

It is difficult to recommend a part if you do not have your physical location filled in so we know which part of the world you're in. Also the transformer connection is missing a return path and your signal conditioner is "unusual" in that you have use the offset control pin to bias the Opamp output. People usually don't use that method but condition the Opamp inputs instead. Again you will need to ask for a suitable Opamp circuit here.

Your goal is to produce a +/- voltage swing at the Opamp output upon a fixed the 2.5V reference level for input to the ADC.

What is your design opamp output voltage pk-pk at the output of the Opamp? 4V pk-pk for 120V AC input?

Edited: I have quickly cook up a simple signal conditioner for you using the MC34071 Opamp and the simulation is attached. It will produce an output centered on the 2.5V. You can change the gain if the output is too large for your design.



Note that the phase of the signal output is inverted but it is just a matter of swapping the transformer secondary winding polarity to get the correct phase.
 

Attachments

Last edited:
Top