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.

Connecting a Barcode reader to a PIC Microcontroller UART

Status
Not open for further replies.

mosh11

New Member
Hello all,

in my project i am building an interface between a Bar code reader and a Pic in order to transfer the bar codes to a ZigBee transceiver

i want the reader to talk to the pic via UART Port of the microcontroller?

i know that there are a Software uart and a hardware uart?

which one should i choose?

and how it can be implemented ?

Thank you

Ahmed salah
 
It depends on what the signal from the barcode reader is - is it standard serial data at RS232 levels?. If so, using a MAX232 and the hardware UART would probably be the best solution.
 
thanx nigel for the reply

the bar code reader is rs232 and it outputs +12v and -12v

so i will use max232 am i right?

but why using the hardware usart instead of the software uart ?

i want more information about hardware usart and software uart ?

the pins that i should connect to the barcode reader(
 
Last edited:
another question

should i use the same connection that's is given to connect the pic to a pc?

will this circuit connection work for the barcode reader ?

thank you

ahmed salah
 
If you're only listening for TX'd data from the barcode scanner and not sending anything to it you can use a clamp and zener diode to receiver RS232 signals. Transmitting is a little more tricky cause there's no garuntee an RS232 receiver will recognize a 0 volt signal as a mark.
 
If you're only listening for TX'd data from the barcode scanner and not sending anything to it you can use a clamp and zener diode to receiver RS232 signals.

You don't even need a zener, just a simple series resistor will do - PIC's already have clamping diodes. However, in either case, you can't use the hardware USART.

Transmitting is a little more tricky cause there's no garuntee an RS232 receiver will recognize a 0 volt signal as a mark.

No guarantee, but has anyone ever found something that doesn't work under those conditions?, certainly all PC's do - but again, you can't use the hardware USART.
 
You don't even need a zener, just a simple series resistor will do - PIC's already have clamping diodes. However, in either case, you can't use the hardware USART.



No guarantee, but has anyone ever found something that doesn't work under those conditions?, certainly all PC's do - but again, you can't use the hardware USART.


but you told me to connect the barcode reader i should use hardware USART?

and where i should i put the series resistor?
 
but you told me to connect the barcode reader i should use hardware USART?

You can only use the USART if you use a MAX232 (or similar) as these provide the required hardware inversion.

and where i should i put the series resistor?

You simply feed the RS232 signal through it to an I/O pin, the inbuilt protection diodes clip it to 5V for you - but you MUST use a software UART to do this, so you can do the inversion in the software.

If you check the Parallax BASIC Stamp, that's been doing it for decades.
 
I'll say this again real fast.. If you are only RECEIVING RS232 data and don't need to use conversion circuitry. If you need to SEND it that's a different story. The clamp diodes on an MCU are usually rated at no more than 1ma so at +12 -12 volts you need a 15k resistor in series. IF The MCU has rail clamp diodes. Verfiy with the PDF of your chip for their exact current ratings.
 
I'll say this again real fast.. If you are only RECEIVING RS232 data and don't need to use conversion circuitry. If you need to SEND it that's a different story. The clamp diodes on an MCU are usually rated at no more than 1ma so at +12 -12 volts you need a 15k resistor in series. IF The MCU has rail clamp diodes. Verfiy with the PDF of your chip for their exact current ratings.

And I'll repeat again, real fast :D

We're talking PIC's, if receiving you can use a single resistor, no problem, PIC's have protection diodes - but you CAN'T use the hardware USART. Likewise, you can transmit with nothing more than a piece of wire, but again, you CAN'T use the hardware USART - I've never heard of, or seen, RS232 not working perfectly in this way.

Like I mentioned earlier, check the BASIC Stamp manuals which do exactly this.
 
I don't know if there's any way you can invert the logic on the PIC's USART, but you could use a simple external inverter if need be. I did forget to mention that part my fault=) With the inverter you can feed it directly into the UART, asuming the UART pins have the clamp diodes as well. An inverter is a whole lot simpler than full level conversion.
 
I don't know if there's any way you can invert the logic on the PIC's USART

No there isn't.

but you could use a simple external inverter if need be. I did forget to mention that part my fault=) With the inverter you can feed it directly into the UART, asuming the UART pins have the clamp diodes as well. An inverter is a whole lot simpler than full level conversion.

But rather getting away from the simplicity of just a single resistor, admittedly it's only one transistor, a diode and two resistors, but that's considerably more complicated than one resistor.

A software UART is simple and easy, and if you're not wanting to use a MAX232, then it's probably as well to go the software route.
 
now i connected the circuit and put the max232 with its components(4 1uf capacitors).

in the datasheet of the max it says that if the pin T1in or T2in received low voltage the o/p will be high if the i/p is high then the o/p is low.

in my case the i/p voltage is 1.5v and the o/p is 3.7v !!!

should the o/p be 12v to transmit the signal to serial port?

i am supplying the max232 with Vcc=4.6v so what's wrong with it?
 
i measured the voltages with the multimeter and i am sure about the connection :

1uf capacitors between (1,3) (4,5) (6,gnd) (2,16)

16 Vcc and 15 gnd
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top