Shop OBEX P1 Docs P2 Docs Learn Events
Terminal Controlled AD5220 Digital Pot! — Parallax Forums

Terminal Controlled AD5220 Digital Pot!

Rich_W8VKRich_W8VK Posts: 44
edited 2009-01-15 20:31 in Learn with BlocklyProp
Hello All!
···· I've·been·working·with the What's a MicroController Book, Chapter 9, The Project: Terminal Controlled Digital Pot . bas Program that I'm wondering if anybody out there has pushed the learning curve further into controlling (2) AD5220 Digital Pots at the same time with an adaptation of this original program?
···· I'm interested in any thoughts, suggestions, comments, or a developed program in PBasic that will do this task! Thanks for reading my Post!

Rich
···

Comments

  • edited 2009-01-14 15:51
    Hi Rich,

    Good question. Digital pots can be used to control amplifier gains and offsets, so there are lots of products and inventions out there that rely the modifications you are proposing.

    This project can be performed with the BASIC Stamp Activity Kit and one additional AD5220 digital potentiometer.··If you'd like to·find this kit locally (Radio Shack, Frys, etc),·check www.parallax.com -> Company -> Distributors.· Or, if you already have a BASIC Stamp + Board of Education, all you'll need is the What's a Microcontroller Parts Kit and a second AD5220, or just a minimum of two AD5220 chips.

    The code can be expanded so that the terminal asks you which digital pot to set. The program will need another set of variables to keep track of the other tap settings. I would recommend declaring oldTapSetting and newTapSetting as two element byte arrays.

    oldTapSetting VAR Byte(2)
    newTapSetting VAR Byte(2)

    Instead of hardwiring the chips' /CS pins to Vss, each chip's /CS pin should be connected to different BASIC Stamp I/O pins. Then, the second chip's U/D and CLK pins can be connected to the same lines that control the first chip. The program will have to be modified to set both /CS lines HIGH at the beginning of the program. Then, it should set the /CS line low for the chip that the BASIC Stamp needs to control. The other chip with its /CS line high won't listen, only the one with its /CS line low.

    In the Get_New_Tap_Setting subourtine, the answer to the question about which POT to use will get stored in a variable. If the answer will be either 0 or 1, you can use a bit variable. Let's call it potIndex. (If you had to control three digital pots, you would need a nibble variable.) An IF...THEN statement will decide which /CS pin to set low using the value in potIndex before calling the Set_Ud_Pin subroutine.

    The Set_Ud_Pin subroutine will be working with names changed from newTapSetting and oldTapSetting to newTapSetting(potIndex) and oldTapSetting(potIndex). Likewise with the Pulse_Clk_Pin subroutine.

    Andy

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Andy Lindsay

    Education Department
    Parallax, Inc.

    Post Edited (Andy Lindsay (Parallax)) : 1/14/2009 5:31:35 PM GMT
  • Rich_W8VKRich_W8VK Posts: 44
    edited 2009-01-14 23:45
    Post Edited (Rich_W8VK) : 1/18/2009 10:30:11 PM GMT
  • edited 2009-01-15 20:31
    Rich,

    Is it possible to re-route the board so that CLK and U/D are common and each chip's /CS goes to individual I/O pins? It can certainly be done the way you have it, but the way I'm suggesting has a list of benefits:

    - Greatly simplifies the code
    - Frees up BASIC Stamp I/O pins controlling/monitoring other peripherals
    - Utilizes features designed into the chip for that purpose
    - Introduces useful design concepts (shared data bus & chip select)
    - Makes increasing to four devices much much simpler

    So, if it is possible to modify your existing board, I recommend it. If not, the project is still totally doable.

    Regarding string parsing (A6, B2, etc), no problem. What's a Microcontroller provides code examples you can use as building blocks. I think the best way to get started would be to review Chapter 8, Activities 3 - 5 and Chapter 10, Activity 4. This has all the building blocks you'll need. In terms of code that lends itself to the system you are designing, here is an example (attached). Note that the results are decimal values that can be used (along with a little math) to choose the chip select pin and tap value to simplify modifications to the code in Chapter 9, Activity 2.

    Andy

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Andy Lindsay

    Education Department
    Parallax, Inc.
Sign In or Register to comment.