Shop OBEX P1 Docs P2 Docs Learn Events
Reading ascii from a 1-wire chip - Help?.... — Parallax Forums

Reading ascii from a 1-wire chip - Help?....

JohnGuyJohnGuy Posts: 13
edited 2007-08-03 22:19 in BASIC Stamp
Hi all,

I've managed to get my BS2p40 to read 1-wire serial number chips (Dallas DS2401) in hex format, using the example code in "Commands, Features, and Projects".

But what I really need for it to do is to read text I have written in ascii format on another type of 1-wire chip (Dallas DS2506).

How can I get it to read ascii? -or if it won't read in ascii, can I read in hex or dec and somehow convert to ascii? If I read it in hex or dec, will I be able to decipher the original ascii characters?

Thanks for your help!,
JohnGuy

Comments

  • NewzedNewzed Posts: 2,503
    edited 2007-08-03 17:19
    I'm not familar with the chip you are using, but............

    Say one ov the variables you are reading in HEX is cat.· If you write:

    debug cat, cr

    it will display cat in ASCII.· If you write:

    debug dec ? cat, cr

    it will display cat in decimal notation.

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Yesterday is history, tomorrow is a mystery, and today is a gift.

    That is why they call it the present.

    Don't have VGA?
    Newzed@aol.com
    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2007-08-03 17:27
    The Stamp I/O statements have what are called formatters. These are described in detail in the Stamp Basic manual including in one of the appendices. It sounds like you've already used the HEX formatter. If you don't use any formatter at all, you get exactly the bytes that come in. I assume that's what you mean by reading ASCII. In other words, if you use a byte variable and just use that in the OWIN statement without HEX in front of it, you get the whole 8-bit character in your byte variable.
  • JohnGuyJohnGuy Posts: 13
    edited 2007-08-03 17:49
    Hi Sid and Mike!

    Okay, I've got this code running:
    ....
    AUXIO
    OWOUT OWpin_1, OW_FERst, [noparse][[/noparse]ReadROM]
    OWIN OWpin_1, OW_BERst, [noparse][[/noparse]STR ROMData\8]
    FOR idx = 0 TO 7 '
    DEBUG DEC ROMData(idx)', " "'
    NEXT '
    ....

    I get back from one of the chips:

    1513017311000141

    [noparse][[/noparse]For some reason I only get back "-" from the other chip].

    Can I somehow convert this to the original ascii text?

    Thanks!
    JohnGuy
  • NewzedNewzed Posts: 2,503
    edited 2007-08-03 18:00
    Change:

    DEBUG DEC ROMData(idx)', " "'

    to

    DEBUG ROMData(idx)

    and tell us what you get.

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Yesterday is history, tomorrow is a mystery, and today is a gift.

    That is why they call it the present.

    Don't have VGA?
    Newzed@aol.com
    ·
  • JohnGuyJohnGuy Posts: 13
    edited 2007-08-03 18:48
    Ooops! Sorry, I thought I'd done that already.

    The debug screen prints out a square box. I tried to copy the character and paste it here, but it just ended up as whitespace.

    Thanks,
    JohnGuy

    
  • NewzedNewzed Posts: 2,503
    edited 2007-08-03 19:09
    Change:

    DEBUG DEC ROMData(idx)', " "'

    to

    DEBUG DEC ROMData(idx), "· "

    and tell me if you get 8 pairs of digits.

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Yesterday is history, tomorrow is a mystery, and today is a gift.

    That is why they call it the present.

    Don't have VGA?
    Newzed@aol.com
    ·
  • JohnGuyJohnGuy Posts: 13
    edited 2007-08-03 19:20
    Hi,

    I have 2 1-wire chips hooked up. They have slightly different ascii letters in them. I get:

    15 130 173 11 0 0 0 141
    15 153 175 11 0 0 0 173

    Thanks,
    John
  • NewzedNewzed Posts: 2,503
    edited 2007-08-03 19:27
    Now change

    DEBUG DEC ROMData(idx), "· "

    to

    DEBUG·HEX ROMData(idx), "· "

    and tell me what you get.

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Yesterday is history, tomorrow is a mystery, and today is a gift.

    That is why they call it the present.

    Don't have VGA?
    Newzed@aol.com
    ·
  • JohnGuyJohnGuy Posts: 13
    edited 2007-08-03 19:32
    Hi,

    F 82 AD B 0 0 0 8D
    F 99 AF B 0 0 0 AD

    Thanks,
    JohnGuy
  • NewzedNewzed Posts: 2,503
    edited 2007-08-03 19:37
    I mentioned I was not familiar with the chip you are using.· Do you know what you should get from the ROM?· The dec and hex numbers you posted don't make sense - they do not translate to intelligent ASCII digits/letters.

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Yesterday is history, tomorrow is a mystery, and today is a gift.

    That is why they call it the present.

    Don't have VGA?
    Newzed@aol.com
    ·
  • JohnGuyJohnGuy Posts: 13
    edited 2007-08-03 19:56
    Hi,

    The first chip is programmed:

    Part No: 4000019-11 Rev A
    ser: 00034
    [noparse][[/noparse]etc.]....
    ....

    The second chip is programmed:

    Part No: 4000006-11 Rev A
    ser: 00033
    [noparse][[/noparse]etc.]....
    ....

    The Maxim program allows me to look at it in ascii or binary, but not in decimal or hex.
    JohnGuy
  • JohnGuyJohnGuy Posts: 13
    edited 2007-08-03 20:11
    Sorry, I'm mistaken. The Maxim programmer says "binary" but really it is a hex view. The first line of it is:

    50 61 72 74 20 4E 6F 3A | Part.No:

    When I look at an ascii-to-hex conversion table, the hex on the left of that line maps onto the ascii on the right of that line.

    But why aren't the correct codes read by the Parallax chip?

    Thanks,
    JohnGuy
  • NewzedNewzed Posts: 2,503
    edited 2007-08-03 20:24
    John, I dug up an old program to read the serial number on a DS2405.· I have attached it - maybe it will help.· You may hve to change it a bit to fit your chip, but the ReadROM command - $33 - is still valid.

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Yesterday is history, tomorrow is a mystery, and today is a gift.

    That is why they call it the present.

    Don't have VGA?
    Newzed@aol.com
  • NewzedNewzed Posts: 2,503
    edited 2007-08-03 22:19
    John, try this.· Change

    DEBUG DEC ROMData(idx), "· "

    to

    DEBUG·ASC ?·ROMData(idx), "· "

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Yesterday is history, tomorrow is a mystery, and today is a gift.

    That is why they call it the present.

    Don't have VGA?
    Newzed@aol.com
    ·
Sign In or Register to comment.