Valvula motorizada
1. Programa de control para un microprocesador que controle el cierre y apertura de total de una válvula entre 0 y 100% en pasos de 10%, para ello se deberátener un pulsador de para incrementar y otro para decrementar dicho porcentaje. Además se debe visualizar el setpoint (porcentaje de apertura) deseado y el valor actual de apertura de la válvula endisplays o en un LCD.
Programa
$regfile = "m16def.dat"
$crystal = 8000000
Config Portb.0 = Output
Config Portb.1 = Output
Config Portb.6 = Output
Config Portb.7 = Output
Config Lcd = 16 * 2Config Lcdbus = 4
Config Lcdpin = Pin , Db4 = Portc.2 , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5 , E = Portc.1 , Rs = Portc.0
Dim Cont As Byte
Dim S As Byte
Dim A As String * 15
Dim SpointAs Byte
Spoint = 0
Cont = 0
Portb.0 = 0
Portb.1 = 0
Portb.6 = 0
Portb.7 = 0
On Int0 Incrementa
On Int1 Decrementa
Enable Interrupts
Config Int0 = Falling
Config Int1 = Falling
EnableInt0
Enable Int1
For S = 0 To 20
Locate 1 , 4
Lcd "INSTRUMENTACION "
Locate 2 , 6
Lcd "INDUSTRIAL"
Shiftlcd Right
Waitms 200
Next
Cls
Locate 1 , 5
Lcd "PRACTICA "
Locate 2 , 8
Lcd"6"
Wait 1
Cls
S = 0
For S = 0 To 20
Locate 1 , 15
Lcd "ELI "
Waitms 200
Next
Cls
Locate 1 , 4
Lcd "CONTROL DE "
Locate 2 , 5
Lcd "VALVULA"
Wait 2
Cls
Do
Locate 1 , 1
Lcd"Porcentaje: " ; Spoint ; "%"
Locate 2 , 1
Lcd "Estado: " ; A
Wait 1
Cls
Loop
End
Incrementa:
Incr Cont
If Cont < 11 Then
Portb.0 = 1
Portb.6 = 1
A = "Abriendo"
Spoint = Spoint + 10Waitms 200
If Spoint > 100 Then
Spoint = 100
End If
Portb.0 = 0
Portb.6 = 0
Else
Portb.0 = 0
Portb.6 = 0
A = "NO PUEDE"
Cont = 10
End If
Return
Decrementa:
Decr Cont
If Cont < 11Then
Portb.1 = 1
Portb.7 = 1
A = "Cerrando"
Spoint = Spoint - 10
Waitms 200
If Spoint < 10 Then
Spoint = 0
End If
Portb.1 = 0
Portb.7 = 0
Else
Portb.1 = 0
Portb.7 = 0
A = "NO...
Regístrate para leer el documento completo.