I need help

Başlatan Cesar35, 05 Ağustos 2016, 20:34:46

Cesar35

 Hello
I need help
I need to send temperature data to the PC
And receive PC data to drive 2 relays
More when I send the data the program crashes
I'm using timerout
When I send data to relay to it hangs
Thank you
CODELOOP_PRINCIPAL:

Serin2 RX_IN,84,1000,TIMEOUT,[WAIT("CMD"),RX]

SELECT CASE RX
CASE "A"
HIGH RELE1
CASE "B"
LOW RELE1
CASE "C"
HIGH rele2
CASE "D"
LOW rele2
END SELECT
PAUSE 300
GOTO LOOP_PRINCIPAL


TIMEOUT:

'DS18B20
OWOUT DQ,1,[$CC, $44] 'Start temperature conversion
pause 1000
OWOUT DQ,1,[$CC, $BE] 'Read the temperature
OWIN DQ,0,[temperature.LOWBYTE,temperature.HIGHBYTE]
temperature = temperature*/1600
Serout2 XT_OUT,84,[DEC2 (temperature/100),".",DEC2 temperature,13,10]
GOTO LOOP_PRINCIPAL

İlyas KAYA

Please add all code.. 
Göz odur ki dağ ardını görsün,
Akıl odur ki başa geleceği bilsin.!

aRci


mesgul      var  byte    'ısı okuma bittimi

CODELOOP_PRINCIPAL:

Serin2 RX_IN,84,1000,TIMEOUT,[WAIT("CMD"),RX]

SELECT CASE RX
CASE "A"
HIGH RELE1
CASE "B"
LOW RELE1
CASE "C"
HIGH rele2
CASE "D"
LOW rele2
END SELECT
PAUSE 300
GOTO LOOP_PRINCIPAL


TIMEOUT:

'DS18B20
OWOUT DQ,1,[$CC, $44] 'Start temperature conversion
bekle:
pause 5
OWIN DS1820,0,[MESGUL]       'okuma bittimi ?
if mesgul=1 then goto bekle 
OWOUT DQ,1,[$CC, $BE] 'Read the temperature
OWIN DQ,0,[temperature.LOWBYTE,temperature.HIGHBYTE]
temperature = temperature*/1600
Serout2 XT_OUT,84,[DEC2 (temperature/100),".",DEC2 temperature,13,10]
GOTO LOOP_PRINCIPAL

Cesar35

#3
Hello, how are you
The temperature is working well
The problem that when I send the camando to trigger the relay has time works that have not time to
Thank you

*****************************************
@ DEVICE pic16F628A
@ DEVICE pic16F628A, WDT_OFF
@ DEVICE pic16F628A, PWRT_ON
@ DEVICE pic16F628A, BOD_OFF
@ DEVICE pic16F628A, PROTECT_OFF
@ DEVICE pic16F628A, MCLR_OFF
@ DEVICE pic16F628A, INTRC_OSC_NOCLKOUT
   DEFINE OSC 4

TRISB=%00000000:PORTB=%00000000
TRISA=%11111110:PORTA=%11111110
CMCON=7
 
SYMBOL  XT_OUT=PORTA.0
SYMBOL  RX_IN=PORTA.1
SYMBOL  DQ=PORTA.3
SYMBOL  SOM=PORTA.2
SYMBOL  LED=PORTB.7

SYMBOL  RELE1=PORTB.0
SYMBOL  RELE2=PORTB.1


DUMMY VAR BYTE
RX    VAR BYTE
X     VAR BYTE

temperature   VAR  WORD            ' Temperature storage
count_remain  VAR  BYTE            ' Count remaining
count_per_c   VAR  BYTE            ' Count per degree C


GOSUB CONFIG'INICIALIZAÇÃO DO ESP8266 

'-------------------------------------------------------------------------------
LOOP_PRINCIPAL:
Serin2 RX_IN,84,1000,TIMEOUT,[WAIT("CMD"),RX]

SELECT CASE RX
CASE "A"                       
    HIGH RELE1       
CASE "B"
    LOW RELE1
CASE "C"
    HIGH rele2
CASE "D"
    LOW rele2
END SELECT
PAUSE 200
GOTO LOOP_PRINCIPAL   
'------------------------------------------------------------------------------
TIMEOUT:
     
'DS18B20
    OWOUT DQ,1,[$CC, $44] 'Start temperature conversion
    pause 1000
    OWOUT DQ,1,[$CC, $BE]  'Read the temperature
    OWIN DQ,0,[temperature.LOWBYTE,temperature.HIGHBYTE]
    temperature = temperature*/1600
    Serout2 XT_OUT,84,[DEC2 (temperature/100),".",DEC2 temperature,13,10]
GOTO LOOP_PRINCIPAL   
'---------------------------------------

ete

Solution is to use usart (heserin and hserout)  the command serin2 with timeout can not work. Some members is telling me serin command is working but I never seen it. Need to try.

Ete

Cesar35

hello Ete
okay
Vc has a program as an example of USART
min for use
Thank you

Cesar35

hello ete

Thank you worked here
It was so using USART 9600

Cesar35

Alıntı yapılan: Cesar35 - 05 Ağustos 2016, 22:32:20
Hello, how are you
The temperature is working well
The problem that when I send the camando to trigger the relay has time works that have not time to
Thank you

*****************************************
@ DEVICE pic16F628A
@ DEVICE pic16F628A, WDT_OFF
@ DEVICE pic16F628A, PWRT_ON
@ DEVICE pic16F628A, BOD_OFF
@ DEVICE pic16F628A, PROTECT_OFF
@ DEVICE pic16F628A, MCLR_OFF
@ DEVICE pic16F628A, INTRC_OSC_NOCLKOUT
   DEFINE OSC 4

TRISB=%00000000:PORTB=%00000000
TRISA=%11111110:PORTA=%11111110
CMCON=7
 
SYMBOL  XT_OUT=PORTA.0
SYMBOL  RX_IN=PORTA.1
SYMBOL  DQ=PORTA.3
SYMBOL  SOM=PORTA.2
SYMBOL  LED=PORTB.7

SYMBOL  RELE1=PORTB.0
SYMBOL  RELE2=PORTB.1


DUMMY VAR BYTE
RX    VAR BYTE
X     VAR BYTE

temperature   VAR  WORD            ' Temperature storage
count_remain  VAR  BYTE            ' Count remaining
count_per_c   VAR  BYTE            ' Count per degree C



'-------------------------------------------------------------------------------
LOOP_PRINCIPAL:
Serin2 RX_IN,84,1000,TIMEOUT,[WAIT("CMD"),RX]

SELECT CASE RX
CASE "A"                       
    HIGH RELE1       
CASE "B"
    LOW RELE1
CASE "C"
    HIGH rele2
CASE "D"
    LOW rele2
END SELECT
PAUSE 200
GOTO LOOP_PRINCIPAL   
'------------------------------------------------------------------------------
TIMEOUT:
     
'DS18B20
    OWOUT DQ,1,[$CC, $44] 'Start temperature conversion
    pause 1000
    OWOUT DQ,1,[$CC, $BE]  'Read the temperature
    OWIN DQ,0,[temperature.LOWBYTE,temperature.HIGHBYTE]
    temperature = temperature*/1600
    Serout2 XT_OUT,84,[DEC2 (temperature/100),".",DEC2 temperature,13,10]
GOTO LOOP_PRINCIPAL   
'---------------------------------------

ete

Cesar,
Pls. examine the project given on following link. It is an RF thermometer project and working with USART.
USART means, e specific pins ( hardware serial port ) should use on the project. I do not know if it is convenient for your project. You need to check and take decision.

http://etepic.com/index.php/topic,62.0.html

Regards
Ete

Cesar35

Hello thanks for the reply
I made a modification to the program for USART 9600
I made a correction in the temperature of the program now everything is normal functioning
Thank you

Powered by EzPortal