Jump to content
ELFORUM - Forumul electronistilor
Guest caif

Ajutor - termometru cu tiny2313

Recommended Posts

Guest caif

am facut un motaj cu un termometru l-am modificat in sensul ca in loc de afisaj cu anod am pus cu catrod comun plus niste componente in plus pt controlul anumitor functii ceea ce nu inteleg eu este urmatorul lucru: am programat uC l-am pus nu arata ce trebuie si in plus regulatorul de tensiune se incalzeste prea puternic de parca ar fi in scurt ceva si asta se intampla doart cand pun uC in care e sc softul daca pun unul care nu are nici o treaba e ok si inca ceva daca imi puteti sugera cam ce modificari trebuie facute in cazul treceri de la un at90s2313 la un attiny2313 in cadrul programari

schema de laacre am pornit fiind http://www.kmitl.ac.th/~kswichit%20/avr ... hermo.html

Link to comment
Share on other sites

daca nu ai modificat cum trebuie schema si SOFTUL, atunci probabil la tine se va aprinde exact ce nu trebuie sa se aprinda in schema originala. adica in loc sa se aprinda doar un digit o data se aprind de fapt exact ceilalti 3 etc....pune schema!

Link to comment
Share on other sites

da, trebuie modificat softul. pentru ca exact cum am spus, la tine se selecteaza cate 3 digiti o data.inainte, pe pinii de control ai anozilor comuni se scotea 0 pentru digitul care trebuia selectat, acum trebuie sa scoti 1. la fel si pentru controlul ledurilor. inainte se scotea 0 pentru led aprins, acum trebuie sa scoti 1 pentru led aprins. te descurci sa modifici singur softul?

Link to comment
Share on other sites

Guest caif

R1-R7 sunt de 220 da si intre uC si tran este acea rez de limitare dar am omiso cand am facut schema referitor la soft e cam greu tinand cont ca sunt un incepator mi-ar prinde bine putin ajutor

/**************************************

thermo.c

Digital Thermometer -55C to +125C

AVR 90S2313 & DS1820

 

Copyright 2001 by Wichit Sirichote

 

**************************************/

 

#include <90s2313.h>

#include

 

 

// 1 Wire Bus functions

#asm

.equ __w1_port=0x12

.equ __w1_bit=6

#endasm

#include <1wire.h>

 

// DS1820 temperature sensor functions

#include

 

// Declare your global variables here

 

unsigned char tick,i,digit;

unsigned char heat[4];

unsigned int xtimer1;

int temp,T,X1,X2,X3,X4,X5; // signed number for negative and positve temperature manipulating

 

char key;

 

unsigned char convert[10] = {0x3F,0x06,0xdb,0xcf,0x66,0x6d,0x7d,0x07,0x7f,0x6f};

 

#define segment PORTB

#define LED_digit PORTD

 

 

// converts 16-bit data in T to display buffer for both negative and positive reading

 

void heatToBuffer()

{

if(T<0){

heat[3] = 0x40; // if negative, put -

heat[0] = 0x39; // C

 

T = abs(T); // get only amplitude

heat[1] = convert[T%10];

heat[2] = convert[T/10];

if (heat[2] == 0x3f)

heat[2] = 0; // off msd

}

else

{

heat[0] = 0x39; // C

 

heat[3] = convert[T/100];

temp = T%100;

heat[1] = convert[temp%10];

heat[2] = convert[temp/10];

// off msd

if (heat[3] == 0x3f)

{

heat[3] = 0;

if(heat[2] == 0x3f)

heat[2] = 0;

}

}

}

 

 

LPF() // performs five-point moving average

{

X5=X4;

X4=X3;

X3=X2;

X2=X1;

X1= T;

T = (X1+X2+X3+X4+X5)/5;

}

 

 

read_temp()

{

if(++xtimer1 >=5)

{

xtimer1 = 0;

segment = 0xff;

T = ds1820_temperature_10(0)/10; // read DS1820 every 5 sec.

LPF(); // enter filter

heatToBuffer(); // convert it

}

}

 

// Timer 0 overflow interrupt service routine

// timer interrupt every 1/15 sec provides foreground task to be run periodically.

 

interrupt [TIM0_OVF] void timer0_ovf_isr(void)

{

switch (++tick){

case 15: tick = 0;

read_temp(); //second_task();

}

 

}

 

void scanLED() /* scan 4-digit LED and 4-key switch, if key pressed key = 0-3

else key = -1 */

// adapted from 89C2051 project if needs scan key, find one bit input port

{

char i;

digit = 0x20;

key = -1;

for( i = 0; i < 4; i++) /* 4-DIGIT scanning */

{

LED_digit = ~digit; /* send complement[digit] */

segment = ~heat; /* send complement[segment] */

delay_ms(1); /* delay a while */

segment = 0xff; /* off LED */

// if ((PORTD & 0x10) == 0) /* if key pressed P3.4 became low */

// key = i; /* save key position to key variable */

digit>>=1; /* next digit */

}

}

 

void main(void)

{

 

DDRB=0xFF;

PORTB=0x00;

 

DDRD=0x7F;

PORTD=0x00;

 

// Timer/Counter 0 initialization

// Clock source: System Clock

// Clock value: 3.906 kHz

// Mode: Output Compare

// OC0 output: Disconnected

TCCR0=0x05;

TCNT0=0x00;

 

// Timer(s)/Counter(s) Interrupt(s) initialization

TIMSK=0x02;

 

// Analog Comparator initialization

// Analog Comparator: Off

// Analog Comparator Input Capture by Timer/Counter 1: Off

ACSR=0x80;

 

// 1 Wire Bus initialization

w1_init();

 

// Global enable interrupts

#asm("sei")

 

// 1 Wire Bus initialization

w1_init();

 

T = 34;

heatToBuffer();

 

while (1)

{

scanLED(); // run background task forever

}

}

Link to comment
Share on other sites

trebuie in primul rand sa mdifici procedura de afisare scanLED, este pentru afisaj cu anod comun. Mai jos ai procedura modificata

 

 

void scanLED()

{

char i;

digit = 0x20;

for( i = 0; i < 4; i++) /* 4-DIGIT scanning */

{

LED_digit = digit; /* send [digit] */

segment = heat; /* send [segment] */

delay_ms(1); /* delay a while */

segment = 0x00; /* off LED */

// if ((PORTD & 0x10) == 0) /* if key pressed P3.4 became low */

// key = i; /* save key position to key variable */

digit>>=1; /* next digit */

}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.Terms of Use si Guidelines