سلام،
میشه راهنمایی کنید چطور میشه این سنسور رو با کدویژن راه اندازی کرد؟
در واقع چیزی که تو سایت بود DS18b20 بود اما اون کد برای DS1820 کار نمی کنه!
من کد زیر رو نوشتم ولی تو شبیه سازی همش 0 نشون میده:
#include <mega32.h>
#include <delay.h>
#include <stdio.h>
#include <math.h>
// 1 Wire Bus functions
#include <1wire.h>
// DS1820 Temperature Sensor functions
#include <ds1820.h>
// maximum number of DS1820 devices
// connected to the 1 Wire bus
#define MAX_DS1820 2
// number of DS1820 devices
// connected to the 1 Wire bus
unsigned char ds1820_devices;
// DS1820 devices ROM code storage area,
// 9 bytes are used for each device
unsigned char rom_codes[MAX_DS1820][9];
unsigned char i;
#asm
.equ __lcd_port=0x15 ;PORTA
#endasm
#include <lcd.h>
void main(void)
{
char lcd_array[16];
PORTA=0x00;
DDRA=0x00;
PORTC=0x00;
DDRC=0x00;
ds1820_devices=w1_search(0xf0,rom_codes);
lcd_init(16);
for (i=0;i<ds1820_devices;i++)
{
sprintf(lcd_array,"INIT DEVICE #%-u ",i+1);
lcd_clear();
lcd_puts(lcd_array);
lcd_gotoxy(0,1);
delay_ms(1000);
}
lcd_clear();
while (1)
{
sprintf(lcd_array,"%f",ds1820_temperatur e_10(&rom_codes[0][0])); //celsius
lcd_gotoxy(0,0);
lcd_puts(lcd_array);
};
};
میشه راهنمایی کنید چطور میشه این سنسور رو با کدویژن راه اندازی کرد؟
در واقع چیزی که تو سایت بود DS18b20 بود اما اون کد برای DS1820 کار نمی کنه!
من کد زیر رو نوشتم ولی تو شبیه سازی همش 0 نشون میده:
#include <mega32.h>
#include <delay.h>
#include <stdio.h>
#include <math.h>
// 1 Wire Bus functions
#include <1wire.h>
// DS1820 Temperature Sensor functions
#include <ds1820.h>
// maximum number of DS1820 devices
// connected to the 1 Wire bus
#define MAX_DS1820 2
// number of DS1820 devices
// connected to the 1 Wire bus
unsigned char ds1820_devices;
// DS1820 devices ROM code storage area,
// 9 bytes are used for each device
unsigned char rom_codes[MAX_DS1820][9];
unsigned char i;
#asm
.equ __lcd_port=0x15 ;PORTA
#endasm
#include <lcd.h>
void main(void)
{
char lcd_array[16];
PORTA=0x00;
DDRA=0x00;
PORTC=0x00;
DDRC=0x00;
ds1820_devices=w1_search(0xf0,rom_codes);
lcd_init(16);
for (i=0;i<ds1820_devices;i++)
{
sprintf(lcd_array,"INIT DEVICE #%-u ",i+1);
lcd_clear();
lcd_puts(lcd_array);
lcd_gotoxy(0,1);
delay_ms(1000);
}
lcd_clear();
while (1)
{
sprintf(lcd_array,"%f",ds1820_temperatur e_10(&rom_codes[0][0])); //celsius
lcd_gotoxy(0,0);
lcd_puts(lcd_array);
};
};
دیدگاه