PDA

View Full Version : Autobaud Detection without USART 12F683 etc



retepsnikrep
- 28th July 2010, 08:58
I'm using a 12F683 running with the internal oscillator at 8mhz and a SERIN2 routine catching incomming characters at 9600 baud. No problem.

However the transmitting device baud rate varies a bit and I was wondering if i could use some sort of autobaud routine to detect the length of a bit and work out the baud rate for the day!

I was thinking pulsin to measure a selection of bits, find the shortest, do some maths and then manipulate either the osctune register or the serin2 MODE low order baud rate bits?

Any comments. I can't use an enhanced pic and the transmitting device is not modifiable.

Anyone ever tried this?

mackrackit
- 28th July 2010, 09:18
When you say the transmitting device varies a bit do you mean it changes from say 9600 to 4800 or is it just off by a percentage?

I might add that the internal OSC on many of the MCUs are not stable enough for serial comms. That might also be part of the problem.

retepsnikrep
- 28th July 2010, 19:34
It varies a bit, say 1000 baud either way from 9600.

Charles Linquis
- 29th July 2010, 04:48
How best to do this depends on how fast it changes, and how many characters you have to "throw away" to determine the correct baud rate.

Two methods that come to mind:

#1. Send a string of characters to the PIC (0x80) for example. Have the PIC sit in a loop and wait for the line to go TRUE (probably high, in your case). Then use PULSIN to measure the LOW period. Calculate the baud rate from that. You should have 7 low bits at 9600 (73uSec). Adjust the baud rate accordingly.

#2. Send a known string of 4 or 5 characters. Start with SERIN2 baud rate value about 10% low. Increment until you receive the correct string . Store that value as baudrate #1. Keep incrementing until the checksum no longer matches Store that value as baudrate #2. Take the average of baudrate #1 and baudrate #2 and use that.

boroko
- 30th July 2010, 14:12
12F1822 if you can wait until 10 Oct 2010.
8 pin with USART.

Bo

retepsnikrep
- 30th July 2010, 16:09
Thanks for the ideas? I like the 12f1822