115200 Baud to 9600 Baud Translator


Closed Thread
Results 1 to 17 of 17

Hybrid View

  1. #1
    ScottC's Avatar
    ScottC Guest

    Wink 115200 Baud to 9600 Baud Translator

    Has anyone done a translation table for serial commands? What I want to do is receive data in at 115200 and send out a different string at 9600. maybe 8 to 10 different commands. Is it Possible?

    Seems it is. I use Pic Basic Pro. I have done serial in, and serial out only, but never both at the same time, yet alone at different baud rates. I am still kinda new at this, and only delt with PIC16F84. If anyone can recommend a PIC, that would be great too!

    From what I can gather so far, looks like I'll use a 16F873 and a 22.1184 XTAL.

    Any ideas on how to go about this?

    Thanks,

    ScottC

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    depending of all your requirement, you can also whatever PIC with a internal USART like pic16f628, pic16F870 or elses.

    Use a 20MHZ will be enough to have a great 115200 baud reception.

    The only thing you'll have to do is to store every data receive in diferent variable or an array. once it's don send all of them serial. You'll be able to change the internal USART baudrate on the spot by changing only the SPBRG register.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    ScottC's Avatar
    ScottC Guest


    Did you find this post helpful? Yes | No

    Wink

    Steve,

    Thanks for the info. I will try just that. It will be a few days as I need to order some PICs.

    I have never worked with a UART before so that part should be interesting.

    Scott

  4. #4
    ScottC's Avatar
    ScottC Guest


    Did you find this post helpful? Yes | No

    Question SERIN2 Giving errors

    I don't understand why I am getting errors on this. Is my array set up right?

    If I replace BAUDIN with N2400 on SERIN2 line, I only get bad expresion during the compile
    Why?
    If I can get this to run at 9600, I would like to increase the input to 115200. What should I put in for the OSC? 20MHZ, and run a 22.1184MHZ xtal?

    Would like to use a 16F84A or 16F873A with UART
    Any Ideas?

    Thanks,

    ScottC

    DEFINE OSC 4 ' 20MHz oscillator
    RSDATA VAR BYTE[7] ' Data input array
    BAUDIN CON 16468 ' 115200,8,N,1 Serial In
    BAUDOUT CON 16468 ' 9600,8,N,1 for Serial Out
    TX VAR PORTA.0 ' Pin for TX
    RX VAR PORTA.1 ' Pin for RX
    '********************************************

    TRISA = %01000010

    '***************************** READ SERIAL PORT

    LOOP:

    SerIn2 RX,BAUDIN,[WAITSTR RSDATA\7] 'serial data in on PortA.1

  5. #5
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    You get the error because N2400 hasn't been defined.

    Declare N2400 as a constant first.

    N2400 CON 16780 ' <-- Baud modes shown in manual for serin2/serout2

    Now you can use N2400 with serin2 to set the baud mode.

    Note: Look at the DEBUG / DEBUGIN commands if you want high-speed serial without a hardware USART, odd value or fast crystal. With DEBUGIN you can easily get 115200bps with a 4MHz crystal. You can't with serin2.

    You can use the 16F84A running @20MHz with DEBUGIN receivng at 115200, and serout2 re-sending at 9600, but you'll want a crystal speed > 4MHz for serin2 @ 9600 if you want reliability.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  6. #6
    ScottC's Avatar
    ScottC Guest


    Did you find this post helpful? Yes | No

    Default Debugin

    Bruce,

    Thanks for the info, but to run up the rate, what number do I use for 115200?
    The manual only shows values up to 9600 baud using 4 mhz xtal. Or is there a way to calculate that number or do you "FOOL" PBP by substituting a different xtal?

    Scott

  7. #7
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    As shown in the manual, to find the value for a given baud rate, use the equation (1000000/baud)-20. This doesn't work for serin2/serout2 @ 115200 bps.

    With DEBUGIN it's simple.

    DEFINE DEBUGIN_REG PORTC
    DEFINE DEBUGIN_BIT 7
    DEFINE DEBUGIN_MODE 0 '1 = Inverted, 0 = true
    DEFINE DEBUG_BAUD 115200

    Yes. There are ways to trick PBP into working at higher data rates with serin2 & serout2, but then everything else in your program is whacked timing wise since PBP adjusts timing for everything else based on the defined osc speed.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

Similar Threads

  1. A Serial GLCD 128x64 Simple Project
    By Oldspring in forum Off Topic
    Replies: 0
    Last Post: - 8th March 2010, 20:58
  2. Replies: 14
    Last Post: - 20th March 2008, 13:54
  3. pic18f4520 baud rate change to 115200
    By caltex88 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 30th September 2007, 08:41
  4. Auto Baud Rate Detection
    By mytekcontrols in forum Serial
    Replies: 10
    Last Post: - 31st October 2005, 02:17
  5. Baud Rate and Timing Calculator
    By picnaut in forum General
    Replies: 3
    Last Post: - 23rd January 2004, 16:48

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts