ESTANDAR RS422

6

Click here to load reader

description

Ejercicio de comunicacion entre micrcontroladores pic utilizando el estandar RS422

Transcript of ESTANDAR RS422

Page 1: ESTANDAR RS422

REDES Y COMUNICACIONES

JOHN FREDY MARTÍNEZ CARDONA MANTENIMIENTO ELECTRÓNICO

ESTANDAR RS-422 Tomar dos microcontroladores PIC y conectarlos vía Rs422, en cada uno conectar a una entrada análoga un potenciómetro de 5K para entrar con una señal de 0 a 5 voltios, también conecte dos led llamados LH y LL, Los led deben prender cuando el voltaje análogo sea mayor a 4 voltios (LH) y menor 2 voltios (LL). Con la entrada análoga de un PIC deben prenderse los led del otro. PROGRAMA EN MIKRO-BASIC program RS422 dim vd0 as word dim receive as byte Adcon1= 0x8e trisb=0 portb=0 Uart1_Init (9600) delay_ms(100) main: if Uart1_Data_Ready()then receive=Uart1_Read() select case receive case 0 portb.b0=0 portb.b1=0 case 1 portb.b0=1 portb.b1=0 case 2 portb.b1=1 portb.b0=0 end select end if vd0=Adc_Read(0) if (vd0=$0) and (vd0<$14) then Uart1_Write(0) end if if (vd0>$199) and (vd0<$332) then Uart1_Write(0) end if if vd0>$332 then Uart1_Write(1) end if if vd0<$199 then Uart1_Write(2) end if

Page 2: ESTANDAR RS422

REDES Y COMUNICACIONES

JOHN FREDY MARTÍNEZ CARDONA MANTENIMIENTO ELECTRÓNICO

goto main end. SIMULACION EN PROTEUS Caso 1

Las entradas analógicas de los dos PICs leen voltajes menores a 2 voltios por medio de los potenciómetros. En este caso los dos led LL están encendidos.

Page 3: ESTANDAR RS422

REDES Y COMUNICACIONES

JOHN FREDY MARTÍNEZ CARDONA MANTENIMIENTO ELECTRÓNICO

Caso 2

Las entradas analógicas de los dos PICs leen voltajes mayores a 2 voltios y menores a 4 voltios por medio de los potenciómetros. En este caso todos los led están apagados.

Page 4: ESTANDAR RS422

REDES Y COMUNICACIONES

JOHN FREDY MARTÍNEZ CARDONA MANTENIMIENTO ELECTRÓNICO

Caso 3

Las entradas analógicas de los dos PICs leen voltajes mayores a 4 voltios por medio de los potenciómetros. En este caso los dos led LH están encendidos. Ahora podremos observar la condición inicial del ejercicio, la entrada analógica del pic U1 en este caso debe prender los led del pic U4.

Page 5: ESTANDAR RS422

REDES Y COMUNICACIONES

JOHN FREDY MARTÍNEZ CARDONA MANTENIMIENTO ELECTRÓNICO

Entrada análoga del pic U1 prende y apaga los leds conectados al puerto b del pic U4.

Page 6: ESTANDAR RS422

REDES Y COMUNICACIONES

JOHN FREDY MARTÍNEZ CARDONA MANTENIMIENTO ELECTRÓNICO

Entrada análoga del pic U4 prende y apaga los leds conectados al puerto b del pic U1.