Autor Tema: Comandos Serin y serout  (Leído 3321 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado risanti13

  • PIC12
  • **
  • Mensajes: 66
Comandos Serin y serout
« en: 05 de Noviembre de 2003, 09:32:00 »
tengo una idea para realizar un  control de a traves Infrarojo y usando el pic16f84 y el comando serin y serout  para realizar   un tX y un RX .

Ejemplo . que el tx  posee dos pulsadores A1 y B1
y el Rx posea dos salidas  C1 y C2
 entonces cuando se pulsa A1 se accione C1
  cuando  se pulsa B1  se accione c2

mi pregunta es si se puede usar el serin o serout para realizar esto .

y si es posible  me pueden dar un ejemplo del codigo en pic basic pro  y como es eso de la paridad y bit de partida y parada



Desconectado ejmc

  • PIC18
  • ****
  • Mensajes: 311
RE: Comandos Serin y serout
« Respuesta #1 en: 08 de Noviembre de 2003, 00:50:00 »
HOLA LO UNICO QUE TEE PUEDO DAR SON ESTOS EJEMPLOS
EJEMPLO1:
" PicBasic Pro program to send and receive from the hardware serial port

" Define LOADER_USED to allow use of the boot loader.
" This will not affect normal program operation.
Define   LOADER_USED   1

" Define LCD registers and bits
Define  LCD_DREG        PORTD
Define  LCD_DBIT        4
Define  LCD_RSREG       PORTE
Define  LCD_RSBIT       0
Define  LCD_EREG        PORTE
Define  LCD_EBIT        1


char    var     byte            " Storage for serial character
col     var     byte            " Keypad column
row     var     byte            " Keypad row
key     var     byte            " Key value
lastkey var     byte            " Last key storage


        ADCON1 = 7              " Set PORTA and PORTE to digital
        Low PORTE.2             " LCD R/W line low (W)
   Pause 500      " Wait for LCD to startup

        OPTION_REG.7 = 0        " Enable PORTB pullups

        key = 0                 " Initialize vars
        lastkey = 0


        Lcdout $fe, 1           " Initialize and clear display

loop:   Hserin 1, tlabel, [char]        " Get a char from serial port
        Lcdout char             " Send char to display
tlabel: Gosub getkey            " Get a keypress if any
        If (key != 0) and (key != lastkey) Then
                Hserout [key]   " Send key out serial port
        Endif
        lastkey = key           " Save last key value
        Goto loop               " Do it all over again

" Subroutine to get a key from keypad
getkey:
        key = 0                 " Preset to no key
        For col = 0 to 3        " 4 columns in keypad
                PORTB = 0       " All output pins low
                TRISB = (dcd col) ^ $ff " Set one column pin to output
                row = PORTB >> 4        " Read row
                If row != $f Then gotkey        " If any keydown, exit
        Next col

        Return                  " No key pressed

gotkey: " Change row and column to ASCII key number
        key = (col * 4) + (ncd (row ^ $f)) + "0"
        Return                  " Subroutine over

        End

EJEEMPLO2:
" SERIN & SEROUT Commands
"
" Upper case serial filter.

        Include "modedefs.bas"          " Include serial modes

SO      con     0                       " Define serial out pin
SI      con     1                       " Define serial in pin
B0      var     byte

loop:   Serin SI,N2400,B0                       " B0 = input character
        If (B0 < "a" or (B0 > "z" Then print  " If lower case, convert to upper
   B0 = B0 - $20
print:  Serout SO,N2400,[B0]                    " Send character
        Goto loop                               " Forever

TODAVIA NO HICE NADA CON ESAS INSTRUCCIONES, PERO CON LOS EJEMPLOS SE APRENDEE MUCHO NO??
ESPERO QUE TE SIRVA.
DOS COSITAS:_A)COMO SE PONE UN ARCHIVO PARA NO MANDAARLO ASI,CON LOS ``Fichero adjunto´´ NO PUEDO.
                      _B)COMO PONGO UNA FOTO ALADO DELL MENSAJE.

Desconectado marmatar

  • Moderadores
  • PIC24H
  • *****
  • Mensajes: 1220
    • MSTools
RE: Comandos Serin y serout
« Respuesta #2 en: 08 de Noviembre de 2003, 16:02:00 »
Hola ejmc...
Para subir un archivo, ya no es posible al foro por falta de espacio... pero hay un almacen del foro donde puedes subirlo y luego colocar un link a ese lugar en tu mensaje.
http://miarroba.com/foros/ver.php?id=132071

Para colocar la foto al lado del mensaje debes editar tu perfil... la foto puede ser un avatar a elección o una foto que agregues.

Un abrazo...
marmatar
Lo posible ya está hecho, entonces hagamos lo imposible - Platón

Desconectado liminix

  • PIC12
  • **
  • Mensajes: 58
Re: Comandos Serin y serout
« Respuesta #3 en: 14 de Julio de 2007, 17:09:49 »
Código: [Seleccionar]
holasssssssssssssssssss si se puede asi  sew ase :)


--------------------------------------------------------------------------------

Y para subir las imagenes de los circuitos, uso la tecnica heredada por Lord:

1.- Capturas la imagen de tu circuito
2.- La guardas con la extension que quieras
3.- la Subes a http://www.imageshack.us/
4.- Copias el  link que dice Direct link to image (despues de que se adjunte)
5.- En tu respuesta añades el siguiente codigo:

Código:

 [img] la direccion que copiaste [/img]

y listo se veran todas las imagenes que quieras