OWOUT dynamic memory addresses


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2005
    Posts
    37

    Default OWOUT dynamic memory addresses

    I have a IButton DS1921G and logs the temperature every X minutes to its memory! It starts at address 1000h and goes to 3048h. I am trying to use the OW commands to get X readings but do not know how to get this to work!

    Everything works fine if I use a static memory address such as 1000h or 1084h. Which uses lsb first:

    OWOUT DQ, 1, [$CC, $F0, $84, $10] ' gets memory location 1084h

    I would like to use a for loop to do this such as:

    Code:
    mem_start = 1000h
    mem_end = 1060h
    
    for i = 1 to 60
        if i < 10 then OWOUT DQ, 1, [$CC, $F0, $0i, $10] ' I get an error trying to compile for $i
        if i >= 10 then OWOUT DQ, 1, [$CC, $F0, $i, $10] ' I get an error trying to compile for $i
    nexti
    Anyone have any suggestions on how I can do this using OW commands or anything at this time!

    Thanks,

    Scott

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Code:
    for i = 1 to 60
        if i < 10 then OWOUT DQ, 1, [$CC, $F0, i, $10] ' I get an error trying to compile for $i
        if i >= 10 then OWOUT DQ, 1, [$CC, $F0, i , $10] ' I get an error trying to compile for $i
    nexti
    Simple variable handling as referenced in the PBP manual...
    If you've got a value of i, leave it as a value of i. It's already a value of i. You can't make it a value of $i or %i. It already is i.

    Also, if you've using PBP 2.50a, do a search. If I remember right, there's a bug fix here on the forums for OWOUT that isn't published yet.
    Last edited by skimask; - 17th March 2008 at 17:44.

  3. #3
    Join Date
    Mar 2005
    Posts
    37


    Did you find this post helpful? Yes | No

    Default

    I will give it a try this evening! I thought I tried this but it seemed to return all 0's. I will double check my code.

    Thanks for your help,

    Scott

  4. #4
    Join Date
    Mar 2008
    Location
    Texas, USA
    Posts
    114


    Did you find this post helpful? Yes | No

    Default

    Code:
    mem_start = 1000h
    mem_end = 1060h
    
    for i = 1 to 60
        if i < 10 then OWOUT DQ, 1, [$CC, $F0, $0i, $10] ' I get an error trying to compile for $i
        if i >= 10 then OWOUT DQ, 1, [$CC, $F0, $i, $10] ' I get an error trying to compile for $i
    nexti
    Scott, as noted before, just use i, but given that, the code doesn't make sense. First, add a space between next and i in the nexti line (maybe just a type-o for this post). Second, except for the < and the >= in the IF statements, I don't see a difference in the execution of the IF's. Also, 60h is 96 decimal. Another change should be to start the i FOR NEXT loop with zero (0) and count to 96 for 60h being within memory sace (95 if this the begining of some other memory space (60h) - which would be normal as new areas in memory almost never start with a "1")

    I think what you want is this code. It will cycle through the i byte of the address, but I'm unclear about the byte order or the extent of your data addresses involved with this particular loop:
    Code:
    for i = 0 to 95  'Use 96 IF 60h IS part of the memory range, but I doubt it.
        OWOUT DQ, 1, [$CC, $F0, i, $10]
    next i
    It might be a good time to read up on hex-decimal-binary relationships (general, not just PBP docs). The caluclator found in Windows Accessories can be your friend (set to scientific mode).
    Last edited by JD123; - 17th March 2008 at 21:05.

  5. #5
    Join Date
    Mar 2005
    Posts
    37


    Did you find this post helpful? Yes | No

    Default

    The memory is incremented by one each time a new datapoint is collected. I am looking at the samples counter to determine the mem_end location which depends on when the user does his rounds. If the user takes the reading early the next time it may be mem_end is 1045h so I will loop until: i = 0 to 45.

    I will also add a loop from 0 to 90 and see what happens! So the OWOUT will send the data as hex without the "$"? I don't think I understand how the data is being sent via OWOUT.

    Code:
    mem_start = 0
    mem_end = X  'Is dependant on the samples counter at time of reading
    
    for i = 0 to mem_end
        OWOUT DQ, 1, [$CC, $F0, i, $10]
        OWIN DQ, 0, [TempRec]
        goto convert_temp
    next i
    Thanks,

    Scott

  6. #6
    Join Date
    Mar 2008
    Location
    Texas, USA
    Posts
    114


    Did you find this post helpful? Yes | No

    Default

    The memory is incremented by one each time a new datapoint is collected. I am looking at the samples counter to determine the mem_end location which depends on when the user does his rounds. If the user takes the reading early the next time it may be mem_end is 1045h so I will loop until: i = 0 to 45.
    Careful again... 45h does NOT equal "45" decimal.
    I will also add a loop from 0 to 90 and see what happens! So the OWOUT will send the data as hex without the "$"? I don't think I understand how the data is being sent via OWOUT.
    It's being sent in binary. Use that Windows calculator, click on hex, enter 45 (or whatever) then click on binary. You can see the relationship this way.
    Code:
    mem_start = 0
    mem_end = X  'Is dependant on the samples counter at time of reading
    
    for i = 0 to mem_end
        OWOUT DQ, 1, [$CC, $F0, i, $10]
        OWIN DQ, 0, [TempRec]
        goto convert_temp
    next i
    I just 'browsed' the datasheet. $CC command just skips the ROM. Data values are "N/A". I don't think you are going to get what you want with this code. Yet, I might be wrong because the last thing I need right now is 'learning' another datasheet.
    Last edited by JD123; - 17th March 2008 at 21:26.

  7. #7
    Join Date
    Mar 2008
    Location
    Texas, USA
    Posts
    114


    Did you find this post helpful? Yes | No

    Red face Please, don't take this wrong...

    Scott, I took a look at your posting history and something is becoming clear. You don't understand values (numbers, strings, etc.) and how the PIC (or any computer for that matter) deals with them. There are tons of good web sites that can help you understand how all these values interact and interchange with each other. I don't want to sound mean, but you have to get a better understanding of computer math, variable, etc..

    {sigh}

    I didn't learn these things when I was in school and I've paid for it all my life. I'm 46 years old and just now, it's starting to click.

Similar Threads

  1. Running Out of Programing Memory
    By rsocor01 in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 31st March 2010, 09:26
  2. Need the code to write to a memory
    By Hamlet in forum General
    Replies: 0
    Last Post: - 20th August 2007, 01:22
  3. Replies: 4
    Last Post: - 2nd March 2007, 07:12
  4. sample code for M25P32
    By Pedro Santos in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 9th January 2007, 03:37
  5. Use internal program memory like DATA memory
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th December 2006, 19:38

Members who have read this thread : 1

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