10-02-2014 07:32 PM
hola a todos estoy tratando de comunicar labview con pic 16f877a a traves de rs232. mi problema es que al presionar el boton automatico (ver programa) la transmision y recepcion de datos corre bien, pero al presionar horario me da un error subrayando visa read y obligandome a cerrar la aplicacion adjunto imagen de error, programa labview y progrma pic lo dejare aca abajo
'DEFINE OSC 4
@ DEVICE PIC16F877A
@ DEVICE PROTECT_OFF,CPD_OFF,WDT_OFF,PWRT_ON,BOD_OFF,LVP_OFF
INCLUDE "modedefs.bas" ;incluyen los modos de comunicación
TRISA = $FF
TRISB = $F1
TRISC = $BF
TRISD = $F3
serial VAR BYTE ;variable de almacenamiento de 255
releF VAR portd.2 ;nombres para los pines
led var portd.4
x var byte
entra var portb.0
salida var portb.1
SYMBOL TxD = PORTC.6
SYMBOL RxD = PORTC.7
inicio:
; Inicializar los puertos
PORTB=$00
PORTC=TRISC
PORTD=TRISD
;3 parpadeos del led que indica funciona
FOR x =1 TO 3
HIGH led
PAUSE 200
LOW led
PAUSE 200
NEXT
PAUSE 500
recibir:
pause 1000
SERIN RxD,T9600,serial ; comparar con pruebaredes
SELECT CASE serial
CASE "A" ; A
GOTO automatico
CASE "B" ; B
GOTO horarioapa
CASE "C" ; C
GOTO horarioenc
CASE ELSE
SEROUT TxD,T9600,["comando invalido.",13,10]
END SELECT
PAUSE 500 ; Retardo para estabilizar el puerto
goto recibir
automatico:
pause 1000
SEROUT TxD,T9600,["control automatico.",13,10]
if entra=1 then
high salida
SEROUT TxD,T9600,["luminaria encendida",13,10]
PAUSE 1000
goto recibir
else
low salida
SEROUT TxD,T9600,["luminaria apagada.",13,10]
PAUSE 1000
goto recibir
endif
horarioapa:
low salida
SEROUT TxD,T9600,["control horario.",13,10]
low salida
PAUSE 1000
SEROUT TxD,T9600,["luminaria apagada.",13,10]
PAUSE 1000
goto recibir
horarioenc:
SEROUT TxD,T9600,["control horario.",13,10]
PAUSE 1000
high salida
PAUSE 1000
SEROUT TxD,T9600,["luminaria encendida",13,10]
10-03-2014 04:27 PM
Buenos días,
Cuándo “Control Horario” es activado cual es el estado de “Automático”? O sea, lo que estoy tratando de entender es si estás tratando de realizar 2 escrituras a la vez.
En general me gustaría recomendarte que trates de usar los cables de error para definir el flujo de datos. Igualmente te beneficiarias al mejorar el manejo de errores. El patrón de diseño de máquina de estados es usualmente utilizado para este tipo de tareas.
Podrás encontrar mas información de las posibles causas del error -1073807298 en los siguientes enlaces:
http://digital.ni.com/public.nsf/allkb/60DDFED7EFEFE7188625705700750821
http://digital.ni.com/public.nsf/allkb/B99D923DFC18555786256F15004B87B0
Saludos,
MCOTO
10-03-2014 09:38 PM
Mostly this happens only because of two reason, 1. Serial port connection after initializion 2. connection is already in use.
In your application, you are writing and reading but where output of VISA WRITE and VISA READ goes. This output must be connected.
what about VISA close. From where it is getting input?
10-03-2014 11:34 PM
@Ranjeet_Singh wrote:
Mostly this happens only because of two reason, 1. Serial port connection after initializion 2. connection is already in use.
In your application, you are writing and reading but where output of VISA WRITE and VISA READ goes. This output must be connected.
what about VISA close. From where it is getting input?
I'm leaning towards reason #2. It's never a good idea to have parallel I/O to the same instrument.
10-04-2014 01:19 AM
I agree that one VISA should or cant be used in parallel, we need to ensure this is done in sequential