help with write command


+ Reply to Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    Apr 2008
    Posts
    43

    Question help with write command

    Hi everyone, Kind of new at this and I'm pulling my hair out. Here's the code I'm having trouble with
    dtempset:
    lcdout 254,1, "set Daytime Temp"
    dtempset2:
    lcdout 254,192, dec2 temp," Celsius"
    if up = 1 then
    temp = temp + 1
    if temp > 45 then
    temp = 45
    endif
    endif

    if down = 1 then
    temp = temp - 1
    if temp < 1 then
    temp = 1
    endif
    endif
    pause 100

    if enter = 1 then
    write 13,temp
    pause 20
    gosub check
    goto ntempset
    endif
    goto dtempset2

    ntempset:
    lcdout 254,1, "set Night Temp"
    ntempset2:
    lcdout 254,192, dec2 temp," Celcius"
    if up = 1 then
    temp = temp + 1
    if temp > 45 then
    temp = 45
    endif
    endif

    if down = 1 then
    temp = temp - 1
    if temp < 1 then
    temp = 1
    endif
    endif
    pause 100

    if enter = 1 then
    write 14,temp
    pause 20
    gosub check:
    goto dtempset
    endif
    goto dtempset2

    check:
    read 13,test
    pause 20
    read 14, test2
    lcdout 254,1, dec test," ",dec test2
    pause 5000
    return

    it seems that the value keeps being pushed into address 13 and over and not into 14???? I'm going crazy!

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,587


    Did you find this post helpful? Yes | No

    Question

    Hi,

    Could your processor be a 18F ???

    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 " !!!
    *****************************************

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


    Did you find this post helpful? Yes | No

    Default

    I have no hair to lost so maybe i could help. Can you post your whole code, PIC model, OSC speed here.

    OH, please when you post a code use code tags

    [code]
    paste your code here
    [/code]

    this make it easier to read.

    Maybe temp is a WORD variable?
    <hr>
    not sure how this would behave..
    Code:
    gosub check:
    Never tested it but i see no reason to have colon here.. maybe Skimask see of some
    Last edited by mister_e; - 20th April 2008 at 14:59.
    Steve

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

  4. #4
    Join Date
    Apr 2008
    Posts
    43


    Did you find this post helpful? Yes | No

    Default

    pic is a 16f628a 4meg crystal. whole program is very long and messy nearly up to 1600 bytes so I'm not sure if its a good idea to post. if I use an eeprom 13,[??,??] at they start it works fine but i just cannot put temp into 13 and 14. temp is also a byte

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


    Did you find this post helpful? Yes | No

    Default

    Any interrupt in your code somewhere?

    Which version of the compiler?

    paste your first code lines... those before the main.
    Steve

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

  6. #6
    Join Date
    Apr 2008
    Posts
    43


    Did you find this post helpful? Yes | No

    Default

    Code:
    eeprom 1,[31,28,31,30,31,30,31,31,30,31,30,31]  ' month days lookup
    
    ' Set LCD DATA Port
     '---------------------------------------------------------------
     Define LCD_DREG PORTB
     'Set starting data bit
     Define LCD_DBIT 4 'rb4,rb5,rb6,rb7
     'Set LCD RS Port
     DEFINE LCD_RSREG portb
     'Set LCD RS Bit
     define LCD_RSBIT 3
     'Set LCD Enable Port
     Define LCD_EREG portb
     'Set LCD Enable Bit
     Define LCD_EBIT 2
     'Set number of LCD Lines
     Define LCD_LINES 2
     'Set Command Delay time in uS
     define LCD_COMMANUS 2000
     'Set Data delay time in uS
     define LCD_DATAUS 50
     test var byte
     test2 var byte
    '--------------------------ds1820setup-------------------------------
    DQ	VAR	PORTa.4			' One-wire data pin
    temperature VAR	WORD			' Temperature storage
    count_remain VAR BYTE			' Count remaining
    count_per_c VAR	BYTE			' Count per degree C
    '-----------------------------thermostat -----------------------------------
    symbol heatmat = porta.3
    target var word
    heatlevel var word
    halfsec var byte
    heatlevelx var byte
    locate var byte
    target = 30
    halfsec = 1
    locate = 13
    temp var byte
    temp = 30
    temp2 var byte
    temp2 = 20
    '------------------------------RTCsetup--------------------------------
    DS_SCL VAR PORTB.0 	' I2C clock pin 
    DS_SDA VAR PORTB.1 	' I2C data pin 
    RTC CON %11010000 	' RTC device address (byte addressing)
     ' -------------- RTC definitions ----------------- 
    SecReg 	CON $00 	' seconds address (00 - 59)' MSB of SecReg must be set to a 0 to enable RTC 
    MinReg CON $01 	' minutes address (00 - 59) 
    HourReg CON $02 	' hours address (01 - 12) or (00 - 23) 
    DayReg CON $03 	' day address (1 - 7) 
    DateReg CON $04 	' date address (01 - 28/29, 30, 31) 
    MonthReg CON $05 	' month address (01 - 12) 
    YearReg CON $06 	' year address (00 - 99) 
    ContReg CON $07 	' control register 
    RTCflag CON 0 		' RTC flag (location 0 of internal EEPROM) 
    RTCset VAR BIT 	' bit to check if RTC has been set 
    cntrl CON %00010000 	' sets the SQW/OUT to 1Hz pulse, logic level low 
    '----------------symbols-------------------------
    symbol up = porta.0
    symbol down = porta.1        'three button interface
    symbol enter = porta.2 
    '-----------decimal value variables for menu display---------------
    
    second  var byte
    minute  var byte
    hour    var byte
    day     var byte
    month   var byte
    year    var byte
    monthx  var byte
    wday    var byte
    second  = 0
    minute  = 0
    hour    = 12                           'set 12.00 1/1/08
    day     = 1
    month   = 1
    year    = 08
    
    
    '--------hex value variables for actual time display--------------
    
    secondx var byte
    minutex  var byte
    hourx    var byte
    dayx     var byte
    monthxx  var byte
    yearx    var byte
    tempx    var byte         '' important this one
    wdayx    var byte
    wdayx       =   $1       'just in case need a value maybe rubbish
    secondx     =   $00                    ' "  "
    
    '---------------------other not sure----------------------
    decx        var byte ' A swap variable
    ''''''''''''''''''''housekeeping'''''''''''''''''''''''
    trisb = %00000000
    trisa = %00000111
    cmcon = 7        'switch off comparitor

  7. #7
    Join Date
    Apr 2008
    Posts
    43


    Did you find this post helpful? Yes | No

    Default

    v2.46. no interupts

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


    Did you find this post helpful? Yes | No

    Default

    oh well...this what might happen when you copy/paste your code block... but omit a single Label change... i don't know why i haven't saw at first... anyways, the problem is in your ntempset2 section
    Code:
            if enter = 1 then
                write 14,temp
                pause 100
                gosub check
                goto dtempset
                endif
                
            goto ntempset2
    was dtempset2 before... hence why it never write @ 14... funny huh?
    Last edited by mister_e; - 20th April 2008 at 16:12.
    Steve

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

  9. #9
    Join Date
    Apr 2008
    Posts
    43


    Did you find this post helpful? Yes | No

    Talking

    must of looked over that 100 times, thankyou mister e

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


    Did you find this post helpful? Yes | No

    Default

    i know the feeling... hence why the
    Steve

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

Similar Threads

  1. Active low input?
    By CosMecc in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 8th August 2010, 20:31
  2. WRITE: One more PBP 2.60 Surprise ...
    By Acetronics2 in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 26th August 2009, 09:10
  3. Can I do this???
    By noobie in forum mel PIC BASIC
    Replies: 2
    Last Post: - 10th June 2006, 18:57
  4. Storing Strings using the Write command
    By BobP in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 1st November 2005, 11:31
  5. Using the Write Command
    By in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 16th April 2003, 02:09

Posting Permissions

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