Comunicacion Serial

download Comunicacion Serial

of 7

Transcript of Comunicacion Serial

  • COMUNICACIN SERIAL

    Protn IDE.

    Una de las formas ms populares de la comunicacin entre dispositivos electrnicos es la comunicacin serial. Hay dos tipos principales de comunicacin serial; sncrona y asncrona. El HRSin, HRSOut, HSerIn, HSerOut, RSin, RSOut, Sern y comandos SerOut se usan para enviar y recibir datos en serie asncronos. Mientras los comandosSHIn y SHOut son para uso exclusivo de comunicacin sncrona.

  • MAX232

    COMUNICACIN SERIAL

    Proton IDE.

  • El RS232 es la especificacin elctrica para las seales que usa el puerto serie del PC. A diferencia de las lgicas TTL, donde 5 voltios es un 1 lgico y 0 voltios es la lgica 0, RS232 utiliza -12 voltios para la lgica 1 y +12 voltios para la lgica 0. Esta especificacin permite comunicacin a travs de longitudes de cable ms largo sin amplificacin. La mayora de los circuitos que trabajan con RS232 utiliza un controlador de lnea /receptor (transceptor), o adaptador de niveles. Este componente hace dos cosas: -

    1. Convierte los 12 voltios de RS-232 a TTL compatible 0 a 5 voltios niveles.

    2. Invierte los niveles de tensin, de modo que la lgica de 5 voltios = 1 y 0 voltios lgica = 0.

    COMUNICACIN SERIAL

    Proton IDE.

  • Sintaxis

    SERIN Rpin { \ Fpin } , Baudmode , { Plabel, } { Timeout , Tlabel, } [ InputData ]

    COMUNICACIN SERIAL

    Proton IDE.

    BaudRate 8-bit no-parity inverted 8-bit no-parity true300 19697 3313600 18030 16461200 17197 8132400 16780 3964800 16572 1889600 16468 84

    Baudmode

    Sentencia Serin

  • DIM SerData AS BYTE

    Again:SERIN PORTA.0 , 24660 , P_ERROR , 10000 , TO_ERROR , [SerData]PRINT CLS , @ SerDataGOTO Again

    TO_ERROR: PRINT CLS , "Timed Out"GOTO Again

    P_ERROR: PRINT CLS , "Parity Error"GOTO Again

    COMUNICACIN SERIAL

    Proton IDE.

    Sentencia Serin

  • Sintaxis

    SEROUT Tpin { \ Fpin } , Baudmode , { Pace, } { Timeout , Tlabel, } [ OutputData ]

    COMUNICACIN SERIAL

    Proton IDE.

    BaudRate 8-bit no-parity inverted 8-bit no-parity true300 19697 3313600 18030 16461200 17197 8132400 16780 3964800 16572 1889600 16468 84

    Baudmode

    Sentencia Serout

  • SEROUT PORTA.0 , 16468 , 1000 , [ "Send this message Slowly" ]

    COMUNICACIN SERIAL

    Proton IDE.

    Sentencia Serout

    DIM FLT AS FLOATFLT = 3.1456SEROUT PORTA.0 , 16780 , [DEC FLT] ' Send 3 values after the decimal point

    DIM SerString[10] AS BYTE ' Create a 10-byte array.SerString[0] = "H" ' Load the first 5 bytes of the arraySerString[1] = "E" ' With the word "HELLO"SerString[2] = "L"SerString[3] = "L"SerString[4] = "O"SEROUT PORTA.0 , 16468 , [ STR SerString\5 ] ' Send 5-byte string.