Me again, but need REAL help now


Closed Thread
Results 1 to 34 of 34

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Try this:
    Code:
    Define  LCD_DREG        PORTB
    Define  LCD_DBIT        4
    Define  LCD_RSREG       PORTB
    Define  LCD_RSBIT       1
    Define  LCD_EREG        PORTB
    Define  LCD_EBIT        3
    INCLUDE "modedefs.bas"
    crc var word:tempc var word:signc var word:result var word
    readhumidity var word:sensorcmd var word:readtemp var word:w var word
    x var word:temp var word:rhtempcomp var word:rhlinear var word:byte0 var byte
    byte1 var byte:databyte var byte:databit var bit:i var word:dpin var portd.0
    cpin var portd.1:portb.2=0:output portb.2:Pause 1000
    lcdout $fe,1, "Temperature and",$fe, $c0 ,"Humidity sensor.":pause 2000
    lcdout $fe,1:Goto mainloop        ' Skip subroutines, start main program
    mainloop: lcdout $fe,1,"Temp ", #tempc,$fe,$c0,"Humidity ",#RHTempComp
    gosub ReadSHT71:pause 100:goto mainloop
    ReadSHT71: Sensorcmd = ReadTemp : gosub readsensor
            if result => 4000 then
            tempC = result - 4000 : SignC = 160
            else
            tempC = 4000 - result : SignC = "-"
        endif
    gosub Initialize : Sensorcmd = ReadHumidity : gosub readsensor
     w = result * 405 : w = div32 100 : x = result * result : x = div32 1000
     x = x * 28 : x = div32 100 : RHLinear = w - x - 400
     w = ( (8 * result ) + 1000) / 10
        if SignC = 160 then
           if tempC > 2500 then
              x = (tempC - 2500) * w : x = div32 100
               RHTempComp = ( RHLinear + x ) / 100
                else
                x = (2500 - temp) * w : x = div32 100
               RHTempComp = ( RHLinear - x ) / 100
            endif
            else
            x = (2500 + tempC) * w : x = div32 10000
               RHTempComp = RHLinear - x
        endif
        sleep 1 : return
    Initialize: dpin=1:cpin=0:for i=1 to 10:cpin=1:pause 1:cpin=0:pause 1:next i
                 gosub TransferStart : return
    ReadSensor: gosub TransferStart : gosub WaitSensor
        shiftout dpin,cpin,0,[Sensorcmd\8]
        input dpin : cpin = 0
        while dpin = 1 : wend
        cpin = 1 : pause 1 : cpin = 0
        while dpin = 0 : wend
        while dpin = 1 : wend
        cpin = 0 : shiftin dpin,cpin,0,[result.byte1\8] : dpin = 0 : cpin = 1
        pause 1 : cpin = 0 : shiftin dpin,cpin,0,[result.byte0\8] : dpin = 0
        cpin = 1 : pause 1 : cpin = 0 : shiftin dpin,cpin,0,[crc\8] : dpin = 1
        cpin = 1 : pause 1 : cpin = 0 : input dpin : input cpin : return
    TransferStart: cpin = 1 : pause 1 : dpin = 0 : pause 1 : cpin = 0
    pause 1 : cpin = 1 : pause 1 : dpin = 1 : pause 1 : cpin = 0 : pause 1
    return
    WaitSensor: result = 4096
    Loop: result = result - 1 : if PORTD.0 & result.bit11 then Loop
        return
    END
    Had a couple of subtle math errors, parenthesis type things..
    Looks like the mode might've been wrong in a couple of places.
    The END wasn't at the bottom...not that it makes much of a difference.
    And it's been COLON-IZED!
    Last edited by skimask; - 19th June 2008 at 06:02.

  2. #2


    Did you find this post helpful? Yes | No

    Default almost there

    Cheers Ski, looks more compact, and forgot about those colon type things to seperate code. AM I missing something else, because now I get this
    ERROR: Macro AND?TTL not found in macro file.
    I recall some kind of Math Macro...........
    Last edited by gringobomba14; - 19th June 2008 at 07:54. Reason: bad grammer, misspelled words, and it was raining

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by gringobomba14 View Post
    Cheers Ski, looks more compact, and forgot about those colon type things to seperate code. AM I missing something else, because now I get this
    ERROR: Macro AND?TTL not found in macro file.
    I recall some kind of Math Macro...........
    Woof...sweet! Nice error!
    What version of PBP are you running? And/Or do you have the patches installed?
    And what is the 'full' verbage of the error? Can you track it down to which line is causing it?

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink a hole in the somewhere ???

    Hi, Ski

    Here it is :


    Executing: "C:\Program Files\Microchip\MPLAB IDE\PBP\PBPW.EXE" -ampasmwin -oq -z -v -p16F877 "Ski.bas"
    PICBASIC PRO(TM) Compiler 2.50a, (c) 1998, 2007 microEngineering Labs, Inc.
    All Rights Reserved.
    Pass 1:
    Pass 2:
    Code Gen:
    Macro Pass:
    ERROR: Macro AND?TTL not found in macro file.
    Halting build on first failure as requested.
    BUILD FAILED: Thu Jun 19 14:33:50 2008
    got that with all the very last releases ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Here it is :
    got that with all the very last releases ...
    Alain
    Let me re-phrase that last comment
    Ya gotta page thru the resulting .asm and possibly .lst file to figure out where the problem is. Then trace it back to the source code lines.

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink

    Hi,

    May be

    Code:
    Loop:result = result - 1 :if PORTD.0 && result.11 then Loop'
    instead of

    Code:
    Loop: result = result - 1 : if PORTD.0 & result.bit11 then Loop
    ... here it compiles !

    may be you're not LOGICAL enough ... LoL !

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    ... here it compiles !
    may be you're not LOGICAL enough ... LoL !
    Good one!

    Yep, I finger-flubbed that one apparently...

Similar Threads

  1. real time clock
    By maria in forum Code Examples
    Replies: 44
    Last Post: - 1st March 2022, 12:13
  2. real time clock - PCF8583
    By maria in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 15th April 2010, 15:41
  3. Real time clock ICs
    By Eng4444 in forum mel PIC BASIC Pro
    Replies: 66
    Last Post: - 20th October 2008, 16:05
  4. Real time clock... what a headache!
    By Eng4444 in forum mel PIC BASIC
    Replies: 2
    Last Post: - 8th June 2006, 21:56
  5. Timer in real time
    By martarse in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 29th July 2005, 14:24

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