All pastes #484962 Raw Edit

Anonymous

public c v1 · immutable
·published 2007-05-12 19:55 UTC
rendered paste body
/*******************************************************************************             ____    ____    ______  ____    ______  __   __                 **            /\  _`\ /\  _`\ /\  _  \/\  _`\ /\__  _\/\ \ /\ \                **            \ \ \/\ \ \ \L\ \ \ \L\ \ \ \L\ \/_/\ \/\ `\`\/'/'               **             \ \ \ \ \ \ ,  /\ \  __ \ \ ,__/  \ \ \ `\/ > <                 **              \ \ \_\ \ \ \\ \\ \ \/\ \ \ \/    \_\ \__ \/'/\`\              **               \ \____/\ \_\ \_\ \_\ \_\ \_\    /\_____\/\_\\ \_\            **                \/___/  \/_/\/ /\/_/\/_/\/_/    \/_____/\/_/ \/_/            **                                                                             ********************************************************************************* Date Debut   :      10/05/2007      |      Microcontroleur   :   PIC 16f877 ** Date Fin     :      12/05/2007      |                                       ** Auteur       :     MOUS Daniel      |      Quartz            :       ?      *******************************************************************************/#include<pic16f677.h>#include<pic16.h>#include"config.h"#include"fonction.h"/********************************************Variable + incrémentation********************************************///--> Pour le thermostatdouble tempThermo= 0 ;//--> Pour les relaisint Relai[] = {0,0,0,0,0,0} ;int i = 0 ;//--> Pour la sécurité Shutdownint shutdown = 0 ;double tmp1  = 0 ;//--> Pour le buzzerint buz = 0 ;//--> Pour le digitint cpt = 0 ;int var = 0 ;/************************************************************                           Main************************************************************/void main(){	while(1)	{		/********************************************		Code du thermostat		********************************************/		tempThermo = recup_sonde_temp(1);   //--> Récupération de la température		if(tempThermo[0] > 40.0)            //--> Si l'eau est trop chaude il passe en mode 9V		{			relai_thermo_on(1);         //--> relai 2 allumé			relai_thermo_off(0);        //--> relai 1 étein		}		if(tempThermo[0] <=  40.0 && tempThermo[0] >= 30.0 ) //--> Si l'eau est tiède, bin du 7V :p		{			relai_thermo_on(0);         //--> relai 2 étein			relai_thermo_off(1);        //--> relai 1 allumé		}				if(tempThermo[0] < 30.0)            //--> Si l'eau est assé froide, le ventilo est en 5V		{			relai_thermo_off(0);        //--> relai 2 étein			relai_thermo_off(0);        //--> relai 1 étein		}		//--> sécurité niveau température		if(tempThermo > 45.0 ) { buz = 1; }         //--> Si T>45° = un ptit bip		else if (tempThermo > 50.0) { buz = 2 ; }   //--> Si T>50° = un plus gros bip		else if (tempThermo > 59.0) { buz = 3 ; }   //--> Si T>60° = un gros bip continu		else { buz = 0 ; }                          //--> Sinon rien		/********************************************		Code pour les 6 Relais		********************************************/		while(i <= 5)		{			relai[i] = recup_data_relai_etat(i);    //--> Récupération des données			if(relai[i] == 1) { relai_i_on(i); }    //--> Si l'ordre au relai I = 1, il donne l'ordre de s'allumé			if (relai[i] == 0) { relai_i_off(i); }  //--> Si c'est 0, il s'étein l'étein :p			i++;                                    //--> Note, si ce n'est ni 0 ou 1 ( 2 alors ) il ne fait rien --> maintien du relais )		}		i = 0 ;		/********************************************		Code de l'arret brutale du PC comme sécurité		********************************************/		if(tempThermo > 60.0) { shutdown = 1 ; }		tmp1 = recup_debi();		if(shutdown == 1 || tmp1 == 1) { relai_shutdown(1); }		shutdown = 0 ;		tmp1 = 0 ;		/********************************************		Code du buzzer		********************************************/		buz_on(buz);		buz = 0 ;                /********************************************                Code de l'affichiage du Digit                ********************************************/		digit(cpt,var);		if(cpt == 6) 		{ 			cpt = 0 ;                         if(var == 0) { var = 1 ; }                        else { var = 0 ; }		}		else { cpt++ ; }		delay_ms(500);		/******************************************/		return 1 ;	}}