Subversion Repositories svnkaklik

Compare Revisions

Ignore whitespace Rev 469 → Rev 470

/programy/C/PIC_C/mereni/teplomer/1wire.c
0,0 → 1,48
#define ONE_WIRE_PIN PIN_A3 // pro pristup k cidlu jsem zvolil
 
void onewire_reset()
 
 
 
{
output_low(ONE_WIRE_PIN);
delay_us(500);
output_float(ONE_WIRE_PIN);
delay_us(500);
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 );
output_bit(ONE_WIRE_PIN, shift_right(&data,1,1));
 
delay_us( 60 );
output_float(ONE_WIRE_PIN);
delay_us( 2 );
}
}
 
 
int onewire_read()
{
int count, data;
 
for (count=0; count<8; ++count)
{
output_low(ONE_WIRE_PIN);
delay_us( 2 );
output_float(ONE_WIRE_PIN);
delay_us( 8 );
shift_right(&data,1,input(ONE_WIRE_PIN));
delay_us( 120 );
}
 
return( data );
}
/programy/C/PIC_C/mereni/teplomer/ds1820.c
0,0 → 1,28
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 = (int) (temp3/16); //calculation pro DS18B20 with 0.1 deg C
 
 
return(result);
 
}
 
/programy/C/PIC_C/mereni/teplomer/main.c
0,0 → 1,80
#include "main.h"
 
 
#define LED_K1 PIN_A2 // anody segmentovek
#define LED_K2 PIN_A1
//#define LED_D1 PIN_A1 // katody segmentovek ///ted uz nepotreba
//#define LED_D2 PIN_A2
//#define LED_D3 PIN_A3
//#define LED_D4 PIN_A4
//#define LED_D5 PIN_A5
//#define LED_D6 PIN_A6
//#define LED_D7 PIN_A7
 
#include "1wire.c"
#include "ds1820.c"
 
void main()
{
long duty; // strida PWM
int temp; // zaokrouhlena teplota
int znak1; // hodnota jednotek
int znak2; // hodnota desitek
int znak; // zobrazovany znak
int i, n; // i pro for
 
 
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
 
while(TRUE)
{
temp = ds1820_read();
 
 
if (temp<10)
{ //pro teploty 0-10°C
znak1=temp;
znak2=0;
}
else
{
znak2=(int) (temp/10); //vydelit deseti a zaokrouhlit dolu = desitky
znak1=temp-znak2*10; //jednotky rozdil teploty a desitek
}
 
for (i=0;i<2;i++)
{ //cyklus zobrazeni udaje
if (i==0) {
output_low(LED_K2); //dva bloky pro sepnuti aktivniho segmentu na 1
output_high(LED_K1);
znak=znak1;
}
if (i==1) {
output_low(LED_K1);
output_high(LED_K2);
znak=znak2;
}
if (znak==1) output_b(0b11110011); //blok if pro rozeznani zobrazeneho znaku
if (znak==2) output_b(0b01001001);
if (znak==3) output_b(0b01100001);
if (znak==4) output_b(0b00110011);
if (znak==5) output_b(0b00100101);
if (znak==6) output_b(0b00000101);
if (znak==7) output_b(0b11110001);
if (znak==8) output_b(0b00000001);
if (znak==9) output_b(0b00100001);
if (znak==0) output_b(0b10000001);
Delay_ms(10);
}
 
// duty=104+(2,31*temperature); // .000416/(16*(1/4000000)) ....PWM presne podle helpu
// set_pwm1_duty(duty);
}
 
 
 
 
}
/programy/C/PIC_C/mereni/teplomer/main.err
0,0 → 1,2
No Errors
0 Errors, 0 Warnings.
/programy/C/PIC_C/mereni/teplomer/main.h
0,0 → 1,9
#include <16F84.h>
 
#FUSES NOWDT //No Watch Dog Timer
#FUSES XT //Crystal osc <= 4mhz
#FUSES NOPUT //No Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
 
#use delay(clock=4000000)
 
/programy/C/PIC_C/mereni/teplomer/main.hex
0,0 → 1,70
:1000000000308A006C290000831685118312851147
:10001000A6308C008C0B0A28000083168515A630AC
:1000200083128C008C0B1228000083168515831216
:100030000034A4012408073C031C3B2883168511C7
:1000400083128511000000000314A30C03182A2852
:1000500085112B28851583168511133083128C008A
:100060008C0B30280000000083168515000000006E
:100070008312A40A1A280034A3012308073C031C96
:1000800060288316851183128511000000008316F5
:100090008515023083128C008C0B4C2800008316CF
:1000A0008515831285195628031057280314A40CAC
:1000B00027308C008C0B5A2800000000A30A3D2832
:1000C00024088D000034240826068039A800A41FC7
:1000D0006E28A309A409A30A0319A40AA61F752858
:1000E000A509A609A50A0319A60A8D018E018C018E
:1000F0008F012608031D7F28250803199928103031
:10010000A7000310A30DA40D8C0D8F0D26080F0260
:10011000031D8C2825080C02031C952825088C0239
:10012000031C8F0326088F0203148D0D8E0DA70B61
:1001300081280000A81FA1288D098E098D0A0319A6
:100140008E0AE8288E308C0024088D0023088E004B
:100150008F018D08031DB6280E088D008E01083012
:100160008C028D08031DB6288C01BE2803108D1B40
:10017000BD288E0D8D0D8C03B6288D130000EC2844
:100180009A010420CC30A30019204430A300192088
:100190009A08031DCF283C200D089A00C828042087
:1001A000CC30A3001920BE30A30019203C200D083C
:1001B0009B003C200D089C001C089E001B089D0015
:1001C0001E08A4001D08A300A6011030A500632886
:1001D0000D08A401A300A2280F08A2000E08A10088
:1001E0000D08A0000C089F001F088C0020088D003F
:1001F00021088E0022088F0076298E308C001A0884
:100200008C021B088E001C088D008E178C080319A9
:10021000142903108E08031D10298D0803191429B1
:100220008E0C8D0C8C0B09299B1F1B298D098E09A7
:100230008D0A03198E0A00007F291B088D011A02FE
:10024000031825291A088C0031298C0108309C00DC
:100250009A0D8C0D1B080C0203188C008D0D9C0B45
:1002600028298E298C018D011A0803101B188C0770
:100270008C0C8D0C9B188C078C0C8D0C1B198C070F
:100280008C0C8D0C9B198C078C0C8D0C1B1A8C07FD
:100290008C0C8D0C9B1A8C078C0C8D0C1B1B8C07EB
:1002A0008C0C8D0C9B1B8C078C0C8D0C95291A309B
:1002B0008400000803196B2901308D008C018C0B20
:1002C0005F298D0B5E294A308C008C0B652900005C
:1002D0000000800B5C29102A84011F3083058316DF
:1002E0000108C739083881008312C0280F089D0013
:1002F0000E089C000D089B000C089A00FD280D08B4
:1003000094001408093C031C8929140895009601DF
:10031000982914089A000A309B001D290D089600A0
:1003200016089A000A309B0032290D081402950025
:1003300098011808013C031C122A9808031DAA29D9
:1003400083168510831285108316051183120515F7
:1003500015089700180BB62983160511831205118D
:10036000831685108312851416089700170BBD2974
:1003700083168601F330831286001708023C031DA2
:10038000C629831686014930831286001708033C6C
:10039000031DCF298316860161308312860017085A
:1003A000043C031DD829831686013330831286004E
:1003B0001708053C031DE1298316860125308312A9
:1003C00086001708063C031DEA29831686010530BE
:1003D000831286001708073C031DF3298316860144
:1003E000F130831286001708083C031DFC29831690
:1003F00086010130831286001708093C031D052A77
:10040000831686012130831286009708031D0D2A6A
:10041000831686018130831286000A309A0057299C
:0A042000980A9929831674296300D5
:02400E00F93F78
:00000001FF
;PIC16F84
/programy/C/PIC_C/mereni/teplomer/main.sta
0,0 → 1,39
 
ROM used: 533 (52%)
533 (52%) including unused fragments
 
2 Average locations per line
7 Average locations per statement
 
RAM used: 13 (19%) at main() level
28 (41%) worst case
 
Lines Stmts % Files
----- ----- --- -----
81 44 56 D:\KAKLIK\projekty\programy\C\PIC_C\mereni\teplomer\main.c
10 0 0 D:\KAKLIK\projekty\programy\C\PIC_C\mereni\teplomer\main.h
113 0 0 C:\Program Files\PICC\devices\16F84.h
49 22 18 D:\KAKLIK\projekty\programy\C\PIC_C\mereni\teplomer\1wire.c
29 13 9 D:\KAKLIK\projekty\programy\C\PIC_C\mereni\teplomer\ds1820.c
----- -----
564 158 Total
 
Page ROM % RAM Functions:
---- --- --- --- ----------
0 21 4 1 @delay_ms1
0 21 4 0 onewire_reset
0 35 7 2 onewire_write
0 39 7 2 onewire_read
0 61 11 9 ds1820_read
0 63 12 6 @DIVS1616
0 30 6 2 @ITOF
0 169 32 8 main
0 32 6 4 @SFTOI
0 21 4 3 @DIV88
0 37 7 2 @MUL88
 
Segment Used Free
--------- ---- ----
00000-00003 4 0
00004-003FF 529 491
 
/programy/C/PIC_C/mereni/teplomer/main.sym
0,0 → 1,72
00C @SCRATCH
00D @SCRATCH
00D _RETURN_
00E @SCRATCH
00F @SCRATCH
010 @SCRATCH
012-013 main.duty
014 main.temp
015 main.znak1
016 main.znak2
017 main.znak
018 main.i
019 main.n
01A @MUL88.P1
01A @delay_ms1.P2
01A @DIV88.P3
01A ds1820_read.busy
01A-01D @SFTOI.P1
01B ds1820_read.temp1
01B @DIV88.P1
01B @MUL88.P2
01C ds1820_read.temp2
01C @DIV88.@SCRATCH
01D-01E ds1820_read.temp3
01F-022 ds1820_read.result
023 onewire_write.data
023-024 @DIVS1616.P1
023-024 @ITOF.P2
023 onewire_read.count
024 onewire_read.data
024 onewire_write.count
025-026 @DIVS1616.P1
027 @DIVS1616.@SCRATCH
028 @DIVS1616.@SCRATCH
 
0157 @delay_ms1
0004 onewire_reset
0019 onewire_write
003C onewire_read
00C0 ds1820_read
0063 @DIVS1616
00A2 @ITOF
016C main
00FD @SFTOI
011D @DIV88
0132 @MUL88
016C @cinit
 
Project Files:
D:\KAKLIK\projekty\programy\C\PIC_C\mereni\teplomer\main.c
D:\KAKLIK\projekty\programy\C\PIC_C\mereni\teplomer\main.h
C:\Program Files\PICC\devices\16F84.h
D:\KAKLIK\projekty\programy\C\PIC_C\mereni\teplomer\1wire.c
D:\KAKLIK\projekty\programy\C\PIC_C\mereni\teplomer\ds1820.c
 
Units:
D:\KAKLIK\projekty\programy\C\PIC_C\mereni\teplomer\main.c (main)
 
Compiler Settings:
Processor: PIC16F84
Pointer Size: 8
Opt Level: 9
Short,Int,Long: 1,8,16
 
Output Files:
Errors: D:\KAKLIK\projekty\programy\C\PIC_C\mereni\teplomer\main.err
INHX8: D:\KAKLIK\projekty\programy\C\PIC_C\mereni\teplomer\main.hex
Symbols: D:\KAKLIK\projekty\programy\C\PIC_C\mereni\teplomer\main.sym
List: D:\KAKLIK\projekty\programy\C\PIC_C\mereni\teplomer\main.lst
Debug/COFF: D:\KAKLIK\projekty\programy\C\PIC_C\mereni\teplomer\main.cof
Call Tree: D:\KAKLIK\projekty\programy\C\PIC_C\mereni\teplomer\main.tre
Statistics: D:\KAKLIK\projekty\programy\C\PIC_C\mereni\teplomer\main.sta
/programy/C/PIC_C/mereni/teplomer/main.tre
0,0 → 1,19
ÀÄmain
ÀÄmain 0/169 Ram=8
ÃÄ??0??
ÃÄds1820_read 0/61 Ram=9
³ ÃÄonewire_reset 0/21 Ram=0
³ ÃÄonewire_write 0/35 Ram=2
³ ÃÄonewire_write 0/35 Ram=2
³ ÃÄonewire_read 0/39 Ram=2
³ ÃÄonewire_reset 0/21 Ram=0
³ ÃÄonewire_write 0/35 Ram=2
³ ÃÄonewire_write 0/35 Ram=2
³ ÃÄonewire_read 0/39 Ram=2
³ ÃÄonewire_read 0/39 Ram=2
³ ÃÄ@DIVS1616 0/63 Ram=6
³ ÀÄ@ITOF 0/30 Ram=2
ÃÄ@SFTOI 0/32 Ram=4
ÃÄ@DIV88 0/21 Ram=3
ÃÄ@MUL88 0/37 Ram=2
ÀÄ@delay_ms1 0/21 Ram=1
/programy/C/PIC_C/mereni/teplomer/mainhcg.BAK
0,0 → 1,82
#include "main.h"
 
 
#define LED_K1 PIN_A2 // anody segmentovek
#define LED_K2 PIN_A1
//#define LED_D1 PIN_A1 // katody segmentovek ///ted uz nepotreba
//#define LED_D2 PIN_A2
//#define LED_D3 PIN_A3
//#define LED_D4 PIN_A4
//#define LED_D5 PIN_A5
//#define LED_D6 PIN_A6
//#define LED_D7 PIN_A7
 
#include "1wire.c"
#include "ds1820.c"
 
void main()
{
float temperature; // teplota z ds1820.c
long duty; // strida PWM
int temp; // zaokrouhlena teplota
int znak1; // hodnota jednotek
int znak2; // hodnota desitek
int znak; // zobrazovany znak
int i; // i pro for
 
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
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);
setup_vref(FALSE);
port_b_pullups(TRUE);
 
 
while(TRUE)
{
temperature = ds1820_read();
temp = (int) temperature;
 
if (temp<10) { //pro teploty 0-10°C
znak1=temp;
znak2=0;
}
else {
znak2=(int) (temp/10); //vydelit deseti a zaokrouhlit dolu = desitky
znak1=temp-((int) (temp/10))*10; //jednotky rozdil teploty a desitek
}
for (i=1;i<=2;i++) { //cyklus zobrazeni udaje
output_low(0x7f); //vymaz display
if (i==1) {
output_high(LED_K1); //dva bloky pro sepnuti aktivniho segmentu na 1
output_low(LED_K2);
znak=znak1;
}
if (i==2) {
output_high(LED_K2);
output_low(LED_K1);
znak=znak2;
}
if (znak==1) output_b(0x4f); //blok if pro rozeznani zobrazeneho znaku
if (znak==2) output_b(0x12);
if (znak==3) output_b(0x06);
if (znak==4) output_b(0x4c);
if (znak==5) output_b(0x2c);
if (znak==6) output_b(0x20);
if (znak==7) output_b(0x0f);
if (znak==8) output_b(0x00);
if (znak==9) output_b(0x04);
if (znak==0) output_b(0x01);
Delay_ms(50);
}
// duty=104+(2,31*temperature); // .000416/(16*(1/4000000)) ....PWM presne podle helpu
// set_pwm1_duty(duty);
}
 
 
 
 
}