Arrays calling Arrays


Closed Thread
Results 1 to 5 of 5

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default

    Hi,
    I've never played with the 1-wire commands but according to the manual you should be able to use the STR modifier to send an array of bytes out. So, an educated guess is something like:
    Code:
    OWbuffer VAR BYTE[8]           ;Array for outgoing data
     
    'Assign values for sensor 1 to the array.
    OWbuffer[0]= $26 : OWbuffer[1]= $7A
    OWbuffer[2]= $BA : OWbuffer[3]= $11 
    OWbuffer[4]= $01 : OWbuffer[5]= $00
    OWbuffer[6]= $00 : OWbuffer[7]= $D8
     
    GOSUB OWRoutine    'Send it
     
    'Assign values for sensor 2 to the array.
    OWbuffer[0]= $26 : OWbuffer[1]= $A7
    OWbuffer[2]= $AB : OWbuffer[3]= $11
    OWbuffer[4]= $10 : OWbuffer[5]= $00
    OWbuffer[6]= $00 : OWbuffer[7]= $E8
     
    GOSUB OWRoutine    'Send it
    END
     
    OWRoutine:
      OWOUT DataPin,1,[MatchRom, STR OWBuffer \8, ConvertV]
    RETURN
    This way you only have one "instance" of the OWOUT command which should save you a couple of words compared to having 26 of them (if that's what you currently have).

    /Henrik.

  2. #2
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    232


    Did you find this post helpful? Yes | No

    Default Reply to Henrik

    Henrik,
    thanks for the reply. I've tried String modifiers to send 1-wire and it doesn't work. I use String modifiers to recieve data and it works fine. It seems the method should work in both directions.

    OWIN DataPin, 2, [STR DSbuffer\9 ] this work fine - recieve data from 1-Wire device

    OWOUT DataPin, 1, [MatchRom, STR OWbuffer\8, ConverV] doesn't work - send 1-Wire
    OWOUT DataPin, 1, [MatchRom, $26, $....... .......$D8, ConvertV] this works - send 1-Wire

    I'm not sure if the PBP comand can handle the string not enclosed in brakets. I'll keep working with this and get back to you. Thanks agin.
    Last edited by MOUNTAIN747; - 25th January 2011 at 20:03. Reason: correct error in numbers

  3. #3
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    232


    Did you find this post helpful? Yes | No

    Default follow up

    OK, I got it. A small error in the method I was using to set up the 1-Wire command. The STR modifier works fine. This will save a lot of code space. Hanrik, thanks for your reply which make me work on the STR method until I got it right!

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default

    Hi,
    Great, I'm glad you got it going!

    Another way might be to use the DATA statement to save the values for each sensor to onboard EEPROM and then use a FOR-NEXT loop to read them out and stuff them into the OWBuffer array. Depending on the number of sensor "strings" you have it probably save you even more code space - provided your chip has enough EEPROM space of course.

    /Henrik.

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