Comparison problem


Closed Thread
Results 1 to 5 of 5

Hybrid View

  1. #1
    Join Date
    Feb 2005
    Location
    GREECE
    Posts
    120

    Question Comparison problem

    Hello boys and girls,

    I have a problem with my code.I measure themperature using DS1820 and display it on an LCD.I want to hear a buzzer if the temurature reach 90 degrees C.My comparison is not working.
    PLEASE HAVE A LOOK


    -------------------------------------------
    @ DEVICE pic16F628, INTRC_OSC_NOCLKOUT ' system clock options
    @ DEVICE pic16F628, WDT_ON ' watchdog timer
    @ DEVICE pic16F628, PWRT_ON ' power-on timer
    @ DEVICE pic16F628, MCLR_OFF ' master clear options (internal)
    @ DEVICE pic16F628, BOD_ON ' brown-out detect
    @ DEVICE pic16F628, LVP_OFF ' low-voltage programming
    @ DEVICE pic16F628, CPD_OFF ' data memory code Protect
    @ DEVICE pic16F628, PROTECT_OFF ' program code protection


    Define LCD_BITS 4 ' 4-bit interface
    Define LCD_LINES 2 ' 2 line LCD


    Define LCD_DREG PORTA
    Define LCD_DBIT 0

    Define LCD_RSREG PORTA
    Define LCD_RSBIT 4

    Define LCD_EREG PORTB
    Define LCD_EBIT 3


    Define LCD_COMMANDUS 2000 ' Adjust for slower LCD modules
    Define LCD_DATAUS 50

    INCLUDE "MODEDEFS.BAS"
    INTCON = 0 ' Disable interrupts
    CMCON = 7
    Pause 500 ' Wait for LCD to startup

    Lcdout $fe, 1 ' Clear LCD screen
    Lcdout "By:Geronikolos" ' Display Hello

    Lcdout $fe,$c0,"FW-05T" ' Clear LCD screen
    PAUSE 5000 ' Wait 5 second

    DQ var PortB.4
    temp var word

    loop:
    owout DQ,1,[$cc]
    owout DQ,0,[$44]
    Pause 2000
    owout DQ,1,[$cc]
    owout DQ,0,[$be]
    owin DQ,0,[temp.byte0,temp.byte1]
    lcdout $FE,1
    temp=temp*5
    lcdout $fe, 1,"Temp = ",DEC2 temp/10,".", dec1 temp," ",$DF,"C"
    lcdout $fe, $C0,"Temp = ",dec temp
    pause 2000
    IF temp > 90 THEN ;--this comparison is not working FOR 90 DEGREES
    portb.0 = 1
    endif
    goto loop
    end
    ---------------------------------------------------------------


    Regards
    Nikos

  2. #2
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default You haven't set the data direction for portb

    Hi,

    Add this line to the top of your code:

    TRISB = %xxxxxxx0

    Hope this helps.
    Regards

    Sougata

  3. #3
    Join Date
    Feb 2005
    Location
    GREECE
    Posts
    120


    Did you find this post helpful? Yes | No

    Default

    My friend sougata,

    I do not think this is the problem!!!But I will try to do it now.

    The problem is the the comparison.
    temp is binary or not?
    How can I do a comparison with temp and 90?

    Thanks
    Regards

  4. #4
    Join Date
    Feb 2005
    Location
    GREECE
    Posts
    120


    Did you find this post helpful? Yes | No

    Question

    Thanks
    You are right.I should have cofigured the portb.o as input.

    Do you have an idea how can I reduce my consuption?
    I have 16f627 internal osc+lcd module+ds1820
    When the pic do a mesurment for the ds1820 my current is 4.5mA and when it do not it is 3mA.

    Any idea to reduce the curent?
    Thanks
    Best regards

  5. #5
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Most of the time your program appears to be “PAUSE”ing. The first thing to do would be to use the NAP or SLEEP command instead of PAUSE. (Make sure and enable the WDT - See the manual)

    Good Luck,

    Paul Borgmeier
    Salt Lake City, Utah
    USA

Similar Threads

  1. Problem to compile my program
    By wagner in forum Off Topic
    Replies: 5
    Last Post: - 7th July 2008, 20:17
  2. USART Problem , but don't know where, in pc? or in PIC?
    By precision in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th July 2007, 08:12
  3. Microcode Studio 18f2455 problem?????
    By volkan in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 21st May 2007, 21:04
  4. 1 slave 1 master 1 MAX232 1 problem ?
    By SuB-ZeRo in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 31st July 2005, 22:59
  5. weird 12F629/675 problem
    By peterdeco1 in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 7th October 2004, 01:08

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