Sensor temperature MCP9800-1-2-3


Closed Thread
Results 1 to 7 of 7
  1. #1
    steneor's Avatar
    steneor Guest

    Default Sensor temperature MCP9800-1-2-3

    Hi!

    I'm using PIC BASIC with a PIC18F4680. I'm wondering whether there's anyone who could tell me how to connect MCP9800 to the PIC and get the PIC to display the temperatue on a serial or LCD.

    Thanks!

    Ernesto

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    MCP9800 connection? =>PBP I2CWRITE section

    Serial lcd: HSEROUT, SEROUT, SEROUT2, DEBUG
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    steneor's Avatar
    steneor Guest


    Did you find this post helpful? Yes | No

    Default

    Hi!
    This is my first solution.


    '************************************************* ***************
    '* Name : MCP9803.BAS *
    '* Author : Ernesto *
    '* Notice : test MCP9803 with pic18f2680 *
    '* : *
    '* Date : 30/07/2006 *
    '* Version : 1.0 *
    '* Notes : *
    '* : *
    '************************************************* ***************
    define LOADER_USED 1 ' utilisation du Bootloader Tinybld 1.91
    define OSC 40 ' Quartz ŕ 10MHz * 4
    DEFINE HSER_BAUD 19200 ' set baud rate to 19200


    FLOAT VAR WORD '

    SDA var PORTC.4
    SCL var PORTC.3

    T_MSB var byte 'Température MSB Signe + 7 Bit
    T_LSB var byte 'Temperature lsb decimal

    ;MCP9800 DATASHEET
    adr_R con %10010001 ;adr mpc9803 read
    adr_W CON %10010000 ;adr mpc9803 write
    MCP9800_TEMPERATURE CON 0 ; Register pointer
    MCP9800_CONFIGURATION CON 1
    MCP9800_HYSTERESIS CON 2
    MCP9800_LIMITSET CON 3

    ONESHOT_OFF CON %00000000 ;bit for register configuration
    ONESHOT_ON CON %10000000
    RESOLUTION_9bit CON %00000000
    RESOLUTION_10bit CON %00100000
    RESOLUTION_11bit CON %01000000
    RESOLUTION_12bit CON %01100000
    FAULT_QUEUE_0 CON %00000000
    FAULT_QUEUE_2 CON %00001000
    FAULT_QUEUE_4 CON %00010000
    FAULT_QUEUE_6 CON %00011000
    ALERT_ACTIVE_LOW CON %00000000
    ALERT_ACTIVE_HIGH CON %00000100
    COMP_MODE CON %00000000
    INT_MODE CON %00000010
    SHUTDOWN_OFF CON %00000000
    SHUTDOWN_ON CON %00000001

    MCP9800_CONFIG con oneshot_off | Resolution_11bit |Fault_queue_0 | ALERT_active_low | Comp_mode | shutdown_off


    debut:

    hserout [$D,$A]
    hserout ["************************************************* ",$D,$A]
    hserout ["* Test du capteur de température MCP9803 *",$D,$A]
    hserout ["************************************************* ",$D,$A]
    hserout [$D,$A]



    init_MCP9800:
    i2cwrite SDA,SCL,adr_W,[mcp9800_configuration,mcp9800_config]
    i2cwrite SDA,SCL,adr_W,[mcp9800_temperature]

    loop:
    i2cread SDA,SCL,adr_R,[T_msb,T_lsb]

    ;float = (T_lsb >>7 ) * 5 ; resolution 9 bit
    ;float = (T_lsb >>6 ) * 25 ; resolution 10 bit
    float = (T_lsb >>5 ) * 125 ; resolution 11 bit

    hserout ["T_msb=",BIN8 T_msb," T_lsb=",BIN8 T_lsb, " Température =",SDEC T_msb,",",dec float,"C" ,$D,$A]
    pause 200

    goto loop

    END

  4. #4
    Join Date
    Sep 2006
    Posts
    5


    Did you find this post helpful? Yes | No

    Default

    Not bad, I tried this one and it worked, had problems with the LCD grounding but the code was good, this code is also suitable for many other temp sensors.

  5. #5
    Join Date
    Jul 2004
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    It's possible to pull the i2c bus and put the mcp9803 temp sensor far away from controller ?(Around 2 meters by using shielded cable)

    Thanks.

  6. #6
    Join Date
    Mar 2008
    Location
    Switzerland
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    Hello *

    I connect MCP9801 to the PIC and i put the 3 Adressline to VCC (A0,A1,A2)
    So i change onliy the 2 Lines of the Programm above:

    adr_R con %10011111 ;adr mpc9803 read Adresse 111
    adr_W CON %10011110 ;adr mpc9803 write Adresse 111

    I get always 16.0 C on the display.

    Thank for feedback.

    Rolf

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Omalik View Post
    I get always 16.0 C on the display.
    The sensor is 16C?

Similar Threads

  1. Thermo 7 segments - little problem
    By fratello in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 27th July 2013, 07:31
  2. RS485 bus - starting probem
    By wurm in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 27th January 2010, 13:35
  3. one line led light make image
    By bioul in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th February 2008, 12:19
  4. HSERIN doesn´t work
    By wurm in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 29th July 2007, 14:23
  5. having problems with Hantronix 20x4 lcd
    By Rhatidbwoy in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 22nd December 2005, 12:22

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts