CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Sensor of temperature (DS1624)

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Christian Menard
Guest







Sensor of temperature (DS1624)
PostPosted: Tue Sep 18, 2001 7:20 pm     Reply with quote

Hi! I'm testing on sensor of temperature (DS1624 DIP-8) with the microcontroler (PIC16F84 and PIC16f877).
I always get 26 Celsius even if I freeze or heat it.

I send you my program.

#include <16F84.H>

#USE DELAY(clock=4000000)
#USE RS232(baud=9600 ,xmit=PIN_A0,rcv=PIN_A1) // Communication

#USE FAST_IO(A)
#USE FAST_IO(B)

Byte Temp=0x0000; // Définition Byte DS1624(Byte DeviceAddress);

// EXERCISEUR POUR TESTER CETTE FONCTION //

main(){ // Début du
do{
Temp=DS1624(0x90); // Fonction
#USE RS232(baud=9600 ,xmit=PIN_A0,rcv=PIN_A1)//
printf("TEST DU CAPTEUR DE TEMP (DS1624) \n\r");
printf("LA TEMPERATURE DU SOUS-SOL EST DE:\%d Celsius\n\r",
Temp);
}while(1); // Boucle
} // Fin du main

///////////////////////////////////////////////////////////////////
// NOM : DS1624
// DESCRIPTION: Cette fonction reçoit le l'adresse du
// capteur
// comme parametre
// et retourne la valeur lue du Capteur sous forme
// de Float(16 Bits)
//
// ENTREE : Byte deviceAddress : 0x90 à 0x97
//
// RETOUR : Byte Valeur du Capt. Temp. : (C900h À
// 7D00h) -55 À +125 Celsius
//
// PROTOTYPE : Byte DS1624(Byte DeviceAddress);
// Byte DS1624(0x90);

Byte DS1624(Byte DeviceAddress){ // Fonction DS1624 qui

#USE I2C(Master,sda=PIN_B0, scl=PIN_B1) // Communication I2C

Byte datah,datal; // Variables datah

// SECTION POUR INITIALISER LE DS DS1624 //

Output_High(PIN_B0);
Output_High(PIN_B1);
i2c_start(); // Début de la
i2c_write(DeviceAddress); // POUR ÉCRIRE 9
i2c_write(0xEE); // Device Protocol
i2c_stop();

// SECTION POUR CONFIGURER LE DS1624 //

i2c_start(); // Début de la communication I2C
i2c_write(DeviceAddress); // POUR ÉCRIRE 9
i2c_write(0xAC); // Device Protocol i2c_write(0x4A); // Valeur écrite dans la i2c_stop(); // Arret de la

// SECTION POUR LIRE LE DS1624 //

i2c_start(); // Début de la communication I2C
i2c_write(DeviceAddress); // POUR ÉCRIRE 9
i2c_write(0xAA); // Device Protocol i2c_start();
i2c_write(DeviceAddress+1); // POUR LIRE 9
datah=i2c_read(); // Lecture du MSB (8
datal=i2c_read(0); // Lecture du LSB (8
i2c_stop(); // Arret de la

// SECTION POUR DECODER LE (DATAH ET DATAL) DU DS1624 //

if(datah>=128 && datah<=255){ // Si le datah est ent
datah=(datah-256); // Prends la valeur lue
}
return(datah); // Retourne la valeur }

I check the hardware of couple of time and everything is O.K

*P.S : I would like you to help me to find the problem!

Thank you!
___________________________
This message was ported from CCS's old forum
Original Post ID: 306
Jerry
Guest







Re: Sensor of temperature (DS1624)
PostPosted: Tue Sep 18, 2001 9:04 pm     Reply with quote

:=Hi! I'm testing on sensor of temperature (DS1624 DIP-8) with the microcontroler (PIC16F84 and PIC16f877).
:=I always get 26 Celsius even if I freeze or heat it.
:=
:=I send you my program.
:=
:=#include <16F84.H>
:=
:=#USE DELAY(clock=4000000)
:=#USE RS232(baud=9600 ,xmit=PIN_A0,rcv=PIN_A1) // Communication
:=
:=#USE FAST_IO(A)
:=#USE FAST_IO(B)
:=
:=Byte Temp=0x0000; // Définition Byte DS1624(Byte DeviceAddress);
:=
:=// EXERCISEUR POUR TESTER CETTE FONCTION //
:=
:=main(){ // Début du
:= do{
:= Temp=DS1624(0x90); // Fonction
:= #USE RS232(baud=9600 ,xmit=PIN_A0,rcv=PIN_A1)//
:= printf("TEST DU CAPTEUR DE TEMP (DS1624) \n\r");
:= printf("LA TEMPERATURE DU SOUS-SOL EST DE:\%d Celsius\n\r",
:= Temp);
:= }while(1); // Boucle
:=} // Fin du main
:=
:=///////////////////////////////////////////////////////////////////
:=// NOM : DS1624
:=// DESCRIPTION: Cette fonction reçoit le l'adresse du
:=// capteur
:=// comme parametre
:=// et retourne la valeur lue du Capteur sous forme
:=// de Float(16 Bits)
:=//
:=// ENTREE : Byte deviceAddress : 0x90 à 0x97
:=//
:=// RETOUR : Byte Valeur du Capt. Temp. : (C900h À
:=// 7D00h) -55 À +125 Celsius
:=//
:=// PROTOTYPE : Byte DS1624(Byte DeviceAddress);
:=// Byte DS1624(0x90);
:=
:=Byte DS1624(Byte DeviceAddress){ // Fonction DS1624 qui
:=
:=#USE I2C(Master,sda=PIN_B0, scl=PIN_B1) // Communication I2C
:=
:=Byte datah,datal; // Variables datah
:=
:=// SECTION POUR INITIALISER LE DS DS1624 //
:=
:=Output_High(PIN_B0);
:=Output_High(PIN_B1);
:=i2c_start(); // Début de la
:=i2c_write(DeviceAddress); // POUR ÉCRIRE 9
:=i2c_write(0xEE); // Device Protocol
:=i2c_stop();
:=
:=// SECTION POUR CONFIGURER LE DS1624 //
:=
:=i2c_start(); // Début de la communication I2C
:=i2c_write(DeviceAddress); // POUR ÉCRIRE 9
:=i2c_write(0xAC); // Device Protocol i2c_write(0x4A); // Valeur écrite dans la i2c_stop(); // Arret de la
:=
:=// SECTION POUR LIRE LE DS1624 //
:=
:=i2c_start(); // Début de la communication I2C
:=i2c_write(DeviceAddress); // POUR ÉCRIRE 9
:=i2c_write(0xAA); // Device Protocol i2c_start();
:=i2c_write(DeviceAddress+1); // POUR LIRE 9
:=datah=i2c_read(); // Lecture du MSB (8
:=datal=i2c_read(0); // Lecture du LSB (8
:=i2c_stop(); // Arret de la
:=
:=// SECTION POUR DECODER LE (DATAH ET DATAL) DU DS1624 //
:=
:=if(datah>=128 && datah<=255){ // Si le datah est ent
:= datah=(datah-256); // Prends la valeur lue
:=}
:=return(datah); // Retourne la valeur }
:=
:=I check the hardware of couple of time and everything is O.K
:=
:=*P.S : I would like you to help me to find the problem!
:=
:=Thank you!


I am using a similar chip from Dallas the DS1629 with Time & Temp.

From what I can see in your code is that you don't need to reinitialze the configuration register for the mode of operation. This is only done once, and then issue read temp convertions after that.

Eg. your code modified.

#USE RS232(baud=9600 ,xmit=PIN_A0,rcv=PIN_A1)//


main(){ // Début du
Init_DS1624(0x90);

do{
Temp=DS1624(0x90); // Fonction
printf("TEST DU CAPTEUR DE TEMP (DS1624) \n\r");
printf("LA TEMPERATURE DU SOUS-SOL EST DE:\%d Celsius\n\r",
Temp);
}while(1); // Boucle
} // Fin du main

///////////////////////////////////////////////////////////////////
// NOM : DS1624
// DESCRIPTION: Cette fonction reçoit le l'adresse du
// capteur
// comme parametre
// et retourne la valeur lue du Capteur sous forme
// de Float(16 Bits)
//
// ENTREE : Byte deviceAddress : 0x90 à 0x97
//
// RETOUR : Byte Valeur du Capt. Temp. : (C900h À
// 7D00h) -55 À +125 Celsius
//
// PROTOTYPE : Byte DS1624(Byte DeviceAddress);
// Byte DS1624(0x90);
// void init_ds1624(DeviceAddress);

#USE I2C(Master,sda=PIN_B0, scl=PIN_B1) // communication I2C


// SECTION POUR CONFIGURER LE DS1624 //

void init_ds1624(DeviceAddress)
{
Output_High(PIN_B0);
Output_High(PIN_B1);

i2c_start();
i2c_write(DeviceAddress);
i2c_write(0xAC);
i2c_write(0x4A);
}

Byte DS1624(Byte DeviceAddress){ // Fonction DS1624 qui

Byte datah,datal; // Variables datah

// SECTION POUR INITIALISER LE DS DS1624 //

i2c_start(); // Début de la
i2c_write(DeviceAddress); // POUR ÉCRIRE 9
i2c_write(0xEE); // Device Protocol

// SECTION POUR LIRE LE DS1624 //

i2c_start(); // Début de la communication I2C
i2c_write(DeviceAddress); // POUR ÉCRIRE 9
i2c_write(0xAA); // Device Protocol i2c_start();
i2c_write(DeviceAddress+1); // POUR LIRE 9
datah=i2c_read(); // Lecture du MSB (8
datal=i2c_read(0); // Lecture du LSB (8
i2c_stop(); // Arret de la

// SECTION POUR DECODER LE (DATAH ET DATAL) DU DS1624 //

if(datah>=128 && datah<=255){ // Si le datah est ent
datah=(datah-256); // Prends la valeur lue
}
return(datah); // Retourne la valeur }
}


I have modified your function and made 2 functions similar to what I have in my code.

Good Luck

Jerry
___________________________
This message was ported from CCS's old forum
Original Post ID: 307
Peter Smith
Guest







Re: Sensor of temperature (DS1624)
PostPosted: Fri Sep 21, 2001 9:58 am     Reply with quote

:=Hi! I'm testing on sensor of temperature (DS1624 DIP-8) with the microcontroler (PIC16F84 and PIC16f877).
:=I always get 26 Celsius even if I freeze or heat it.
:=
:=I send you my program.

Here's a snippet of my code that I know for a fact works.

The problem in your code could be that your sensor is in the wrong mode, ie it only takes a temperature when you tell it to.

The code below is in this mode, so you have to explicitly tell the sensor to perform the conversion.

Hope this code is of some help

Pete.

-------------------------------------------------------------

ds1624_init_temp(); // Initialise the DS1624


ds1624_read_temp(); // Start the conversion process
ds1624_return_temp(); // Grab the temperature


void ds1624_temp_config(byte data) // Configure the DS1624
{
my_i2c_start(); // Start i2c bus
my_i2c_write(0x90); // Send control code (=1001+ADD+Write)
my_i2c_write(0xac); // Send command protocol (Access Config)
my_i2c_write(data); // Send the data
my_i2c_stop(); // Stop the bus
delay_ms(51); // Wait for the data to sink in.
}


void ds1624_init_temp() // Initialise the temperature sensor
{
my_i2c_start(); // Start the bus
my_i2c_write(0x90); // Send control code (=1001+ADD+Write)
my_i2c_write(0xee); // Send command protocol
my_i2c_stop(); // Stop the bus
ds1624_temp_config(0xcb); // Configure the device for desired operation (one shot)
}


void ds1624_read_temp() // routine to initialise temperature conversion
{

my_i2c_start(); // Start i2c bus
my_i2c_write(0x90); // Send control code (=1001+ADD+Write)
my_i2c_write(0xee); // Send command protocol (One Shot Conversion start)
my_i2c_stop(); // Stop the bus
restart_wdt();
}

void ds1624_return_temp() // Routine to return the temperature
{

restart_wdt(); // Restart WDT

my_i2c_start(); // Start i2c bus
my_i2c_write(0x90); // Send control code (=1001+ADD+Write)
my_i2c_write(0xaa); // Read temperature

restart_wdt();
my_i2c_start(); // Start i2c bus
my_i2c_write(0x91); // Send control code (=1001+ADD+Read)
highbyte=i2c_read(); // Read MS Byte
lowbyte=i2c_read(0); // Read LS Byte
my_i2c_stop(); // Stop the bus
restart_wdt();

}
___________________________
This message was ported from CCS's old forum
Original Post ID: 340
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group