Shop OBEX P1 Docs P2 Docs Learn Events
digital pot? — Parallax Forums

digital pot?

ArchiverArchiver Posts: 46,084
edited 2000-07-15 03:55 in General Discussion
Dave-

You're trying to stuff 128 pounds of bits into a 16 pound bag. A
"nib" (0.5 bytes, four bits, %0000 through %1111) can assume a value
from 0 through 15, and won't work in your

FOR dataword = 0 TO 127

statement. Change dataword to a byte or change your FOR statement.

Steve

On 14 Jul 00 at 2:46, dave@d... wrote:

> Hey all-
>
> I'm sure the answer is easy, but this one is stumping me.
>
> I have an Analog Devices AD7376 that I'm using as a digital
> potentiometer. It's a real simple device that takes 7 bits in via a
> SPI compliant serial bus and sets it's internal wiper to 1 of 128
> positions (0-127, 50K ohms FS).
>
> However, it doesn't seem to want to play nice with me. The data
> sheet (http://www.analog.com/pdf/2111_01.pdf) isn't very specific
> WRT the interface standard (which bit goes first, clock tolerances,
> everything else I need)
>
> The setup:
> SDI to pin 15
> CK to pin 14
> /CS to pin 13
>
> Split supply for the AD7376, common ground (same protoboard),
> bypassing, battery powered, et al.
>
> I'm using the following:
>
> 'this is program to test the Analog Devices AD7376An 50K digital
> pot 'c2000 dave paton 'pin 15 is data out, 14 is shiftout clock, 13
> is chip select 'A to +5V, B to GND, W to meter
>
> dataword var nib
> high 13 'make sure chip is deselected
> testpot:
> dataword = 0
>
> for dataword = 0 to 127 'loop to go from 0 to 5V
> low 13 'select the chip
> pause 1 'let it catch up
> shiftout 15,14,0,[noparse][[/noparse]dataword\7] 'send the data
> pause 1 'let it catch up
> high 13 'deselect chip
> pause 10 'wait for a bit
> next 'go from 0 to 127
>
> goto testpot 'lather, rinse, repeat forever
>
> but with the pot connected as a voltage divider for 0-5V, all it
> does is bounce between 1.44 and 1.86V. It should be going from 0 to
> 5. and repeating. I've tried changing the bit order (LSB or MSB
> first), messing with the timing, et al. I can see the waveform on my
> scope, bu due to trigger issues it has I can only grab the last byte
> or so. I know the data is getting there. I'm a C guy by default, and
> tho PBASIC is simple, it sems far from easy.
>
> I know it's something simple. Any ideas?
>
> -dave
>
> Next week's topic: Faster gardening through dynamite
>
> - dave paton http://www.dpaton.net dave at ieee dot
> org
>
>
>
>
>
>
>

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2000-07-14 03:46
    Hey all-

    I'm sure the answer is easy, but this one is stumping me.

    I have an Analog Devices AD7376 that I'm using as a digital
    potentiometer. It's a real simple device that takes 7 bits in via a SPI
    compliant serial bus and sets it's internal wiper to 1 of 128 positions
    (0-127, 50K ohms FS).

    However, it doesn't seem to want to play nice with me. The data sheet
    (http://www.analog.com/pdf/2111_01.pdf) isn't very specific WRT the
    interface standard (which bit goes first, clock tolerances, everything
    else I need)

    The setup:
    SDI to pin 15
    CK to pin 14
    /CS to pin 13

    Split supply for the AD7376, common ground (same protoboard),
    bypassing, battery powered, et al.

    I'm using the following:

    'this is program to test the Analog Devices AD7376An 50K digital pot
    '©2000 dave paton
    'pin 15 is data out, 14 is shiftout clock, 13 is chip select
    'A to +5V, B to GND, W to meter

    dataword var nib
    high 13 'make sure chip is deselected
    testpot:
    dataword = 0

    for dataword = 0 to 127 'loop to go from 0 to 5V
    low 13 'select the chip
    pause 1 'let it catch up
    shiftout 15,14,0,[noparse][[/noparse]dataword\7] 'send the data
    pause 1 'let it catch up
    high 13 'deselect chip
    pause 10 'wait for a bit
    next 'go from 0 to 127

    goto testpot 'lather, rinse, repeat forever

    but with the pot connected as a voltage divider for 0-5V, all it does
    is bounce between 1.44 and 1.86V. It should be going from 0 to 5. and
    repeating. I've tried changing the bit order (LSB or MSB first),
    messing with the timing, et al. I can see the waveform on my scope, bu
    due to trigger issues it has I can only grab the last byte or so. I
    know the data is getting there. I'm a C guy by default, and tho PBASIC
    is simple, it sems far from easy.

    I know it's something simple. Any ideas?

    -dave

    Next week's topic: Faster gardening through dynamite
    dave paton http://www.dpaton.net dave at ieee dot org
  • ArchiverArchiver Posts: 46,084
    edited 2000-07-14 13:26
    here is the stamp application # 18.
    it gives a working example to your question.
    ive attached it, its a pdf file.

    Norm & Monda
    Cozy MK IV #202
    Ford V-6 Powered
    Original Message
    From: <dave@d...>
    To: <basicstamps@egroups.com>
    Sent: Thursday, July 13, 2000 10:46 PM
    Subject: [noparse][[/noparse]basicstamps] digital pot?


    Hey all-

    I'm sure the answer is easy, but this one is stumping me.

    I have an Analog Devices AD7376 that I'm using as a digital
    potentiometer. It's a real simple device that takes 7 bits in via a SPI
    compliant serial bus and sets it's internal wiper to 1 of 128 positions
    (0-127, 50K ohms FS).

    However, it doesn't seem to want to play nice with me. The data sheet
    (http://www.analog.com/pdf/2111_01.pdf) isn't very specific WRT the
    interface standard (which bit goes first, clock tolerances, everything
    else I need)

    The setup:
    SDI to pin 15
    CK to pin 14
    /CS to pin 13

    Split supply for the AD7376, common ground (same protoboard),
    bypassing, battery powered, et al.

    I'm using the following:

    'this is program to test the Analog Devices AD7376An 50K digital pot
    '©2000 dave paton
    'pin 15 is data out, 14 is shiftout clock, 13 is chip select
    'A to +5V, B to GND, W to meter

    dataword var nib
    high 13 'make sure chip is deselected
    testpot:
    dataword = 0

    for dataword = 0 to 127 'loop to go from 0 to 5V
    low 13 'select the chip
    pause 1 'let it catch up
    shiftout 15,14,0,[noparse][[/noparse]dataword\7] 'send the data
    pause 1 'let it catch up
    high 13 'deselect chip
    pause 10 'wait for a bit
    next 'go from 0 to 127

    goto testpot 'lather, rinse, repeat forever

    but with the pot connected as a voltage divider for 0-5V, all it does
    is bounce between 1.44 and 1.86V. It should be going from 0 to 5. and
    repeating. I've tried changing the bit order (LSB or MSB first),
    messing with the timing, et al. I can see the waveform on my scope, bu
    due to trigger issues it has I can only grab the last byte or so. I
    know the data is getting there. I'm a C guy by default, and tho PBASIC
    is simple, it sems far from easy.

    I know it's something simple. Any ideas?

    -dave

    Next week's topic: Faster gardening through dynamite
    dave paton http://www.dpaton.net dave at ieee dot org
  • ArchiverArchiver Posts: 46,084
    edited 2000-07-14 23:14
    On 7/13/00 at 8:50 PM, S Parkis <parkiss@e...> wrote:

    > statement. Change dataword to a byte or change your FOR statement.

    See what happens when you code at 1am?

    Now, on to bigger and better things....

    Rotary encoders. This is to be part of my accellerated senior project
    (one year of classes in one semester).

    I'm building a digital preamp (I knw, it's been done, so what) and I'd
    like to use a rotary encoder for the volume control. Scott Edwards
    intrfaced one to a stamp 1 a long time ago, IIRC. I was curious if
    someone has:
    a. done this with a BS2
    and
    b. can explain to me how one generates the direction bit from the 2 pin
    output of the encoder.

    More to come...

    -dave

    Next week's topic: Faster gardening through dynamite
    dave paton http://www.dpaton.net dave at ieee dot org
  • ArchiverArchiver Posts: 46,084
    edited 2000-07-15 03:55
    here is the stamp app that shows how its done.

    its attached.

    Norm & Monda
    Cozy MK IV #202
    Ford V-6 Powered
    Original Message
    From: <dave@d...>
    To: <basicstamps@egroups.com>
    Sent: Friday, July 14, 2000 6:14 PM
    Subject: [noparse][[/noparse]basicstamps] Re: digital pot?


    > On 7/13/00 at 8:50 PM, S Parkis <parkiss@e...> wrote:
    >
    > > statement. Change dataword to a byte or change your FOR statement.
    >
    > See what happens when you code at 1am?
    >
    > Now, on to bigger and better things....
    >
    > Rotary encoders. This is to be part of my accellerated senior project
    > (one year of classes in one semester).
    >
    > I'm building a digital preamp (I knw, it's been done, so what) and I'd
    > like to use a rotary encoder for the volume control. Scott Edwards
    > intrfaced one to a stamp 1 a long time ago, IIRC. I was curious if
    > someone has:
    > a. done this with a BS2
    > and
    > b. can explain to me how one generates the direction bit from the 2 pin
    > output of the encoder.
    >
    > More to come...
    >
    > -dave
    >
    > Next week's topic: Faster gardening through dynamite
    >
    > dave paton http://www.dpaton.net dave at ieee dot org
    >
    >
    >
    >
    >
    >
Sign In or Register to comment.