50 Baud rate

Hey guys,

I am trying to interface an old teleprinter to an arduino. Is it possible to make the arudino communicate at 50 baud? Any pointers would be welcome as I am currently staring at my board and a Putty window with a melted brain.

I have written the code to take care of translating the message to baudot code for the teleprinter and it is transferring at 5N2.

If anyone has an idea or a link to relevant reading material that would be really helpful.

Thanks,

-R

The arduino can, sure, need to set up registers per section 20 of the datasheet. Might be easier to use one of the software serial libraries to talk tot the printer, and the regular serial port to send/receive messages to/from the IDE serial monitor at normal speeds.

I think you’re stuck with software serial. I don’t think you can divide the clock low enough to get 50 baud from hardware serial.

DrAzzy: I think you're stuck with software serial. I don't think you can divide the clock low enough to get 50 baud from hardware serial.

50 BPS should be achievable for hardware at 16MHz for both U2Xn=0 and U2Xn=1.

How so?

From datasheet, we calculate the value for the baud register as:

UBRRn = (Fcpu / 16BAUD) - 1

So (16,000,000 / (16*50=800)) -1

So we would need UBRRn to be 19,999. But per datasheet, that’s a 12 bit register (the first four bits of UBRRH are not used), so the largest value it can take is 4095.

Am I missing something?

Oops, you're right . . . my mind is going, I can feel it Dave. There is no question about it. I can feel it.

I have written the code to take care of translating the message to baudot code for the teleprinter and it is transferring at 5N2.

But teleprinters do not use two stop bits but one and a half stop bits.

While this might work some times with two stop bits it is possible to get stuck in a mode that prints garbage and will not pull into sync. The half stop bit prevents that.

Incidentally the use of the name "baudot code" is a complete misnomer as it bears no relationship to the code that the the American engineer Baudot actually invented. The code used today is much more like the one invented by the English Engineer Murray. In fact there is only one code difference from Murray's to what is used today.

If you are just sending data to the teleprinter, it is pretty trivial to “bit bang” the protocol. There are lots of code examples on the web. Here is one example (standard 10 bits):

void sputchar( uint8_t c )
{
  c = ~c;  //check if inverted output needed!
  STX_PORT &= ~(1<<STX_BIT);            // start bit
  for( uint8_t i = 10; i; i-- ){        // 10 bits
    _delay_us( 1e6 / BAUD );            // bit duration
    if( c & 1 )
      STX_PORT &= ~(1<<STX_BIT);        // data bit 0
    else
      STX_PORT |= 1<<STX_BIT;           // data bit 1 or stop bit
    c >>= 1;
  }
}

5N2 is 1 start bit, 5 data bits, no parity, and two stop bits. I guess the stop-period needed depends on the hardware that will "move-along"

I guess the stop-period needed depends on the hardware that will "move-along"

No it is not related to mechanical hardware.

As I said in reply #6 this is a problem that can occur when latching on to transmissions that are already taking place. It is a function of the received data stream. For example a common channel filler message on the short wave bands is a station sending a continuous stream of "RY". If this were done with two stop bits then you are not guaranteed ever to lock to it. Do the analysis and see.

How do you get half a bit? It's either a bit, or it isn't! Unless you mean a half length bit = twice the frequency.

How do you get half a bit?

Just set the output pin halfway high.

Henry_Best: How do you get half a bit? It's either a bit, or it isn't! Unless you mean a half length bit = twice the frequency.

It is half the baud rate, so half as long. So the basic signal time on a 50 baud system is 20mS. That is the length of the start bit and the five data bits. The stop bit being one and a half bits (that is what everyone else calls it) is 30mS. The OP is using a stop bit of 40mS in length.

This is a time period in an asynchronous signal so it doesn't not equate to a frequency.

It may be interesting to google "Arduino RTTY".

R(adio)TTY, is still used by HAMs and a lot of HAMs use arduinos. A lot of data is sent at a baudrate of 45.45, but 50 is used as well.