Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Forums > Electronic Projects Design/Ideas/Reviews


Electronic Projects Design/Ideas/Reviews Are you building an electronic project or want to? Maybe you need some assistance? Come and submit your electronic questions here and let our experienced members find a solution.

Reply
 
LinkBack Thread Tools Display Modes
Old 22nd March 2008, 10:09 PM   (permalink)
Default Problems with serial communications from PIC

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!
xieliwei is offline  
Old 22nd March 2008, 11:53 PM   (permalink)
Default

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.
Diver300 is offline  
Old 23rd March 2008, 09:46 AM   (permalink)
Default

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

Hi,
Google for 'RS232 standards'

http://www.camiresearch.com/Data_Com..._standard.html

http://en.wikipedia.org/wiki/RS232
__________________
Eric
"Good enough is Perfect"

PIC tutorials:
Gramo's: www.digital-diy.net/
Bill's: www.blueroomelectronics.com/
ericgibbs is offline  
Old 23rd March 2008, 10:41 AM   (permalink)
Default

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!
xieliwei is offline  
Old 23rd March 2008, 12:45 PM   (permalink)
Default

You might have a look at my tutorials, the internal oscillator in a 16F628 is fine at 9600 baud, and probably higher as well.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 19th April 2008, 11:22 AM   (permalink)
Default

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: http://www.electro-tech-online.com/s...d.php?p=304514

Very much appreciated!
xieliwei is offline  
Old 19th April 2008, 11:31 AM   (permalink)
Default

Quote:
Originally Posted by xieliwei
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!.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 19th April 2008, 11:37 AM   (permalink)
Default

'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 by monkeybiter; 19th April 2008 at 11:39 AM.
monkeybiter is offline  
Old 19th April 2008, 11:40 AM   (permalink)
Default

Quote:
Originally Posted by xieliwei
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.
Diver300 is offline  
Old 19th April 2008, 03:11 PM   (permalink)
Default

Thank you all for the prompt reply!

Quote:
Originally Posted by Nigel Goodwin
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!

Quote:
Originally Posted by monkeybiter
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 is offline  
Old 19th April 2008, 03:31 PM   (permalink)
Default

Quote:
Originally Posted by xieliwei
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.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 19th April 2008, 03:45 PM   (permalink)
Default

In case anyone reads this in the future,

Quote:
Originally Posted by Diver300
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.
Pommie is online now  
Old 19th April 2008, 04:32 PM   (permalink)
Default

Greetings,

What about the MAX233 capacitors? check the datasheet and put those as is recommended on it
davemaster is offline  
Old 20th April 2008, 05:44 PM   (permalink)
Default

Quote:
Originally Posted by Nigel Goodwin
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.


Quote:
Originally Posted by davemaster
What about the MAX233 capacitors? check the datasheet and put those as is recommended on it
From this page, 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 is offline  
Old 20th April 2008, 06:49 PM   (permalink)
Default

Quote:
Originally Posted by xieliwei
Hmm, I'm still confused. Aren't decoupling capacitors supposed to 'remove' AC?
No.

Quote:

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.
Attached Images
File Type: gif Transistor_Amplifiers.GIF (5.1 KB, 17 views)
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Reply

Bookmarks

Thread Tools
Display Modes



Similar Threads
Title Starter Forum Replies Latest
still the same pic problems kutalinelucas Micro Controllers 12 16th February 2008 06:07 PM
how send serial data with PIC HCT-Pirate Micro Controllers 7 3rd February 2008 05:27 PM
Problems switchin relay with PIC Andy1845c General Electronics Chat 5 17th November 2007 07:14 PM
Need help badly on Inchworm and MPLAB thushy Micro Controllers 14 11th March 2007 07:05 PM
USB to Serial problems spondootre Micro Controllers 12 28th November 2006 09:09 AM



All times are GMT. The time now is 05:05 AM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.

eXTReMe Tracker