Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Digitalni termometar PIC16F84

[es] :: Elektronika :: Mikrokontroleri :: Digitalni termometar PIC16F84

[ Pregleda: 2878 | Odgovora: 7 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

Milos992

Član broj: 298531
Poruke: 19
*.ptt.rs.



Profil

icon Digitalni termometar PIC16F8421.12.2013. u 12:39 - pre 125 meseci
Pozdrav interesuje me da ali neko ima semu i .asm file? Za izradu termometra sa ovim tipom mikrokontrolera. Nasao sam na internetu, ali je code u .c jezikua meni treba u .asm. Hvala unapred na odgovoru.
 
Odgovor na temu

ZAS011
Uzgajivač šargarepe izakuće
Vanuatu

Član broj: 288510
Poruke: 4543

ICQ: 8713400
Sajt: www.justfuckinggoogleit.c..


+530 Profil

icon Re: Digitalni termometar PIC16F8421.12.2013. u 14:10 - pre 125 meseci
Propusti taj .c fajl kroz asembler i jedan od nusprodukata je .asm fajl.
Malko ga preradiš i eto rešenog domaćeg.
--
Make no mistake between my personality and my attitude.
My personality is who I am.
My attitude depends on who you are.
 
Odgovor na temu

Milos992

Član broj: 298531
Poruke: 19
*.ptt.rs.



Profil

icon Re: Digitalni termometar PIC16F8421.12.2013. u 14:29 - pre 125 meseci
Hvala na odgovoru. Problem je taj sto sam se ja bazirao na PLC programiranje, a mikrokontroleri mi ostali ne poznanica.
 
Odgovor na temu

veselinovic
Jovan Veselinovic
Ist. Sarajevo

Moderator
Član broj: 7761
Poruke: 3871
89.111.224.67



+334 Profil

icon Re: Digitalni termometar PIC16F8421.12.2013. u 17:08 - pre 125 meseci
Pa postavi onda ovdje taj c, neko ce se vec naci da iskompajlira.
 
Odgovor na temu

Milos992

Član broj: 298531
Poruke: 19
*.ptt.rs.



Profil

icon Re: Digitalni termometar PIC16F8422.12.2013. u 01:31 - pre 125 meseci
Prilazem te fajlove sa kodom.

Code:

temp84.c

//================================================

#include <16F84A.h>
#use delay(clock=4000000)
#fuses NOWDT,XT, NOPUT, NOPROTECT
#include <mylcd.c>
#include <ds1820.c>
//=====================================
// main program start here
//=====================================
void main(void)
{
   int buff[9], sensor, n,temp,temp_dec;

   delay_ms(50);
   lcd_init();

   while(true)
   {
      sensor=0;
      init_ds1820(sensor);
      write_ds1820_one_byte(0xcc, sensor);  // skip ROM
      write_ds1820_one_byte(0x44, sensor);  // perform temperature conversion
      while (read_ds1820_one_byte(sensor)==0xff); // wait for conversion complete
      init_ds1820(sensor);
      write_ds1820_one_byte(0xcc, sensor);  // skip ROM
      write_ds1820_one_byte(0xbe, sensor);  // read the result

      for (n=0; n<9; n++)     // read 9 bytes but, use only one byte
      {
         buff[n]=read_ds1820_one_byte(sensor);  // read DS1820
      }
      temp=buff[0]>>1;

      if ((buff[0] & 0x1)==1)
         temp_dec=5;
      else
         temp_dec=0;

      lcd_putc("\f");
      printf(lcd_putc,"Temp   :\n");
      printf(lcd_putc," %u.%u'C",temp,temp_dec);
      delay_ms(1000);
   }
} //enf of main program



Code:

mylcd.c

struct lcd_pin_map {                 // This structure is overlayed
           BOOLEAN enable;           // on to an I/O port to gain
           BOOLEAN rs;               // access to the LCD pins.
           BOOLEAN rw;               // The bits are allocated from
           BOOLEAN unused;           // low order up.  ENABLE will
           int     data : 4;         // be pin B0.
        }
        lcd;


#byte lcd = 6                  // on to port B (at address 6)
#define set_tris_lcd(x) set_tris_b(x)
#define lcd_type 1           // 1 lines
#define lcd_line_two 0x40    // LCD RAM address for the second line
BYTE const LCD_INIT_STRING[4] = {0x20 | (lcd_type << 3),0xC,1,6};
                             // These bytes need to be sent to the LCD
                             // to start it up.
                             // The following are used for setting
                             // the I/O port direction register.
struct lcd_pin_map const LCD_WRITE = {0,0,0,0,0}; // For write mode all pins are out
struct lcd_pin_map const LCD_READ = {0,0,0,0,15}; // For read mode data pins are in

BYTE lcd_read_byte()
{
      BYTE low,high;
      set_tris_lcd(LCD_READ);
      lcd.rw = 1;
      delay_cycles(1);
      lcd.enable = 1;
      delay_cycles(1);
      high = lcd.data;
      lcd.enable = 0;
      delay_cycles(1);
      lcd.enable = 1;
      delay_us(1);
      low = lcd.data;
      lcd.enable = 0;
      set_tris_lcd(LCD_WRITE);
      return( (high<<4) | low);
}

void lcd_send_nibble( BYTE n )
{
      lcd.data = n;
      delay_cycles(1);
      lcd.enable = 1;
      delay_us(2);
      lcd.enable = 0;
}

void lcd_send_byte( BYTE address, BYTE n )
{
      lcd.rs = 0;
      while ( bit_test(lcd_read_byte(),7) ) ;
      lcd.rs = address;
      delay_cycles(1);
      lcd.rw = 0;
      delay_cycles(1);
      lcd.enable = 0;
      lcd_send_nibble(n >> 4);
      lcd_send_nibble(n & 0xf);
}

void lcd_init()
{
    BYTE i;
    set_tris_lcd(LCD_WRITE);
    lcd.rs = 0;
    lcd.rw = 0;
    lcd.enable = 0;
    delay_ms(15);
    for(i=1;i<=3;++i) {
       lcd_send_nibble(3);
       delay_ms(5);
    }
    lcd_send_nibble(2);
    for(i=0;i<=3;++i)
       lcd_send_byte(0,LCD_INIT_STRING[i]);
}

void lcd_gotoxy( BYTE x, BYTE y)
{
   BYTE address;

   if(y!=1)
     address=lcd_line_two;
   else
     address=0;
   address+=x-1;
   lcd_send_byte(0,0x80|address);
}

void lcd_putc( char c)
{
   switch (c) {
     case '\f'   : lcd_send_byte(0,1);
                   delay_ms(2);
                                           break;
     case '\n'   : lcd_gotoxy(1,2);        break;
     case '\b'   : lcd_send_byte(0,0x10);  break;
     default     : lcd_send_byte(1,c);     break;
   }
}

char lcd_getc( BYTE x, BYTE y)
{
   char value;

    lcd_gotoxy(x,y);
    while ( bit_test(lcd_read_byte(),7) ); // wait until busy flag is low
    lcd.rs=1;
    value = lcd_read_byte();
    lcd.rs=0;
    return(value);
}


Code:

ds1820.c

#BYTE TRISA=0x85
#BYTE PORTA=0x5
#BYTE STATUS=0x3
#define RP0  5
#define C 0


// The following are standard 1-Wire routines.
void make_ds1820_high_pin(int sensor)
{
   TRISA = 0xff;
}

void make_ds1820_low_pin(int sensor)
{
   PORTA = 0x00;
   TRISA = 0xff & (~(0x01 << sensor));
}


// delay routines
void delay_10us(int t)
{
#asm
            BCF STATUS, RP0
 DELAY_10US_X:
            CLRWDT
            NOP
            NOP
            NOP
            NOP
            NOP
            NOP
            DECFSZ t, F
            GOTO DELAY_10US_X
#endasm
}

void delay_ms(long t)    // delays t millisecs
{
   do
   {
     delay_10us(100);
   } while(--t);
}

void init_ds1820(int sensor)
{
   make_ds1820_high_pin(sensor);
   make_ds1820_low_pin(sensor);
   delay_10us(50);

   make_ds1820_high_pin(sensor);
   delay_10us(50);
}

int read_ds1820_one_byte(int sensor)
{
   int n, i_byte, temp, mask;
   mask = 0xff & (~(0x01<<sensor));
   for (n=0; n<8; n++)
   {
      PORTA=0x00;
      TRISA=mask;
      TRISA=0xff;
#asm
      CLRWDT
      NOP
      NOP
#endasm
      temp=PORTA;
      if (temp & ~mask)
      {
        i_byte=(i_byte>>1) | 0x80;    // least sig bit first
      }
      else
      {
        i_byte=i_byte >> 1;
      }
      delay_10us(6);
   }
   return(i_byte);
}

void write_ds1820_one_byte(int d, int sensor)
{
   int n, mask;
   mask = 0xff & (~(0x01<<sensor));
   for(n=0; n<8; n++)
   {
      if (d&0x01)
      {
         PORTA=0;
         TRISA=mask;        // momentary low
         TRISA=0xff;
         delay_10us(6);
      }

      else
      {
          PORTA=0;
          TRISA=mask;
      delay_10us(6);
          TRISA=0xff;
      }
      d=d>>1;
   }
}
 
Odgovor na temu

sani.etf
Banja Luka

Član broj: 316873
Poruke: 20

Sajt: www.elektronika.rs.ba


Profil

icon Re: Digitalni termometar PIC16F8423.12.2013. u 01:48 - pre 125 meseci
Citat:
Milos992:
Pozdrav interesuje me da ali neko ima semu i .asm file? Za izradu termometra sa ovim tipom mikrokontrolera. Nasao sam na internetu, ali je code u .c jezikua meni treba u .asm. Hvala unapred na odgovoru.


Mozes li da mi posaljes link toga sto si nasao na internetu?
 
Odgovor na temu

shpiki
Student
Novi Sad

Član broj: 50342
Poruke: 1651



+62 Profil

icon Re: Digitalni termometar PIC16F8423.12.2013. u 09:40 - pre 125 meseci
Citat:
sani.etf: Mozes li da mi posaljes link toga sto si nasao na internetu?

Potrebno Googlanja ~3sec
http://www.coolcircuit.com/project/digitemp/
There are only 10 types of people in the world:
those who understand binary, and those who don't.
 
Odgovor na temu

Milos992

Član broj: 298531
Poruke: 19
*.ptt.rs.



Profil

icon Re: Digitalni termometar PIC16F8423.12.2013. u 09:43 - pre 125 meseci
Da to je taj sajt odakle sam skinuo kod. Da li neko moze da mi pomogne oko toga kompajliranja.
 
Odgovor na temu

[es] :: Elektronika :: Mikrokontroleri :: Digitalni termometar PIC16F84

[ Pregleda: 2878 | Odgovora: 7 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.