Shop OBEX P1 Docs P2 Docs Learn Events
digital potentiometer and constant voltage output — Parallax Forums

digital potentiometer and constant voltage output

preyespreyes Posts: 7
edited 2006-04-23 23:07 in BASIC Stamp
I need to set the output voltage from one of my pins to 0.6 V and at another pin at 3.3 V.· From what i've read so far it sounds like you can only set it high (5 volts) and low (0 volts) but nothing in between.··So now I'm·trying to interface a digital potentiometer to get the output voltage that I need, but i'm not sure how to write the code that will do this.· 'What's a Microctroller?' shows an example on how to adjust the voltage through the pot's whole range but not how to keep it steady at one set value without using the user input from the debug terminal.· Does anyone have any suggestions?

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-04-23 17:44
    You should, theoretically, be able to do this with a bit of math.· Let's say you have an 8-bit digital pot and your source is 5v.· This would give you 19.6 mv per count.· Here's the math:

    0.6 / 0.0196 = 30.6 (you should try 30 and 31 to see which is best for your app)

    3.3 / 0.0196 = 168.3 (truncate to 168)


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • preyespreyes Posts: 7
    edited 2006-04-23 18:57
    Thanks Jon for your response. But how would I write a program to set the pot at 30 or 168? Is there a simple command that will set it at a certain level and keep it at that level? Also, since the stamp is running off of a 9 volt battery, for every output that I have is it just subtracting from that total of 9 volts? For example, if I'm using 0.6 volts out of one pin and 3.3 volts out of another, then I should have 5.1 volts left over (not counting whatever is needed for the stamp to operate), right?
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-04-23 20:23
    You have to understand the interface to your digital pot; once you know that the rest is simple. What digital pot are you using? I don't have any practical experience with them, but the code I've seen uses a synchronous interface (so SHIFTOUT is used). Also, your digital pot might not allow for 9v in -- you have to check for that. As is often said, the devil is in the details and there is no escaping them; try to to cheat "the devil" (details) and you may break something.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • stamptrolstamptrol Posts: 1,731
    edited 2006-04-23 20:34
    Another practical way to get a variable output voltage which you can set and forget is to use a digital to analog converter chip. The D/A like an LTC 1451 will allow you set the 0 to 5 volt output to a 1 in 4095 accuracy. Its also easy to have several LTC1451's on one stamp without using too many pins. I think there is a Parallax Application note for the '1451.

    Cheers
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2006-04-23 21:40
    If you already have a digital pot, let us know which one it is. The one in the original edition of WAM uses 32 position pot that has an up/down and an increment pin. (The new WAM may use a different one.) To set it to a known value, you first have to reset it to zero by setting it to count "down, and then give it 32 "decrement" pulses. Then to set it to the voltage you want, you set it to "up" and give it a certain number of "increment" pulses. To get it to 3.3 volts, that would be 21 pulses. Then you leave it there, and it will not change until your program tells it to, or you power down and up again. A resolution of 1/32 is not much--Is it enough?

    The following statement doesn't make any sense to me: "if I'm using 0.6 volts out of one pin and 3.3 volts out of another, then I should have 5.1 volts left over (not counting whatever is needed for the stamp to operate), right?" What do you mean? The digital pot is in parallel with the power supply, but your comment suggests to me that you think it is in series.

    There are digital pots that have many more available steps, and there are also digital pots that have internal memory that "remember" their setting, so that when you turn on the power it automatically comes back the the setting where you left it. Those usually have a SHIFTOUT or I2COUT interface, instead of increment/decrement.

    The option of a DAC may be better for you.
    The following messages have code for a couple of different 12 bit (4096 step) DACs...
    MAX5722:
    http://forums.parallax.com/forums/default.aspx?f=5&p=2&m=88071#m91143
    TLV5618A:
    http://forums.parallax.com/forums/default.aspx?f=5&p=2&m=88071#m93372

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • preyespreyes Posts: 7
    edited 2006-04-23 23:07
    Thanks for everyone's help. I'm using an AD5220, the one that came with my basic stamp homework board from RadioShack. I'll work on it some more before I post anymore questions. Thanks.
Sign In or Register to comment.