15 Mart 2010 Pazartesi

Maxim/Dallas DS18B20 sıcaklık algılayıcısı SÜRÜCÜ PROGRAMI



Maxim/Dallas firması tarafından üretilen DS18B20 sıcaklık algılayıcısı en fazla 0.5 derecelik hata ile -55 ile +125 dereceler arası ölçüm yapabilmekte ve sıcaklık bilgisini sayısal olarak vermektedir. DS18B20 gibi sayısal çıkış veren sıcaklık algılayıcılarının kullanımı ile analog/sayısal dönüştürücü kullanımına gerek kalmamaktadır.

Ayrıca parazit besleme özelliği sayesinde harici besleme kaynağına gerek almadan sıcaklık bilgisi okunabilmektedir. Sensörün Pic’e bağlantısı apılırken yapılacak tek şey DQ data hattına 4.7 k’lık bir pull up direnciyle +5 volta bağlanması olacaktır. Aşağıda verilen sürücü programı devrede sadece bir Ds18B20 varken çalışacaktır. Ayrıca buradan kablosuz sıcaklık ölçümünün nasıl yapılacağına dair bilgi edinebileceğiniz dökümana ulaşabilirsiniz.


class="prettyprint"> 
align="justify">//Bu kodu ds18b20.c olarak kaydediniz
align="justify">// (C) copyright 2003 j.d.sandoz / jds-pic !at! losdos.dyndns.org
#define ONE_WIRE_PIN PIN_C7
void onewire_reset()
{
output_low(ONE_WIRE_PIN);
delay_us( 500 ); //1-wire resetleme için sıfıra çekilir
output_float(ONE_WIRE_PIN); //1-wire bir yapılır
delay_us( 500 ); // sensörün hazırlanması için beklenir.
output_float(ONE_WIRE_PIN);
}
void onewire_write(int data)
{
int count;
for (count=0; count<8; ++count)
{
output_low(ONE_WIRE_PIN);
delay_us( 2 ); // Sensöre yazma işlemine başlamak için 1-wire sıfıra çekilir.
output_bit(ONE_WIRE_PIN, shift_right(&data,1,0)); // yazılacak bilgi 1-wire'da
delay_us( 60 ); // Yazma işlemi zamanı doldurulur.
output_float(ONE_WIRE_PIN); // 1-wire bir yapılır,
delay_us( 2 ); // 1us'den fazla beklenir.
}
}
int onewire_read()
{
int count, data;
for (count=0; count<8; ++count)
{
output_low(ONE_WIRE_PIN);
delay_us( 2 ); //Sensördem okuma işlemi içinl 1-wire sıfıra çekilir.
output_float(ONE_WIRE_PIN); //1-wire bir yapılır,
delay_us( 8 ); // Sensörün kendine gelmesi beklenir,
shift_right(&data,1,input(ONE_WIRE_PIN)); // sonuc bilgisi alınır.
delay_us( 120 ); //Okuma işlemi zamanı doldurulur.
}
return( data );
}
float ds1820_read()
{
int8 busy=0, temp1, temp2;
signed int16 temp3;
float result;
onewire_reset();
onewire_write(0xCC);
onewire_write(0x44);
while (busy == 0)
busy = onewire_read();
onewire_reset();
onewire_write(0xCC);
onewire_write(0xBE);
temp1 = onewire_read();
temp2 = onewire_read();
temp3 = make16(temp2, temp1);
result = (float) temp3 / 2.0;
delay_ms(200);
return(result);
}
Örnek uygulama Progamı:
class="prettyprint"> 
#include <16F877A.h>
#FUSES NOWDT, XT, PUT, NOPROTECT, NODEBUG, BROWNOUT, NOLVP, NOCPD, NOWRT
#use delay(clock=4000000)
#include
#include
void main()
{
float temperature;
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
lcd_init();
lcd_putc(”\f”);
while (1)
{
temperature = ds1820_read();
printf(lcd_putc,”Sicaklik:\n %3.1f derece”, temperature);
delay_ms(250;)
}
}

Hiç yorum yok:

Yorum Gönder

İzleyiciler

LED DİRENÇ HESAPLAMA

All LEDs require current limiting, without a current limiting mechanism the LED will usually burn out in under a second. Adding a simple resistor is the easiest way to limit the current. Use the calculator below to find out the value of resistor you require.

For example if you are wanting to power one of our_blank">red LEDs in an automotive application you would see that the typical forward voltage is 2.0 Volts and the maximum continuous forward current is 30mA. Therefore you would enter 14.5, 2.0 and 30 into the Single LED calculation box. After calculating you get 470ohm 1 watt as the result. Here is a that allows you to enter a resistor value and generate the corresponding color code.

Note: For automotive applications use the actual system voltage, not 12 Volts. Most 12 Volt system actually operate at around 14.5 Volts.

Supply Voltage
VOLTS
Voltage Drop Across LED
VOLTS
Desired LED Current
MILLIAMPS



Calculated Limiting Resistor
OHMS
Nearest higher rated 10% resistor

Calculated Resistor Wattage
WATTS
Safe pick is a resistor with
power rating of (common values are .25W, .5W, and 1W)
WATTS

LEDs in series

Several leds in series with one resistor
Supply Voltage
VOLTS
Voltage Drop Across LED
VOLTS
Desired LED Current
MILLIAMPS
How many LEDs connected




Calculated Limiting Resistor
OHMS
Nearest higher rated 10% resistor

Calculated Resistor Wattage
WATTS
Safe pick is a resistor with
power rating of (common values are .25W, .5W, and 1W)
WATTS
LM317 UYGULAMA DEVRELERİ HESAPLAMASI

 




Çıkış Voltajı
R1 resistor

R2 resistor

R1 resistor
R2 resistor

Çıkış Voltajı


Lm317 uygulama devreleri ve detayli bilgiye Buradan ulasabilirsiniz

LM555 - ASTABLE OSCILLATOR CALCULATOR

LM555 - ASTABLE OSCILLATOR CALCULATOR
Value Of R1 Ohms Value Of R2 Ohms
Value Of C1 Microfarads
Output Time HIGH SECONDS Output Time LOW SECONDS Output Period HIGH + LOW SECONDS Output Frequency HERTZ Output Duty Cycle PERCENT
Resistor values are in Ohms (1K = 1000) - Capacitor values are in Microfarads (1uF = 1)

NOTE: The leakage currents of electrolytic capacitors will affect the actual output results of the timers. To compensate for leakage it is often better to use a higher value capacitor and lower value resistances in the timer circuits.

LM555 Astable Oscillator Circuit Diagram


LM555 - ASTABLE CAPACITOR CALCULATOR

The next calculator can find the capacitance needed for a particular output frequency if the values of R1 and R2 are known.

Value Of R1 Ohms Value Of R2 Ohms
Frequency Desired Hertz
Capacitance uF
s

VOLT AMPER OHM ve WATT HESAPLAMA

Current:
kA (kiloamps) A (amps) mA (milliamps) µA (microamps)
Voltage:
kV (kilovolts) V (volts) mV (millivolts) µV (microvolts)