 |
:: استاذ و مشرف قسم الالكترونيات ::
تاريخ التسجيل: May 2007
المشاركات: 6,832
|
|
نشاط [ F.Abdelaziz ]
قوة السمعة:
|
|
06-06-2015, 09:30 PM
المشاركة 1
|
|
شرح مشروع متحكم فى درجة الحرارة الموجبة يصلح نواة للتحكم فى المشاريع الكبرى مثل المكي
شرح مشروع متحكم فى درجة الحرارة الموجبة يصلح نواة للتحكم فى المشاريع الكبرى مثل المكيفات والأفران والسخانات وغيرها باستخدم الحساس LM35 والميكروكونترولر PIC16F88 مع المترجم CCS C :
الدائرة الكهربية :


البرنامج وعليه تعليقات للشرح :
كود:
/******************************************************
CCS ADC LM35 2X7Segment PIC18F88
*******************************************************/
#include <16F88.h>
#device ADC=10
#USE DELAY(clock = 4000000)
// 10 Data temps for common cathode display 0,1,2....9
const int digit[10]={0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7C, 0x07, 0x7F, 0x6F};
#define display_1 pin_a1 //display unit-1 comm-catode , from lift i.e. for Tens
#define display_2 pin_a2 // display unit-2 comm-catode , for Units
char units=0, tens=0 ; // declare char variables
int16 adc_result,temp;
int16 repeat;
//void display();
void main ()
{
setup_adc(ADC_CLOCK_INTERNAL); // Internal
setup_adc_ports (sAN0);
set_adc_channel (0);
output_high(display_1); // initially disable display unit-1 , high , and ...
output_high(display_2); // initially disable display unit-2 , high
while (TRUE)
{
//1-Get ADC reading result "number" and convert it to degrees
adc_result= read_adc (); //a- reat ADC to get number from 0 to 1023 for 10 bit resolution
temp = adc_result * 0.4883;// b- Then , convert this number to degrees for LM35 Sensor 10mV/1C
//2-Get actual valus for ones and tens digits by calculations
units=temp%10; // get units digit by Calculating the remainder of temp/10
tens=temp/10; // get ten digit by calculated temp/10
//3- Display Units
output_low(display_2); // a- enable (on) display uint-2 ,ones on , when use transistor , invert it
output_b(digit[units]); // b-send display data information ,to ones
delay_ms(1); // c-small delay
output_high(display_2); // d-disable(off) display uint-2
//4- Display Tens
output_low(display_1); //a- enable display uint-1 , tens on , when use transistor , invert it
output_b(digit[tens]); //b- send display data information , to tens
delay_ms(1); //c- small delay
output_high(display_1); //d- disable display uint-1 , tens off
//////////////////////////////////////////////////////////
if(temp>=18) output_high(pin_A3) ; // Example for control command
else output_low(pin_A3);
}
}
|