0
\$\begingroup\$

From this answer, it says RS-232 defines the voltage levels and what not of a signal.

I want to be able to read barcodes on my microcontroller with something like this.

The closest datasheet I could find to a similar product was this:

The specsheet states that the scanner runs at 5V. However, from wikipedia:

For data transmission lines (TxD, RxD and their secondary channel equivalents) logic one is defined as a negative voltage, the signal condition is called "mark". Logic zero is positive and the signal condition is termed "space".

If the scanner works at 5V, how is this RS-232?

And regarding my question, from the datasheets I can't find any information regarding the actual transfer protocol, and how to interface to the scanner at a software level.

Is it assumed that the transfer protocol is UART?

\$\endgroup\$
2
  • \$\begingroup\$ @gbulmer Sorry about that, I fixed the link. This has a serial port for data transfer (or so it says...) \$\endgroup\$
    – tgun926
    Commented Aug 31, 2014 at 12:22
  • \$\begingroup\$ Okay, I have deleted my comment. So you might need an RS232 interface. \$\endgroup\$
    – gbulmer
    Commented Aug 31, 2014 at 12:42

2 Answers 2

1
\$\begingroup\$

It is entirely possible for a device two work from +5V, yet communicate using RS232 signal levels (~ -10V / +10V). There are common chips (max232 is a typical one) that do the conversion.

Note that between the micro-controller and the max232 chip communication uses the asynch/uart protocol, but using 5V (or 3.3V) and 0V. This is sometimes referred to as 'RS232 at TTL level' or 'uart at ttl level'. It is a bit foolish to convert from such level to true rs232, just to convert back 10cm later to the same ttl level, hence some devices communicate directly at this level.

When RS232 is mentioned it is generally assumed that the asynch/UART protocol is used.

Barcode readers generally work by inserting the barcode as characters into a data stream. When the connection is RS232, this takes the form of ASCII characters. When the barcode reader is connected to the keyboard (or nowadays via USB) it emulated keys being pressed, so it can provide input to any program that accepts keyboard input. You probably want to avoid this type because you would have to emulate USB and part of the USB stack on your micro-controller to get this to work.

\$\endgroup\$
1
\$\begingroup\$

RS-232 specifies more than just the electrical characteristics. According to Wikipedia1:

The standard defines the electrical characteristics and timing of signals, the meaning of signals, and the physical size and pinout of connectors.

Taking this in the context of the OSI 7-layer networking model2 TIA-232-F (as the current standard is) would occupy the lowest two levels of Physical (the cables, connectors and voltages) and Data (the start/stop bits, 7/8 data bits, parity, etc):

  1. Application
  2. Presentation*
  3. Session
  4. Transport
  5. Network
  6. Data
  7. Physical

Taking a subset of the TIA-232-F specification and changing the physical layer voltages (change +/-10V to 0-5V), but keeping the data layer intact results in what is commonly referred to as TTL Serial or sometimes RS-232/TTL, which is what the majority of microcontrollers speak.

With a single point-to-point system like TIA-232-F much of the OSI model can be ignored, and levels 3-5 become irrelevant. So you just have the Presentation layer, which is what the characters and bytes sent over the data medium represent (for plain text the presentation could be ASCII for example), and the Application - which is how you interpret or generate the data in the presentation.

*I was taught "Protocol" for this layer, not "Presentation" back in my university days. How times change, eh? Protocol makes much more sense to me though.

\$\endgroup\$
1
  • \$\begingroup\$ IIRC the TIA-232-F does NOT specify the start/stop protocol. \$\endgroup\$ Commented Aug 31, 2014 at 12:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.