Shop OBEX P1 Docs P2 Docs Learn Events
Digipot updates very slowly — Parallax Forums

Digipot updates very slowly

hvguyhvguy Posts: 18
edited 2010-08-13 19:38 in BASIC Stamp
So I have a need for a bunch of digipots and decided to go with the AD5206. I had no problem getting it working, until I tried to change the pot value faster than once a second. Here's some code from what I'm working on:

HIGH 13
LOW 12
potvalue=0
potaddr=0

ZeroPots:
FOR potaddr = 0 TO 5
SHIFTOUT 14, 13, MSBFIRST, [potaddr\3, 0\8]
PULSOUT 12, 10
NEXT

This works fine and sets everything to zero. Now, I use this piece of code to change the pot value every time a button is pressed:

DO
IF IN1=1 AND potvalue<250 THEN
potvalue=potvalue + 10
SHIFTOUT 14, 13, MSBFIRST, [0\3, potvalue\8]
PULSOUT 12, 10
PAUSE 900
ENDIF
LOOP

Obviously every time the button is pressed the pot should increment by 10. So here's the strange part; with the PAUSE set to 900 the pot updates fine with every button press. If I set the PAUSE to be any smaller it will update two or three times then stop. I have verified that the BS2 is sending out the correct serial data every time with a scope, but it does not update the wiper position.

To put it another way, here is an example:

PAUSE is set to 200
button is pressed once, value increases by one step.
button is pressed again, it increases again.
button is held so that the code loops and value advances as predicted (watching scope and DEBUG) but real world pot value ceases to change after a few pulses.

If I wait about 5 seconds then press the button again. Now the value updates to whatever it should be after missing however many steps and continues to change for another few steps before doing the same thing again. If I set the PAUSE to 900 or higher the pot advances 10 steps per serial output pulse ever time the code loops. So why does it work fine slowed down so much but not at a reasonable speed? BTW, the DS says this pot has a setup time of something like 5ns, so I don't think I'm sending data too fast... plus this is a basic stamp, they aren't exactly fast devices :-)

I'm really stumped here anything would help, thanks!

Comments

  • BeanBean Posts: 8,129
    edited 2010-08-12 06:12
    It looks like you are coding for a device that has a "Latch" signal by pulsing pin 12.

    The AD5206 has a "Chip Select" signal that must be brought LOW just be before shifting in the data, then must be brought HIGH to latch in the data.

    Try changing your code to

    LOW 12
    SHIFTOUT 14, 13, MSBFIRST, [0\3, potvalue\8]
    HIGH 12

    And see if that helps.

    Bean
  • velociostrichvelociostrich Posts: 40
    edited 2010-08-12 10:34
    I asked in another thread (http://forums.parallax.com/showthread.php?t=124763) how to get the AD5204 to work (which is the same as the AD5206, with the exception that the 5206 has two more potentiometers and therefore slightly different pinouts), but haven't yet gotten a response -- I did not set the CS pin low, so I'll give that a try later.

    @hvguy: What value resistor did you use on the SDO pin, and did you just connect the GND pin to VSS?
  • hvguyhvguy Posts: 18
    edited 2010-08-12 15:16
    Bean,

    I tried the code as you recommended:

    DO
    IF IN1=1 AND potvalue<250 THEN
    potvalue=potvalue + 10
    LOW 12
    SHIFTOUT 14, 13, MSBFIRST, [0\3, potvalue\8]
    HIGH 12
    PAUSE 100
    ENDIF
    LOOP

    It still functions the same as before. Any other ideas?


    velociostrich,

    I tied Vss and GND. The AD5206 does not have the SDO pin, but I have the AD5204 as well and did use a 1K pull-up. You could use something much lager (100K) if you wanted to run high impedance logic...
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2010-08-12 16:46
    Is there a pulldown resistor and can you see on the 'scope that there are clean levels on the pushbutton (IN1)?

    How about this with debounce?
    DO
      DO : LOOP WHILE IN1  ' wait for pin low (debounce)
      DO : LOOP UNTIL IN1  ' wait for pin high
       IF potvalue<250 THEN
         potvalue=potvalue + 10
         LOW 12
           SHIFTOUT 14, 13, MSBFIRST, [0\3, potvalue\8]
         HIGH 12
         PAUSE 100
       ENDIF
    LOOP
    

    How about this on the 'scope, which should scan up and down rapidly:
    potvalue VAR Byte
    increment VAR Word
    potvalue = 0
    DO
       IF potvalue=0 THEN increment = 10
        IF potvalue=250 THEN increment = -10
       LOW 12
         SHIFTOUT 14, 13, MSBFIRST, [0\3, potvalue\8]
       HIGH 12
       potvalue=potvalue + increment
     LOOP
    
  • hvguyhvguy Posts: 18
    edited 2010-08-12 18:10
    Well, unfortunately this one is rather anticlimactic... The ground jumper connected to pin 4 had broken under the insulation and did not always make contact. I pulled it out and dropped in another, and everything worked fine. Although a few things can be learned from this:

    First, this code works fine:

    potnumber VAR nib
    potvalue VAR byte

    LOW 12
    potnumber=0
    potvalue=0

    SHIFTOUT 14, 13, MSBFIRST, [potnumber\3, potvalue\8]
    PULSOUT 12,1

    pin 12 is pin 8 or CLK on the AD5206 and must be initialized LOW
    pin 13 is pin 5 or CS on the AD5206
    pin 14 is pin 7 or SDI on the AD5206

    potnumber is 0-5 to address pots 1-6
    potvalue is 0-255 for wiper position

    The \8 is not technically necessary since the default number of bits is 8, but I left it there for the purpose of clarity. Another pot that uses more or less bits would need to have the number of bits defined by the \X.

    Second, the pot does work with the GND pin floating, but only sometimes, so make sure all your jumpers are good :-)

    Another interesting thing to note, especially for anyone referencing this after reading NV18 about the DS126x series pots, is that the AD520x loads data while CS is LOW. The DS126x series does it while RST is HIGH, even though both datasheets pinouts show the pin as active low.

    Thanks for the feedback!
  • velociostrichvelociostrich Posts: 40
    edited 2010-08-12 18:59
    I tried posting earlier but it didn't seem to work, but thanks for the feedback as well! I haven't gotten mine to work, but it seems that one of the connections is bad and need to be re-soldered -- it must be a cold joint or something, because testing resistance between the wire and the leg of the chip shows some amount of resistance.
  • hvguyhvguy Posts: 18
    edited 2010-08-13 14:32
    Let us know if you keep having problems after you fix that solder joint. I'm sure there are a few other people that will search this thread that will be interested.
  • velociostrichvelociostrich Posts: 40
    edited 2010-08-13 19:38
    As I couldn't remember what pin it was that seemed to be a cold joint, I checked them again with my multimeter's continuity check function and found that they were actually all OK; unfortunately, I can't really mess with the thing again for a few days as I'll be taking a trip. One question though: shouldn't the resistance between any A/B pair be whatever the rating of the potentiometer is? So then if I had a 10k digital potentiometer, the resistance between A1 and B1 should be 10k, for example? I just now tried testing the thing again and found that the resistance between the A and W contacts was between 0.2 and 0.3 ohms, and between 37 and 38 ohms between the W and B contacts, though I could've sworn I had ordered either 5- or 10K AD5204s... all of which seems strange. I suppose that with my limited surface mount soldering experience, I could have fried both ICs, but with my second attempt I limited the amount of time I had my iron (rated, oddly enough, for 47 and a half watts) making contact with the pins to no more than a few seconds and didn't bridge any connections...
Sign In or Register to comment.