voice.c

This project created with ISD2560 record and playback chip, DS1821 temperature sensor, PIC16F84 with circuit for sightless Voice Termometer, fire and gas alarm system. (by Ayhan Dayanik).



//*********************************************
// Author: Ayhan DAYANIK
// Date  : 21/07/2003
// Version:1.0
// 
// Purpose:
// Voice Termometer, fire  and gas alarm system
// for sightless
//*********************************************

#include <system.h>

#include "ISD2560.h"
#include "DS1821.h"
#include "Voice.h"


asm
{
   list p=PIC16F84
   __config H'3FF9'  ;XT,!WDT,!PWRT,!CP
}

//Fire control
char FireControl( void )
{
    temperature=Temp_Measure();
    if (temperature & 0x80) return 0;     //because minus temperature
    if(temperature>50) {MessagePlay(Fire);return 1;} else return 0;
}

//Gas and fire control routine
void GasControl( void )
{
    if(FireControl()) nop(); else MessagePlay(Gas);
}

void SayTemperature( void )
{
    char sign;
    sign=0;
    temperature=Temp_Measure();
    if (temperature & 0x80) //if minus temperature
    {
        temperature--;
        temperature=~temperature;   //2. complement to normal value
        sign=1;
    }
    temperature=char_to_bcd(temperature);
    tmp=temperature & 0xF0;tmp=tmp>>4;

    MessagePlay(FistMsg);
    if (sign) MessagePlay(Minus);
    if (tmp) MessagePlay(HiNumVoice[tmp]);
    tmp=temperature & 0x0F;
    MessagePlay(LoNumVoice[tmp]);
    MessagePlay(LastMsg);
}

//Interrupt routine
void interrupt( void )
{
   //TMR0 overflow
   if( INTCON & 4 )
   {
      clear_bit( INTCON, 2 );
      TimerL--;
      if( TimerL == 0 )
      {
         //her saniye çalýþan kýsým
         TimerL=25;
         TimerH--;
         if( TimerH == 0 )
         {  //check fire every minute  
            TimerH=60;
            FireControl();
         }
      }
   }

   //PORTB change 
   if( INTCON & 1 )
   {
      clear_bit( INTCON, 0 );
      if(PORTB & EOM) Msg=1;else Msg=0;
      if(PORTB & Button) nop(); else SayTemperature();
      if((PORTB & Sensor1) || (PORTB & Sensor2)) GasControl();
   }
}

void App_Init( void )
{
      //Tris ports
    set_bit(STATUS,RP0);
        set_tris_a( 0x00 );
        set_tris_b( 0xF0 );
        OPTION_REG =0xD6;     //Configure the OPTION register
    clear_bit(STATUS,RP0);

    Msg=1;
    TimerH=60;
   TimerL=25;

    ISD_Reset();
    DS1821_Start();
    DS1821_TermometerMode();

    enable_interrupt( RBIE );
    enable_interrupt( T0IE );
    enable_interrupt( GIE );
}

void main( void )
{
    App_Init();
    while(1);
}



http://www.sourceboost.com/home.html

Copyright © 2002-2006 SourceBoost Technologies