Autor Tema: ayudita!  (Leído 2342 veces)

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

Desconectado jhonathanve

  • PIC12
  • **
  • Mensajes: 88
ayudita!
« en: 12 de Abril de 2011, 19:29:13 »
Hola a todos como están?.. el señor  mleyton en el añio 2008 publico un tema con el sht15 en pic basic. El mismo el coloca el archivo . hex. He realizado pruebas y el programa no me da incluso con el archivo hex que el deja no me da. He probado con un programa sencillo para ver si he conectado los pines en la lcd correctamente y me ha ido muy bien.. si alquien me podría ayudar a detectar el error por favor.. gracias d ante mano!!




'****************************************************************
'*  Name    : sht15.BAS                                         *
'*  Author  : [Mauricio Leyton Carrasco]                        *
'*  Notice  : Copyright (c) 2005 [set under view...options]     *
'*          : All Rights Reserved                               *
'*  Date    : 01/19/2007                                        *
'*  Version : 1.0                                               *
'*  Notes   :   Leer la data de temperatura y humedad  para ser *
'*              enviada por la RS232, asi como tambien a un dis-*
'*              play LCD de 2 x 16, mostrando en el display las *
'*              temperaturas-humedad maxima y minima            *     
'*              Mantener la linea Define LOADER_USED 1          *
'****************************************************************
Define   LOADER_USED   1
include "modedefs.bas"

' Define LCD pines
Define  LCD_DREG        PORTD 'puerto D para LCD
Define  LCD_DBIT        4      'bit de partida
Define  LCD_BITS        4       'cantidad de bit
Define  LCD_RSREG       PORTE   'puerto E para RSREG
Define  LCD_RSBIT       0       'pin 0 para RSREG
Define  LCD_EREG        PORTE   'puerto E para Enable
Define  LCD_EBIT        1       'pin 1 para Enable

' Define parametros de rs 232
   DEFINE   DEBUG_REG   PORTC   ' Puerto C
   DEFINE   DEBUG_BIT   6      ' ***  pin Bit-6 ***
   DEFINE   DEBUG_BAUD 1200   ' *** Baud Rate ***
   DEFINE   DEBUG_MODE   0      ' Set Puerto Serial Mode 0=True, 1=Inverted
   DEFINE   DEBUG_PACING 300   ' retardp en microsegundos entre cada caracter
    DEFINE  DEBUGIN_REG PORTC
    DEFINE  DEBUGIN_BIT 7
    DEFINE  DEBUGIN_MODE  0





ADCON1 = 7              ' Setea Puerto A y Puerto E para digital
 Low PORTE.2



'** Asigamiento de Pines

dta    VAR PORTD.2 ' Linea de Datos
clk    VAR PORTD.3 ' Reloj Serial
'ser_tx VAR PORTC.6

'** Constantes

cmdtr CON %00000011 ' Command "read temperature"
cmdhr CON %00000101 ' Command "read humitity"

'** Variables

result VAR WORD ' RAW Data from Sensor
chksum VAR BYTE ' Checksum
cmd    VAR WORD ' Sensor Command
RHlin  VAR WORD ' Rel. Humidity (RH) Linear (% *10)
RHtc   VAR WORD ' Rel. Humidity (RH) temp. compensated (% *10)
Temp   VAR WORD ' Temperature (°C *100)
i      VAR BYTE
maxi   VAR WORD
mini   VAR WORD
maxhr   VAR WORD
minhr   VAR WORD

flag   VAR BIT
flag = 0
maxi = 0
mini = 0
maxhr = 0
minhr = 0
PAUSE 1000
main:
'SEROUT2 GPIO.5,16468,["COMIENZO...",10,13]
GoSub init
cmd = cmdtr

GoSub readsensor
Temp=result-3995

GoSub init
cmd = cmdhr

GoSub readsensor
RHlin=(26542-(54722**result+result))**result-40 ' RH linear
RHtc=655+(result*5)+(result**15917)
RHtc=(RHtc**(Temp/10+2480))-(RHtc**2730)+RHlin ' RH temp. compensated

'++++++++++++++++++++++++++++++++++++++++++
if flag = 0 then mini = Temp
if flag = 0 then minhr = RHtc
if Temp > maxi then maxi = Temp
if Temp < mini then mini = Temp
if RHtc > maxhr then maxhr = RHtc
if RHtc < minhr then minhr = RHtc
flag = 1
DEBUG "TEMP",DEC2 temp/100,".",DEC1 temp/10," - %HR:",DEC2 RHTC/10,".",DEC1 RHTC,10,13
LCDOUT $fe,128, "TEMP = ",DEC2 temp/100,".",DEC1 temp/10," C"
LCDOUT $fe,192,"HR   = ",DEC2 RHTC/10,".",DEC1 RHTC," %"
PAUSE 5000
LCDOUT $fe,1
LCDOUT $fe,128, "Max T = ",DEC2 maxi/100,".",DEC1 maxi/10," C"
LCDOUT $fe,192, "Min T = ",DEC2 mini/100,".",DEC1 mini/10," C"
PAUSE 5000
LCDOUT $fe,1
LCDOUT $fe,128, "Max HR = ",DEC2 maxhr/10,".",DEC1 maxhr," %"
LCDOUT $fe,192, "Min HR = ",DEC2 minhr/10,".",DEC1 minhr," %"
PAUSE 5000
LCDOUT $fe,1

GoTo main

'** Iniciar Sensor
init:
High dta
Low clk
For i=1 to 10
High clk
Pause 1
Low clk
Pause 1
Next i
Call tstart
Return

'** Comienzo de Transferencia
tstart:
High clk
Pause 1
Low dta
Pause 1
Low clk
Pause 1
High clk
Pause 1
High dta
Pause 1
Low clk
Return

'** Leyendo Datos del SHT
readsensor:
GoSub tstart
GoSub WaitSensor

ShiftOut dta,clk,1,[cmd\8] ' send command
Input dta ' wait acknowledge
Low clk
While dta=1
Wend
PulsOut clk,10 ' send ack
While dta=0
Wend
While dta=1 ' wait for conversion to complete
Wend
Low clk
ShiftIn dta,clk,0,[result.highbyte\8] ' get first byte
Low dta
PulsOut clk,10 ' send ack
ShiftIn dta,clk,0,[result.lowbyte\8] ' get second byte
Low dta
PulsOut clk,10 ' send ack
ShiftIn dta,clk,0,[chksum\8] ' get third byte (checksum)
High dta
PulsOut clk,10 ' send ack
Input dta ' End of Transmission
Input clk
Return


WaitSensor:
result=4096
Loop:
result=result-1
IF dta && result.bit11 Then Loop
Return

end

Desconectado KALLITOS

  • Colaborador
  • PIC24H
  • *****
  • Mensajes: 1256
Re: ayudita!
« Respuesta #1 en: 12 de Abril de 2011, 20:37:16 »
Por ACA esta la ayuda.

Pareces nuevo  :?.
A un microcontrolador hay que sacarle hasta el ultimo byte....(YO)

Cómo puede ser que un pic24EP512 me quede corto de memoria, señores de MICROCHIP saquen pics con más memoria flash

Más de 45 mil lineas de codigo y aun no termino el equipo, asu mare!!

S34ML08G1TFI200 no necesito mas memoria externa.

Desconectado jhonathanve

  • PIC12
  • **
  • Mensajes: 88
Re: ayudita!
« Respuesta #2 en: 12 de Abril de 2011, 21:38:04 »
jajaja saludos. gracias. xD


 

anything