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

incubadora de huevos controlada por pic

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



Joined: 09 Jul 2004
Posts: 1

View user's profile Send private message

incubadora de huevos controlada por pic
PostPosted: Fri Jul 09, 2004 4:00 am     Reply with quote

ola estoi aciendo una incubadora que sera controlada por pic o sea

dentro de esta incubadora tendre que tener justo 25 grados mi idea es usar un pic que detecte si la temperatura es de 25 grados e entonces encenderia un led verde si la tenperatura baja menos de 25 grados el pic encenderia una bonbilha que calentaria la incubadora asta los 25 grados

pero si la tenperatura passa de los 25 grados el pic pondria en marcha un pequeno ventilador que bajaria la tenperatura asta los 25 grados

e echo este pequenho codigo pero esto no funciona


#include <16F877.h>
#device *=16
#device ICD=TRUE
#device adc=10
#use delay(clock=20000000)
#fuses NOWDT,HS, PUT, NOPROTECT, BROWNOUT, NOLVP




#define VENTILADOR PIN_B0
#define LUZ PIN_B1
#define TEMP_alta PIN_B2
#define NORMAL PIN_B3
#define TEMP_baixa PIN_B4


void main()
{

int choice=1; int flag=0;
int8 sense;

float voltage= 0;


setup_adc_ports(ALL_ANALOG);
setup_adc(ADC_CLOCK_DIV_32);


while (flag == 0)
{
set_adc_channel(0);
delay_us(10);
sense=read_adc();

if(sense >=110)//esto seria 25 grados el valor tendria que ser ajustado para conseguir los 25grados
{
output_high ( ventilador );
output_high ( temp_alta );
output_low ( luz );
output_low ( normal );
output_low ( temp_baixa );

delay_ms(20);

if(sense <=110)
{
output_high ( luz );
output_high ( temp_baixa );
output_low ( ventilador );
output_low ( normal );
output_low ( temp_alta );

delay_ms(20);
if(sense ==110)
{
output_low ( luz );
output_low ( temp_baixa );
output_low ( ventilador );
output_high ( normal );
output_low ( temp_alta );

delay_ms(20);

}
}
}
}
}

como sensor de temperatura usare un LM35
Guest








PostPosted: Fri Jul 09, 2004 4:09 am     Reply with quote

It would be better to use "<=" and ">=" instead of the "==" what is a hard (and probably never-true) condition for temperatures.
Try to use:
if(sense >= 110) ........
else if (sense >= 100) ........
else if (sense <= 90) ...........
//AND WHAT ELSE?
future



Joined: 14 May 2004
Posts: 330

View user's profile Send private message

PostPosted: Fri Jul 09, 2004 7:36 am     Reply with quote

I would not use a pic to do something like this, a little analog comparator should do the job.
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Fri Jul 09, 2004 10:46 am     Reply with quote

Hola manuelxastre,

1) Too much microcontroller for such task.

2) Why so fast ? at least you are going to control a device that has a
considerable high thermic inertia. Consider a slower xtal frequency
and some delays in the main loop.

3) You didnīt define whatīs your REF voltage.

4) Reduce your code to minimum and first solve the main task, wich is
read an analog value using the internal ADC.

5) You need to define if the convertion result (float) will be right or left
justified.

6) You will need to average multiple temperature aquisition to smooth the
output AD value.

7) After you get repeatedly the same AD value corresponding with an
voltage applied to the input ADC, you will start writing your control
algoritm.

Best wishes,

Humberto

.
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