Connect with us

ds1620 to pic

Discussion in 'Electronic Basics' started by balu, Mar 8, 2005.

Scroll to continue with content
  1. balu

    balu Guest

    hai can any one help me out in giving hints to write a programme for
    pic and ds1620 temperature sensor to communicate
     
  2. Chris

    Chris Guest

    Google

    PIC +DS1620


    Look at the third entry


    http://www.rentron.com/CCS_C/S­ERLED_C.htm


    It's already done for you. Code, schematic, everything.


    Google is your friend.
    Chris
     
  3. Byron A Jeff

    Byron A Jeff Guest

    I have some DS1620 code on my PIC page:

    http://www.finitesite.com/d3jsys

    Look in the projects area for the thermostat.

    BAJ
     
  4. balu

    balu Guest

    hello chris,byron and petrus,, thanx for the info given,, i got almost
    a clear idea
     
  5. balu

    balu Guest

    hai evryone, itz me again, i have written some code to activate ds1620,
    still it is not working. actually this code doesnt show the temperature
    readings, but it will just check weather some signal is comming from
    ds1620. so if any one can spare for 5 mins please have a look and
    suggest me where the problem is and why iam not able to get the ouput.

    /*ds1260.c iam using pic 16f876 which has two 7 segment led displays*/
    #include <16F876.h>
    #device 16F876 ICD=TRUE
    #use delay(clock=4000000)
    #fuses XT,NOWDT, NOPROTECT, NOPUT, NOBROWNOUT
    #define led_delay 500
    #define digitbit 49 /* for left display LB0 = (8x6)+1 */
    #define digitbit1 48 /* for right display RB0 = (8x6)+0 */
    #define clk_c0 56 /* portc 0 bit */
    #define rst_c1 57 /* portc 1 bit */
    #define ip_c5 61 /* portc 5 bit the i/p of ds1620 is been
    connected to 5th pin of pic*/
    #define input 0xff
    #define output 0x00
    #define port_c 0x07
    /*#define temp 0x22, i havent defined temp variable it automatically
    taking 22h for temp, so the below tempmsb has been caluculated like 22*
    8+7=183*/
    #define tempmsb 183
    #define config 0x0c
    #define valbit 176 /* here the 22 byte 0th bit same as above*/
    #define seg7zero 0x3f
    #define seg7one 0x06
    #define rstdelay 5

    /* write function*/

    void write_ds1620(byte adrs)
    {
    byte i;
    int value;
    for(i=0; i<8; i++)
    {
    output_low(clk_c0);
    adrs =adrs>>1;
    value=adrs&0x01;
    if(value==0x01)
    {
    output_high(ip_c5);
    }
    else
    output_low(ip_c5);
    output_high(clk_c0);
    delay_us(1);
    }
    delay_us(rstdelay);
    }
    void main()
    {
    while(1)
    {
    byte rawtemp,temp=0x02;
    int i;
    int cnt = 0;
    set_tris_c(0xdc); /*11011100*/
    delay_us(rstdelay);
    output_high(rst_c1);
    write_ds1620(config);
    write_ds1620(0x02);
    write_ds1620(0xee);
    write_ds1620(0xaa);
    output_low(rst_c1);

    set_tris_c(0x20); /* reading from ds 1620*/
    output_high(rst_c1);
    for(i=0; i<8; i++)
    {
    output_low(clk_c0);
    temp=temp/2; /*22h*/
    if(bit_test(*port_c,0x05))
    output_high(tempmsb);
    else
    output_low(tempmsb);
    output_high(clk_c0);
    delay_us(1);
    }
    output_low(rst_c1);

    delay_us(rstdelay);
    /*stop conversion*/
    set_tris_c(0xdc);
    write_ds1620(0x22);

    /*display*/
    /*following checks the lsb of temp register where the reading has taken
    from the ds1620 . if any data is comming it will get some value in the
    register so it checks the lsb of the temp(22h) register and displays
    according to lsb.*/

    set_tris_c(0x00);

    if(bit_test(*temp,0x00))
    {
    output_high(digitbit1);
    output_c(seg7one);
    delay_us(led_delay);
    }
    else
    {
    output_high(digitbit);
    output_c(seg7zero);
    delay_us(led_delay);
    }

    }/*while*/
    }/*main*/
     
  6. balu

    balu Guest

    hai evryone, itz me again, i have written some code to activate ds1620,
    still it is not working. actually this code doesnt show the temperature
    readings, but it will just check weather some signal is comming from
    ds1620. so if any one can spare for 5 mins please have a look and
    suggest me where the problem is and why iam not able to get the ouput.

    /*ds1260.c iam using pic 16f876 which has two 7 segment led displays*/
    #include <16F876.h>
    #device 16F876 ICD=TRUE
    #use delay(clock=4000000)
    #fuses XT,NOWDT, NOPROTECT, NOPUT, NOBROWNOUT
    #define led_delay 500
    #define digitbit 49 /* for left display LB0 = (8x6)+1 */
    #define digitbit1 48 /* for right display RB0 = (8x6)+0 */
    #define clk_c0 56 /* portc 0 bit */
    #define rst_c1 57 /* portc 1 bit */
    #define ip_c5 61 /* portc 5 bit the i/p of ds1620 is been
    connected to 5th pin of pic*/
    #define input 0xff
    #define output 0x00
    #define port_c 0x07
    /*#define temp 0x22, i havent defined temp variable it automatically
    taking 22h for temp, so the below tempmsb has been caluculated like 22*
    8+7=183*/
    #define tempmsb 183
    #define config 0x0c
    #define valbit 176 /* here the 22 byte 0th bit same as above*/
    #define seg7zero 0x3f
    #define seg7one 0x06
    #define rstdelay 5

    /* write function*/

    void write_ds1620(byte adrs)
    {
    byte i;
    int value;
    for(i=0; i<8; i++)
    {
    output_low(clk_c0);
    adrs =adrs>>1;
    value=adrs&0x01;
    if(value==0x01)
    {
    output_high(ip_c5);
    }
    else
    output_low(ip_c5);
    output_high(clk_c0);
    delay_us(1);
    }
    delay_us(rstdelay);
    }
    void main()
    {
    while(1)
    {
    byte rawtemp,temp=0x02;
    int i;
    int cnt = 0;
    set_tris_c(0xdc); /*11011100*/
    delay_us(rstdelay);
    output_high(rst_c1);
    write_ds1620(config);
    write_ds1620(0x02);
    write_ds1620(0xee);
    write_ds1620(0xaa);
    output_low(rst_c1);

    set_tris_c(0x20); /* reading from ds 1620*/
    output_high(rst_c1);
    for(i=0; i<8; i++)
    {
    output_low(clk_c0);
    temp=temp/2; /*22h*/
    if(bit_test(*port_c,0x05))
    output_high(tempmsb);
    else
    output_low(tempmsb);
    output_high(clk_c0);
    delay_us(1);
    }
    output_low(rst_c1);

    delay_us(rstdelay);
    /*stop conversion*/
    set_tris_c(0xdc);
    write_ds1620(0x22);

    /*display*/
    /*following checks the lsb of temp register where the reading has taken
    from the ds1620 . if any data is comming it will get some value in the
    register so it checks the lsb of the temp(22h) register and displays
    according to lsb.*/

    set_tris_c(0x00);

    if(bit_test(*temp,0x00))
    {
    output_high(digitbit1);
    output_c(seg7one);
    delay_us(led_delay);
    }
    else
    {
    output_high(digitbit);
    output_c(seg7zero);
    delay_us(led_delay);
    }

    }/*while*/
    }/*main*/
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-