Connect with us

ds1722 on parallel port using SPI

Discussion in 'Electronic Design' started by Lauwe, Jan 3, 2004.

Scroll to continue with content
  1. Lauwe

    Lauwe Guest

    I got a ds1722(http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2766) and i
    want to interface it to my pc so i can read temperatures. i used the scheme
    found at http://www.reed-electronics.com/ednmag/contents/images/245653f1.pdf

    no matter what register-byte i write (like 80h, supposed to be write-only)
    the chip seems to return the default configuration register (1110 0011)
    (even when i set the configuration-register different and try to read it).
    to me this indicates there is somesort of problem with the way i try to
    write data since it seems to fail every time (sending 0000 0000) wich is the
    address that will retrieve the configuration-register for me.

    i use the following visual-basic code to retrieve MSB:

    *******************************************
    Debug.Print "reading temp"
    'read first byte at 02h

    'set CE high d6 high and d0 high
    DlPortWritePortUshort 888, 65
    Sleep 100

    'first write address 02h (00000010)

    'write 6 zeros
    For i = 1 To 6
    'raise clk leave SDI low
    DlPortWritePortUshort 888, 67
    Sleep 100
    'lower clk (SDI remains low)
    DlPortWritePortUshort 888, 65
    Sleep 100
    Next i

    'write 1 one
    'raise clk and SDI high
    DlPortWritePortUshort 888, 71
    Sleep 100
    'lower clk (and SDI)
    DlPortWritePortUshort 888, 65
    Sleep 100

    'write 1 zero
    'raise clk leave SDI low
    DlPortWritePortUshort 888, 67
    Sleep 100
    'lower clk (SDI remains low)
    DlPortWritePortUshort 888, 65
    Sleep 100

    'now we are ready to read 1 byte
    For i = 1 To 8
    'raise clk
    DlPortWritePortUshort 888, 67
    Sleep 100
    'read bit
    Debug.Print DlPortReadPortUchar(889)
    Sleep 10
    'lower clk
    DlPortWritePortUshort 888, 65
    Sleep 100
    Next i


    'Transfer complete: lower CE
    DlPortWritePortUshort 888, 1
    Sleep 300

    *******************************************

    if someone could explain to me what i am doing wrong it would be greatlu
    appreciated.

    tnx,
    Laurens
     
  2. Snip...

    Is the port set to the SPP (Standard Parallel Port) Mode? It seems to me you
    are using direct control of the parallel port and you need to set the
    correct mode in that case. And someone mentioned that windo$e 2000/XP has
    problems with those direct calls.....

    Cheers

    Klaus
     
  3. Si Ballenger

    Si Ballenger Guest

    Can the SDO on the chip pull parallel port pin #12 low enough to
    indicate the data? I've just made two parallel port pages below
    that do similar stuff. Note on the contact/switch page I had to
    use a transistor to pull the status lines low. I've been looking
    at using a TI TLC542C chip to do some data reading also. I use a
    program called userport to get hardware access.

    http://www.geocities.com/zoomkat/status.htm
    http://www.geocities.com/zoomkat/output.htm
     
  4. Lauwe

    Lauwe Guest

    Yes, the SDO can pull pin 12 low enough because i do get data from the chip.
    i think the problem is caused by the way i try to write high-bits, but can
    this be because of timing? (i didn't think so because i control the CLK). i
    have been looking at the waveform-figures and i can't quite find out if i am
    following these figures (i think i am).

    i have tried to write high-bytes like i do in the vb code: put clk(parport
    pin3) and SDI(parport pin4) high, and then put them bolth low again
    also tried: putting clk high; then putting SDI high; then putting SDI low
    and then putting clk low.

    but i still feel that the problem is being caused by not being able to write
    the high-bits.

    so the SPP-thing didn't work..


    ps. tnx for all reactions so far!

    ----- Original Message -----
    From: "Si Ballenger" <shb*NO*SPAM*@comporium.net>
    Newsgroups: sci.electronics.design
    Sent: Saturday, January 03, 2004 9:51 PM
    Subject: Re: ds1722 on parallel port using SPI
     
  5. Si Ballenger

    Si Ballenger Guest

    Try setting the sleep to something like 6000 (6 seconds ?) and
    have multimeter connected between the parallel port pin lines and
    ground. When you set a line high, you should be able to see if
    the pins go to +5V in that 6 second time frame. If they don't,
    then you are not accessing the computer hardware with your
    program. If you are using a computer that is running NT/2K/XP are
    you using a dll or something similar that gives access the
    parallel port hardware? VB is not natively allowed this type of
    hardware access on NT/2K/XP machines.
     
  6. Lauwe

    Lauwe Guest

    I just did a test with the multimeter and it tells me that high's are 3.47V
    and lows are 0V... but these can't be to low because CLK seems to be working
    fine..
    (and i am using dlportio, and it has worked before..)
     
  7. Lauwe

    Lauwe Guest

    tnx for all the help guys but i found out what was wrong. it seems i lowered
    the SDI to soon so it didn't see the bit as a 1 but a 0 with this code it
    works:

    ***********************************
    'write 1 one

    'raise SDI
    DlPortWritePortUshort 888, 69
    Sleep 10
    Debug.Print "1"
    'raise clk
    DlPortWritePortUshort 888, 71
    Sleep 10
    'lower clk
    DlPortWritePortUshort 888, 69
    Sleep 10
    'lower SDI
    DlPortWritePortUshort 888, 65
    Sleep 10
    ***********************************
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-