реклама на сайте
подробности

 
 
> Dewpointer
Andrejka
сообщение Jan 2 2009, 19:28
Сообщение #1


Участник
*

Группа: Участник
Сообщений: 18
Регистрация: 7-12-08
Пользователь №: 42 268



Hi, I found a schematic of simple temperature, huminidity and dewpoint measuring cicruit. Originally device uses: Sht11 sensor, AT90S8535 MCU, and HD44780 like 20x4 LCD. In my project I replace Sht11 with Sht15 (from Sparkfun), At90s8535 is replaced with newer Atmega8535 (Atmel datasheets say - this is a at90s8535 direct repalcement). But this device working incorrectly, so I have only "Sht11 Monitor" label on LCD, without sensor readings. If possible please help me with source code.

Source project:







URL:
Source project - http://www.embedtronics.com/sht11/sht11.html
Source code - http://www.embedtronics.com/sht11/shtdemo1.c
Schematic - http://www.embedtronics.com/sht11/SHT11Sch.pdf


My device show only this label:



I tried to simulate device in Proteus simulator but this program show the same screen, without sensor readings, only label.


Thank You!
Go to the top of the page
 
+Quote Post
 
Start new topic
Ответов
korobov_michael
сообщение Jan 3 2009, 06:45
Сообщение #2


Частый гость
**

Группа: Свой
Сообщений: 118
Регистрация: 11-03-07
Из: Украина, Харьков
Пользователь №: 26 059



I found the following:
1. At initialization, you set the bit AS2 in register ASSR (ASSR = 0x08). This means you want the Timer2 to be clocked from TOSCs pins (PC6, PC7). But these pins are connected to LCD and therefore canot be clock sources.
2. Since you didn't clock Timer2, you cannot receive interrupts from this timer and absence of last LCD string with time confirms this.
3. It is not good practice to use library functions like sprintf in interrupt handlers - they take a lot of processor time (In my IAR it taken approx. 16000 cycles, taking into account that you use CodeWizard it can take more).

I'd like to propose the following. Don't set the AS2 bit in ASSR. Using the crystal of 4MHz interrupts from Timer2 will be every (256 * 128) / 4MHz = 1/122s seconds. Correct the interrupt handler in the following way:

Код
interrupt [TIM2_OVF] void timer2_ovf_isr(void)
{
    static unsigned char sec122; // 1/122 seconds
    if(++sec122 > 122)
    {
        sec122 = 0;
        if (++t.second==60)         //keep track of time, date, month, and year
        {
          ........
         }
    }


The next thing - do not use the 4MHz crystal in tasks where real time is needed. Try to use the 3.6864MHz and TCCR2 = 0x04; You'll get the exact 1/225 seconds timer2 interval:
Код
interrupt [TIM2_OVF] void timer2_ovf_isr(void)
{
    static unsigned char sec122; // 1/122 seconds
    if(++sec225 > 225)
    {
        sec225 = 0;
        if (++t.second==60)         //keep track of time, date, month, and year
        {
          ........
         }
    }
Go to the top of the page
 
+Quote Post

Сообщений в этой теме
- Andrejka   Dewpointer   Jan 2 2009, 19:28
- - ReAl   Цитата(Andrejka @ Jan 2 2009, 21:28) I tr...   Jan 3 2009, 07:30
- - Andrejka   Thanks for reply! Maybe I just simple attach a...   Jan 4 2009, 13:38
|- - _Pasha   Цитата(Andrejka @ Jan 4 2009, 17:38) Mayb...   Jan 4 2009, 14:11
|- - korobov_michael   Цитата(Andrejka @ Jan 4 2009, 15:38) Mayb...   Jan 5 2009, 06:44
- - Andrejka   My Atmega8535 fuses are: CKSEL3..0 - 1111, and I u...   Jan 5 2009, 14:38
|- - _Pasha   Цитата(Andrejka @ Jan 5 2009, 18:38) Sht1...   Jan 5 2009, 18:21
||- - korobov_michael   Цитата(_Pasha @ Jan 5 2009, 20:21) Please...   Jan 5 2009, 18:42
|- - korobov_michael   Цитата(Andrejka @ Jan 5 2009, 16:38) Samp...   Jan 5 2009, 20:07
|- - _Pasha   Цитата(korobov_michael @ Jan 6 2009, 00:0...   Jan 5 2009, 20:22
||- - korobov_michael   Цитата(_Pasha @ Jan 5 2009, 22:22) You si...   Jan 5 2009, 21:32
|- - Andrejka   Цитата(korobov_michael @ Jan 6 2009, 00:0...   Jan 6 2009, 05:52
||- - korobov_michael   Цитата(Andrejka @ Jan 6 2009, 07:52) Yes,...   Jan 6 2009, 07:39
|- - Andrejka   Цитата(korobov_michael @ Jan 6 2009, 00:0...   Jan 6 2009, 21:43
- - radu   hello i'm beginner and i have the same problem...   Jan 16 2009, 10:39
- - radu   hello again i solve the problem regarding correct ...   Jan 16 2009, 19:16
|- - korobov_michael   Цитата(radu @ Jan 16 2009, 21:16) hello a...   Jan 17 2009, 06:57
- - B0SC0   I, too, am working on this project and have a prob...   Jan 22 2009, 20:17
- - korobov_michael   Well, first of all give me please a couple of your...   Jan 23 2009, 13:06
- - B0SC0   Цитата(korobov_michael @ Jan 23 2009, 08...   Jan 23 2009, 14:05
- - Andrejka   Цитата(B0SC0 @ Jan 23 2009, 17:05) The co...   Jan 24 2009, 19:40
- - B0SC0   Цитата(Andrejka @ Jan 24 2009, 14:40) Jus...   Jan 25 2009, 04:25
- - Andrejka   Цитата(B0SC0 @ Jan 25 2009, 08:25) Yes, I...   Jan 25 2009, 17:50


Reply to this topicStart new topic
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 


RSS Текстовая версия Сейчас: 20th August 2025 - 10:02
Рейтинг@Mail.ru


Страница сгенерированна за 0.01387 секунд с 7
ELECTRONIX ©2004-2016