TODOPIC
Microcontroladores PIC => Lenguaje C para microcontroladores PIC => Mensaje iniciado por: Cesareus en 20 de Abril de 2017, 11:09:02
-
Hola a todos, estoy tratando de utilizar la famosa sonda digital en un programita que había hecho para un lm35 en picc con las librerías 1wire.c y ds1820.c y en la simulación en proteus no me aparecen ni los valores de la medición ni valores que había seteado por defecto y que son modificables a trabes de pulsadores en 4 entradas del pic. y la falla se presenta cuando se llama a la función ds1820_read(), evidentemente no me esta leyendo la entrada correspondiente. Les agradecería me ayuden. Saludos. Adjunto el correspondiente programa y librerías.
-
#include <main.h>
#include <lcd.c>
#include <1wire.c>
#include <ds1820.c>
#define RELE PIN_C4
#define RELE1 PIN_C3
#define SW1 PIN_A1 //PORTA RA1
#define SW2 PIN_A2 //PORTA RA2
#define SW3 PIN_A3 //PORTA RA3
#define SW4 PIN_A4 //PORTA RA4
float temo = 0.0; //Variable de tipo flotante temo
// ************** Programa Principal ************** //
void main ()
{
//******* Variables *******//
int mical=25;
int mahel=27;
set_tris_a(0xFF);
set_tris_b(0x00);
set_tris_c(0x00);
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_oscillator(OSC_8MHZ);
lcd_init (); // Inicializa la libreria para manejar el LCD.
printf ( LCD_PUTC, "\f" ); // Limpia la LCD.
lcd_gotoxy(1,1);
printf(lcd_putc,"TEMP:");
lcd_gotoxy(13,1); //Acomoda cursor LCD
lcd_putc("oC");
lcd_gotoxy(4,2);
printf(lcd_putc,"TC:");
lcd_gotoxy(9,2);
printf(lcd_putc,"-TR:");
while ( true ) //Bucle infinito.
{
temo = ds1820_read();
lcd_gotoxy(9,1);
printf(lcd_putc,"%3.1F",temo);
lcd_gotoxy(7,2);
printf(lcd_putc,"%d",mical);
lcd_gotoxy(13,2);
printf(lcd_putc,"%d",mahel);
delay_ms(300);
if(input(SW1)){
mical++;}
if(input(SW2)){
mical--;}
if(input(SW3)){
mahel++;}
if(input(SW4)){
mahel--;}
if(temo<mical)
output_high(RELE);
else
output_low(RELE);
if(temo>mahel)
output_high(RELE1);
else
output_low(RELE1);
} // Fin del loop infinito.
}
-
y las librerías:
- Tienes que ingresar para ver archivos adjuntos - - Tienes que ingresar para ver archivos adjuntos -
-
Y ESTE ES MAIN.H
#include <16F886.h>
#device adc=8
#fuses INTRC_IO,NOWDT,PUT,MCLR,NOPROTECT,NOCPD,NOBROWNOUT
#fuses NOIESO,NOFCMEN,NOWRT,NODEBUG,NOLVP
#use delay(clock=8000000)
#define LCD_ENABLE_PIN PIN_C6
#define LCD_RS_PIN PIN_C7
#define LCD_RW_PIN PIN_C2
#define LCD_DATA0 PIN_B0
#define LCD_DATA1 PIN_B1
#define LCD_DATA2 PIN_B2
#define LCD_DATA3 PIN_B3
#define LCD_DATA4 PIN_B4
#define LCD_DATA5 PIN_B5
#define LCD_DATA6 PIN_B6
#define LCD_DATA7 PIN_B7
-
Y POR ULTIMO FOTO DE CIRCUITO.
- Tienes que ingresar para ver archivos adjuntos -
-
Te falta el pull-up en la linea de datos. Porque es open-colector la salida DQ del ds1820.
-
Listo. Solucionado el tema.