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.
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.
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.
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.
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.