PDA

View Full Version : Automatic Baud Rate Detection



titanvision
- 28th July 2005, 07:05
I am beginner with Pic Micro controller, my objective is use 16F876A I/SP and I want to automatically detect baud rates from any device. How can I do that, any ideas from seniors?

I use Latest Proton development Suite, and PICPRO BASIC version 2.46

Thank you all in advance

bot402
- 28th July 2005, 10:03
Within the PROTON samples folder there are two programs for detecting baud rate and setting up the USART to match. One for 16F devices and one for 18F devices.

Both of these programs could be converted to PBP as they are simple in operation.

picnaut
- 28th July 2005, 17:15
Hi Titanvision,

For PDS questions, go to --> http://www.picbasic.org/forum

:)

Cheers.

mytekcontrols
- 1st August 2005, 00:13
Ok I've got to ask the question...

How would one go about providing automatic baud rate detection with PBP?

I did a quick search of the forums, but did not find anything on this topic. If someone does know of an example, can you please post a link here. Or perhaps we can do some tinkering with it here, and come up with some code that'll work. I'll be doing some more research into this. So stay tuned...

mister_e
- 1st August 2005, 00:25
Well i think... just a thought, that is feasable and accurate if the Serial data that comes to the PIC have a Special kind of header like at least 2 bytes wide. Let's say the Master will send $55 as header
$55= %0101 0101
you measure the gaps between 1 and zero with internal timer or whatever else method and once it's done, you calculate the baudrate.

So, my assumption should be correct if the master send few $55 or $AA + some kind of special Synchro character.

at the end you have a pseudo code like
1. Measure incoming $aa $55 pulse width
2. calculate and set according baudrate
3. Waiting for synchro byte... bytes or string
4. Get serial data with according baudrate

titanvision
- 2nd August 2005, 05:22
Thanks you all, is there a codes samples can be offered?

As I mentioned I am beginner with proton development suite and pic basic pro compiler,

Mister e was given some good high light,
somehow my points is my target X device baud rate unknown, device it might be even or odd parity, I want to build a baud trace function for that, when I get correct handshake with target device I take that result in temporary variable as a my default baud rate for communicate with that device..
If I made connection to another X device process routines will be same,

Baud rates range can be 150 ~ 115000 it doesn’t matter what baud rate is come or generated from X device, for example it can be 9900.

So far I get some information from Other forms and manual of compilers what I am using for instance 1000000 / baud rate – 20 gives decimal numbers set up my device sufficient, if I know my target X device will communicate with baud rate for example 9600 above mentioned calculation formula result Hex format should be 54h .

It might be there is some limitation with micro controller according the clock rate however my theory I do not want to depend on micro controller serial port pins it can be shifted any I/O pin get a freedom of max usage of such a micro controller.

Regards

Joe

NavMicroSystems
- 2nd August 2005, 12:29
Thanks you all, is there a codes samples can be offered? . . .
Joe

Joe,
You are asking too much.

Start small.
Think about how this could be solved.
Steve's approach is something you could start with.

Let's assume the "unknown" device sends out a (more or less) continous datastream
at unknown Baudrate, Parity etc. and there is now way to influence that Datastream.
So there will be no $55 or $AA Pattern you could sync to.
It will be a challenge to detect the comms parameters.

Even worse if the "unknown" device sends out data on request only.

Again,
start small, let your PC transmit data and try to detect it on your PIC.
(and you'll soon see what I mean)

titanvision
- 4th August 2005, 04:43
Joe,
You are asking too much.

Start small.
Think about how this could be solved.
Steve's approach is something you could start with.

Let's assume the "unknown" device sends out a (more or less) continous datastream
at unknown Baudrate, Parity etc. and there is now way to influence that Datastream.
So there will be no $55 or $AA Pattern you could sync to.
It will be a challenge to detect the comms parameters.

Even worse if the "unknown" device sends out data on request only.

Again,
start small, let your PC transmit data and try to detect it on your PIC.
(and you'll soon see what I mean)

Thank you Ralph,

I understand what you mean; somehow I have short of experience with PDS and PBP compilers. Anyway your advice still appreciates

Regards,

Joe