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.

Am I USING PIC UART CORRECTLY??

Status
Not open for further replies.
You must have a short on your board somewhere. However, it will not work as you still haven't got a level shifter and inverter.

Mike.
 
I agree with Pommie. You can use a MAX232 if you have a 5V supply or I used a MAX3232 for 3v3 supply with my USART applications.

Mike
 
thank you so much for your help. i cut off the dsub serial connector from the circuit, and did the same test by supplying 5V to one of its female holes and testing on other side with multimeter. only the same hole was 5V and the rest were 0. so im going to build the circuit again.


a few questions tho which im a bit confused about. in the datasheet for PIC16F628, under UART section, it says that it uses standard standard NRZ (non return to zero). does this mean that, the signal does not return to zero, i.e, instead of zero it will go to a negative value, then back up to a positive value without "stopping at" zero. if so this isnt TTL is it because ttl is 0 to 5V. if this is the case why do i need a max232 to convert ttl to rs232 if it isnt ttl in the first place because its NRZ? i searched but couldnt find the values of NRZ, i.e, what values the output of the uart will swing between e.g, -/+ 3V?


one more question, using multimeter, i checked on the serial end of the USB-serial dongle whilst it was connected and detected by laptop. the TX pin. it was reading something like -6.25V and other pins were either the same or 0. IF i need a max232 converter depending on answer u give to my question above, is the one in the following link ok so i dont buy wrong one...

**broken link removed**

it says from TTL will produce rs232 values of +/- 9V. will this work on what i am using because i think my device uses rs232 of +/- 6.25V. will it still work even tho this chip will produce slightly more?

if my serial port was using +/- 12V would i need a chip which produces 12V or more or could i get away with using one like on the link above?

also, assuming the uart is giving out values of 0-5V (in which case i dont kno what the NRZ is about), obviously i need a max-232 chip, but why do i need an inverter??

again thanks to those ppl who helped me u saved me a lot of headache & black hairs.
 
The data sheet is confusing where it states that nrz is used, the actual output is at TTL levels and needs to be inverted and level shifted to work with a PC. The level shifting isn't as important as the inversion which is why the simple transistor versions work (posted by Bill and by me earlier). The chip you linked to is the correct chip. If you google "pic max232" then you will gets lots of examples how to wire it up.

Mike.
 
hi blueroom thanks for your post. if im not mistaken youe circuit doesnt actually convert to rs232 but just acts as an inverted for the TTL logic coming out of the pic? are there any premade chips which u recommend from maplin electronics which i can buy for inverting the TTL logic, because i really want to keep the hardware components and soldering to a bare minimum due to debugging etc. im not sure which one to get. and to be honest, i dont understand actually why i have to invert the ttl logic from 0 to 5V and 5 to 0V. why does this inversioin have to be done? doesnt the pic uart take care of this? thanks
 
cyprio7 said:
hi blueroom thanks for your post. if im not mistaken youe circuit doesnt actually convert to rs232 but just acts as an inverted for the TTL logic coming out of the pic? are there any premade chips which u recommend from maplin electronics which i can buy for inverting the TTL logic, because i really want to keep the hardware components and soldering to a bare minimum due to debugging etc. im not sure which one to get. and to be honest, i dont understand actually why i have to invert the ttl logic from 0 to 5V and 5 to 0V. why does this inversioin have to be done? doesnt the pic uart take care of this? thanks

The MAX232 is the standard RS232 interface chip, and you should be able to find it at Maplin (or any component shop) - you can check my tutorials for how to connect it up, it's quite simple.

The PIC UART is designed to operate with such a chip, and as the MAX232 inverts the logic, any alternative has to. If you dump the hardware UART, and use a software one, then you can invert the logic in software - and use a single resistor feeding the receive pin as the interface (the BASIC STAMP does just that).
 
cyprio7 said:
hi blueroom thanks for your post. if im not mistaken youe circuit doesnt actually convert to rs232 but just acts as an inverted for the TTL logic coming out of the pic? are there any premade chips which u recommend from maplin electronics which i can buy for inverting the TTL logic, because i really want to keep the hardware components and soldering to a bare minimum due to debugging etc. im not sure which one to get. and to be honest, i dont understand actually why i have to invert the ttl logic from 0 to 5V and 5 to 0V. why does this inversioin have to be done? doesnt the pic uart take care of this? thanks
You've got to invert the signal from the hardware USART. Simple but not as cheap or common as a MAX232 is the DS275.
**broken link removed**
 
What happens if you have a DS275 at both ends of a serial connection.

From the data sheet.
"The DS275 Line-Powered RS-232 Transceiver Chip derives power from the data line providing an extremely low-cost and low-power RS-232 serial port interface."

Mike.
 
k im a lil confused coz of what blueroom and nigel said. just to confirm.... if i was to feed the data DIRECTLY from d pic uart to the PC, in terms of inversion nothing needs to be done, but it just needs to be converted from ttl to rs232.... however, because we are feeding it into a max232 chip to convert ttl to rs232, this chip will invert the signal from the PIC uart, which means, as soon as the data leaves pic uart, we invert it before supplying it to max232 chip, so that when max232 chip inverts it, and data leaves this chip, it is now in the correct "inversion" or polarity state? is this right? coz blueroom said it differently to nigel so its confused me a bit. thanks
 
cyprio7 said:
k im a lil confused coz of what blueroom and nigel said. just to confirm.... if i was to feed the data DIRECTLY from d pic uart to the PC, in terms of inversion nothing needs to be done, but it just needs to be converted from ttl to rs232.... however, because we are feeding it into a max232 chip to convert ttl to rs232, this chip will invert the signal from the PIC uart, which means, as soon as the data leaves pic uart, we invert it before supplying it to max232 chip, so that when max232 chip inverts it, and data leaves this chip, it is now in the correct "inversion" or polarity state? is this right? coz blueroom said it differently to nigel so its confused me a bit. thanks

No, you can't connect the PIC UART directly to a PC, because it needs to be inverted, it's designed to feed via a MAX232 (the PC already has an inverting RS232 driver inside it). If you use a software UART, then you can connect it directly - with a simple series resistor from PC TX to PIC RX, and a direct wire from PIC TX to PC RX (plus ground of course).
 
hi there... thanks for all your replies. i have purchased the chips from maplin(rip off), and drawn a schematic iv attatched it.

because people said i have to invert signal and level shift it, i thought i had to use a seperate inverter ic to invert, THEN feed the signal to the max232 chip. iv included the inverter ic in my schematic but you can ignore that as now i know i can just feed the lines from the pic directly into the max232 as this does the inverting?

a question tho, my usb-serial dongle uses +/-6.25V on the serial end for rs232..the MAX232CPE chip that im using uses slightly higher than this voltage...about +/- 10 or 12V. is it ok to still use this max chip with this dongle? i dont want to supply 12V if it takes 6.25V only and blow up my laptop or something. it may accept it but i just wanted the opinion of you guys, better to be safe than sorry. (capacitors and power lines etc have been omitted from my schematic)

and thanks for the help, much appreciated.
 
here is my schematic
 

Attachments

  • ttl rs232 converter circuit diagram2.jpg
    ttl rs232 converter circuit diagram2.jpg
    97.2 KB · Views: 256
Your DB9 connections are wrong. You need pin3 (you have pin 7) to RX (via max232), pin 2 to TX and pin 5 to ground. I'm assuming a 1 to 1 cable to a PC.

Mike.
 
The MAX232 does both the inversion and the voltage doubling.
You also need to add several more caps including the decoupling caps.
You should try Google as it's an easy find.
 

Attachments

  • 628uart.gif
    628uart.gif
    950 bytes · Views: 302
Last edited:
ok in some examples on the net, it shows capacitors with two straight parallel lines (circuit symbol), and some symbols with one straight line and one slightly curved line parrallel to each other, i take it the latter is polarised... this is the one iv seen in most examples so i take it i should use a polarised one which is called "electrolytic"? iv also noticed there are so many different shapes of capacitors does it matter which i use? i know i need a 1uF one, i just dont want to get the wrong one because there are so many types.

also please let me know if the max232 using slightly higher voltage than the +/- 6.25 V on my DB9 connection matters..will it still work without damaging my pc? thanks

and i will look at your tutorial nigel thanks, i was actually looking at it for manchester encoding/rf transmission but i got so confused because there is so much code but (no offence) not a lot of explanation to what is actually happening and how its working, so i was finding it hard to follow the code and know whats actually going on, but i will have a look again.

while im on the subject of RF though, i might as well ask you this. i purchased this tx/rx pair from maplin

**broken link removed**

it says they are "matched" or "paired", does this mean that this transmitter can only send to this reciever? i want to buy 2 pairs, so i end up with tx1.tx2,rx1,rx2. i want tx1 to be able to send to both rx's or an indivual specified one (i take it i use packet system for this like in your tutorial)..... but because it says these are "paired" it made me wonder wether i will be able to make them function in this way. i want either tx to be able to send to a specific, or all recievers.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top