Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Problems with serial communications from PIC

Status
Not open for further replies.

xieliwei

Member
I'm having problems trying to get serial communications working on a PIC16F88. The UART to serial level shifting is done using a MAX233.

1. Connecting TX to RX on the PC works (I get echo on the terminal)
2. Connecting TX and RX on the MAX233 works as well
3. Connecting TX and RX to the TX and RX of the PIC produces gibberish.
4. I've checked that my baud rates, parity and rate-control are correct.
5. Just in case I messed up my RX and TX connections, I tried swapping them in all permutations possible.

I'm thinking its because I'm using the internal RC oscillator of the PIC, which isn't very stable.

I also need help knowing how do I connect DTS and RTS if I don't want software /hardware rate control, and how would I do that if I want to use rate control.

Finally, someone please tell me if there is a standard for RX and TX notations?

Thanks! :D
 
If you are getting an echo without DTS and CTS before you connect the PIC then you don't need those connections with the PIC.

Pin 2 of the 9 pin RS232 connection is the transmit and connects to pin 4, 9, 18, 23 or 27 of the MAX233

Pin 5, 8, 19, 22 or 26 of the MAX233 connects to Pin 8 of the pic16F88.

I would not use the internal oscillator for serial communication timing. You should use a crystal or a crystal oscillator.

For testing I would suggest getting the PIC to light an LED when it recieves a byte.

Also if you convert what is recieved to lower case, and send it back out, it proves that reception and transmission are working.
 
Hello all, thanks for the replies!

Diver300, after wiring as you recommended, it still gave me gibberish, but at least I know the wiring is correct now. Alternating an LED for each character received did work, so I guess its a timing issue (the internal oscillator was that inaccurate?).

ericgibbs, wow, it was right under my nose, I'm embarassed! :$
I haven't seen the first link beore though, but its really very clear (better than wikipedia's), thanks!
 
Hmm, sorry for the disappearance, but its working now.

The problem seems to be a combination of a bad cable and a missing capacitor.

My homemade serial cable made from an old serial mouse cable apparently has broken links within the cable which made things go crazy. Using the cable off another old mouse gave me more consistent results.

Things were still not operating as they're supposed to though. After looking through the typical operating diagram for the MAX233, I remembered that I omitted the 1.0uF capacitor required between Vcc and GND. Things worked straight away after I added that capacitor.

Then a question came to my head. The chip's specifications stated 0 external capacitors required, which is why I thought I could omit the 1.0uF capacitor. Did I forget to read some fine print regarding their capacitor count?

And in the interest of learning, I have three questions.

What is the purpose of that capacitor; is it for filtering purposes or as a "power reserve" during current draw peaks?

If it is not there to act as a noise filter and since I already have an output capacitor attached to my voltage regulator's output, can I just "merge" the two capacitors (i.e. Remove both capacitors and replace with one with a value of the sum of the two capacitors removed)? They are (I think) in effect capacitors attached in parallel and should be equivalent to a single capacitor with a capacitance equal to the sum of the capacitance of the capacitors attached in parallel?

What effect does this new capacitor added have on the time taken for the power supply to stabilise on power up?

Sorry if my questions sound confusing, illogical, weird and/or stupid, I'm in the beginning stages of my learning and things are still shaky.

Also, please look at this other thread that I have started for some questions on a project I'm working on:

Very much appreciated! :D
 
xieliwei said:
What is the purpose of that capacitor; is it for filtering purposes or as a "power reserve" during current draw peaks?

Both really, but most importantly it makes both Vdd and Vss the same 'potential' for AC.

It's a critical part, and should ALWAYS be fitted in any electronic circuit.

PIC's are probably one of the most 'forgiving' parts, and sometimes will work quite happily with out it - but it should still be fitted!.
 
'decoupling' capacitors are required between supply and ground, one for every one or two ic's in the circuit. they should be as close as possible to the ic. i think 0.1uf ceramic is usual.

Nigel replied while i was typing.
 
Last edited:
xieliwei said:
What is the purpose of that capacitor; is it for filtering purposes or as a "power reserve" during current draw peaks?

If it is not there to act as a noise filter and since I already have an output capacitor attached to my voltage regulator's output, can I just "merge" the two capacitors (i.e. Remove both capacitors and replace with one with a value of the sum of the two capacitors removed)? They are (I think) in effect capacitors attached in parallel and should be equivalent to a single capacitor with a capacitance equal to the sum of the capacitance of the capacitors attached in parallel?

What effect does this new capacitor added have on the time taken for the power supply to stabilise on power up?

If components were perfect, and wires had no resistance or inductance, then you could just have one big capacitor.

In the real world, things are a lot more complicated. The biggest problem is that ICs like the MAX233 take current peaks that start and stop very quickly. The inductance of the wires or tracks going to the IC have significant inductance.

As a result, keeping the power supply stable in one place on the board is not good enough, as the voltage will not be stable in other places. To deal with this it is a good idea to add small capacitors at each IC.

Small capacitors are better for this because they have small inductance.

The large capacitors that are needed for the power supply are much larger, and they have more inductance. The extra little capacitors do not slow down the time to stabilise the power supply, because they are so much smaller.
 
Thank you all for the prompt reply!

Nigel Goodwin said:
Both really, but most importantly it makes both Vdd and Vss the same 'potential' for AC.
Hmm, I don't understand that sentence, please elaborate!

monkeybiter said:
one for every one or two ic's in the circuit
Erm, for every one or two ics? What does that mean?

To Diver300: Wow, thanks for the elaborate explanation!

Thank you all again, I've learnt a lot from this forum. :)
 
xieliwei said:
Hmm, I don't understand that sentence, please elaborate!

Circuits assume that the supply rails are all the same point as far as AC is concerned, and this is what the supply decoupling capacitors ensure.

From an AC point of view a circuit is completely different from a DC one.
 
In case anyone reads this in the future,

Diver300 said:
Pin 2 of the 9 pin RS232 connection is the transmit and connects to pin 4, 9, 18, 23 or 27 of the MAX233
The MAX233 has only 20 pins. Pin 3 of the 9 pin connector is data out from the PC and should be connected to pins 4 or 19.

Pin 5, 8, 19, 22 or 26 of the MAX233 connects to Pin 8 of the pic16F88.
Pins 3 or 20 should go to pin 8.

I would not use the internal oscillator for serial communication timing. You should use a crystal or a crystal oscillator.
There is no problem using the internal oscillator.

For testing I would suggest getting the PIC to light an LED when it recieves a byte.

Also if you convert what is recieved to lower case, and send it back out, it proves that reception and transmission are working.
Good tip.

Mike.
 
Nigel Goodwin said:
Circuits assume that the supply rails are all the same point as far as AC is concerned, and this is what the supply decoupling capacitors ensure.

From an AC point of view a circuit is completely different from a DC one.

Hmm, I'm still confused. Aren't decoupling capacitors supposed to 'remove' AC? Perhaps I don't understand what an AC circuit is like.


davemaster said:
What about the MAX233 capacitors? check the datasheet and put those as is recommended on it

From **broken link removed**, the number of external capacitors listed for the MAX233 is 0. Thus I thought that the capacitor used in the typical operating diagram was optional (in fact, I selected it because I thought it'll be a self-contained level shifter).
 
xieliwei said:
Hmm, I'm still confused. Aren't decoupling capacitors supposed to 'remove' AC?

No.

Perhaps I don't understand what an AC circuit is like.

Here's the same circuit, showing the same stage as Normal, as DC, and as AC - I didn't bother drawing the supply decoupling component in.
 

Attachments

  • Transistor_Amplifiers.GIF
    Transistor_Amplifiers.GIF
    5.1 KB · Views: 243
I'm sorry, but I still have problems understanding. I'm not very used to the idea of an AC circuit. Is it okay if you could explain the differences in all three circuits depicted?

Thanks!
 
It's really just that the supply rails are the same as far as AC is concerned, the decoupling capacitor is there to ensure that. So as far as an AC signal is concerned, the third diagram is what it sees - notice the two bias resistors are now in parallel, and the emitter resistor isn't there at all.
 
Status
Not open for further replies.

Latest threads

Back
Top