{"id":2193,"date":"2008-07-07T02:06:56","date_gmt":"2008-07-07T06:06:56","guid":{"rendered":"http:\/\/www.nearfuturelaboratory.com\/?p=2193"},"modified":"2017-08-18T18:02:10","modified_gmt":"2017-08-18T18:02:10","slug":"ds1803-digital-potentiometer","status":"publish","type":"post","link":"https:\/\/blog.nearfuturelaboratory.com\/2008\/07\/07\/ds1803-digital-potentiometer\/","title":{"rendered":"DS1803 Digital Potentiometer"},"content":{"rendered":"

I’ve been fussing with this digital potentiometer, the DS1803 by Maxim. They’re “digital” because you can control the resistance over its range programmatically, by sending it commands over a 2-Wire (I2C\/TWI) serial interface. So, that means that I can hook it up to some microcontroller, like the Arduino, and adjust the resistance in a little program. I chose this one in particular because it can operate at either 3V or 5V, which is convenient, and it comes in a few different models with various resistance ranges. I’m using the DS1803-010, which means it has a range of 0-10K Ohms.<\/p>\n

I created a little PCB with two DS1803s on it. Each DS1803 has two potentiometers on it, so I’ve got four on this board. The code for controlling the DS1803 is pretty straightforward. Each one is addressable over the 2-Wire interface, but because we have two on the same interface, I had to configure one to listen to a slightly different address. The details are in the specification sheet<\/a>, but basically you hardwire the three lines A0, A1, A2 (see the schematic above) to change the address. Effectively you can have up to 8 individually addressable DS1803s on one interface.<\/p>\n

<\/a><\/p>\n

<\/p>\n

In the Arduino source code example below I am only talking with one DS1803 at address 0x28. (if I was talking to to the second one in the schematic, its address was 0x29.) Here I’ve hooked up a logic analyzer to the interface to just make sure we’re communicating. The code below simply adjusts the potentiometer incrementally upward.<\/p>\n

[ad#ad-4]<\/p>\n

\n\/\/\n\/\/ Control<\/font> the<\/font> DS1803<\/font> Digital<\/font> Potentiometer<\/font>\n\n#include <Wire.h><\/font><\/strong><\/font>\n\nvoid<\/strong> setup<\/font>(<\/font>)<\/font>\n{<\/strong><\/font>\n  Wire<\/font>.begin<\/font>(<\/font>)<\/font>;<\/font> \/\/ join<\/font> i2c<\/font> bus<\/font> (<\/font>address<\/font> optional<\/font> for<\/strong> master<\/font>)<\/font>\n}<\/strong><\/font>\n\nbyte<\/font> val<\/font> =<\/font> 0<\/font>;<\/font>\n\nvoid<\/strong> loop<\/font>(<\/font>)<\/font>\n{<\/strong><\/font>\n  Wire<\/font>.beginTransmission<\/font>(<\/font>0x28<\/font>)<\/font>;<\/font> \/\/ transmit<\/font> to<\/font> device<\/font> 0x28<\/font>)<\/font>\n  Wire<\/font>.send<\/font>(<\/font>0xAA<\/font>)<\/font>;<\/font>            \/\/ sends<\/font> instruction<\/font> byte<\/font>,\n                               \/\/ write<\/font> to<\/font> potentiometer<\/font>-<\/font>0<\/font>\n  Wire<\/font>.send<\/font>(<\/font>val<\/font>)<\/font>;<\/font>             \/\/ sends<\/font> potentiometer<\/font> value<\/font> byte<\/font>\n  Wire<\/font>.endTransmission<\/font>(<\/font>)<\/font>;<\/font>     \/\/ stop<\/font> transmitting<\/font>\n\n  val<\/font>+<\/font>+<\/font>;<\/font>        \/\/ increment<\/font> value<\/font>\n  if<\/strong>(<\/font>val<\/font> =<\/font>=<\/font> 150<\/font>)<\/font> \/\/ if<\/strong> reached<\/font> 64th<\/font> position<\/font> (<\/font>max<\/font>)<\/font>\n  {<\/strong><\/font>\n    val<\/font> =<\/font> 0<\/font>;<\/font>    \/\/ start<\/font> over<\/font> from<\/font> lowest<\/font> value<\/font>\n  }<\/strong><\/font>\n  delay<\/font>(<\/font>100<\/font>)<\/font>;<\/font>\n}<\/strong><\/font>\n\n\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

I’ve been fussing with this digital potentiometer, the DS1803 by Maxim. They’re “digital” because you can control the resistance over its range programmatically, by sending it commands over a 2-Wire (I2C\/TWI) serial interface. So, that means that I can hook it up to some microcontroller, like the Arduino, and adjust the resistance in a little … Continue reading DS1803 Digital Potentiometer<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[18,22,78,84],"tags":[1178,356,464,480,492,1195,722],"yoast_head":"\nDS1803 Digital Potentiometer - Near Future Laboratory<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blog.nearfuturelaboratory.com\/2008\/07\/07\/ds1803-digital-potentiometer\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"DS1803 Digital Potentiometer - Near Future Laboratory\" \/>\n<meta property=\"og:description\" content=\"I’ve been fussing with this digital potentiometer, the DS1803 by Maxim. They’re “digital” because you can control the resistance over its range programmatically, by sending it commands over a 2-Wire (I2C\/TWI) serial interface. So, that means that I can hook it up to some microcontroller, like the Arduino, and adjust the resistance in a little … Continue reading DS1803 Digital Potentiometer\" \/>\n<meta property=\"og:url\" content=\"https:\/\/blog.nearfuturelaboratory.com\/2008\/07\/07\/ds1803-digital-potentiometer\/\" \/>\n<meta property=\"og:site_name\" content=\"Near Future Laboratory\" \/>\n<meta property=\"article:published_time\" content=\"2008-07-07T06:06:56+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-08-18T18:02:10+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/farm4.static.flickr.com\/3053\/2645309524_c9e66a40ec.jpg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@nearfuturelab\" \/>\n<meta name=\"twitter:site\" content=\"@nearfuturelab\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https:\/\/blog.nearfuturelaboratory.com\/#organization\",\"name\":\"Near Future Laboratory\",\"url\":\"https:\/\/blog.nearfuturelaboratory.com\/\",\"sameAs\":[\"https:\/\/www.instagram.com\/nearfuturelaboratory\/\",\"https:\/\/www.linkedin.com\/company\/near-future-laboratory\/\",\"https:\/\/twitter.com\/nearfuturelab\"],\"logo\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/blog.nearfuturelaboratory.com\/#logo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/blog.nearfuturelaboratory.com\/wp-content\/uploads\/2019\/10\/NearFutureLaboratoryLogo-CS4.jpg\",\"width\":1049,\"height\":206,\"caption\":\"Near Future Laboratory\"},\"image\":{\"@id\":\"https:\/\/blog.nearfuturelaboratory.com\/#logo\"}},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/blog.nearfuturelaboratory.com\/#website\",\"url\":\"https:\/\/blog.nearfuturelaboratory.com\/\",\"name\":\"Near Future Laboratory\",\"description\":\"Clarify Today, Design Tomorrow\",\"publisher\":{\"@id\":\"https:\/\/blog.nearfuturelaboratory.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/blog.nearfuturelaboratory.com\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/blog.nearfuturelaboratory.com\/2008\/07\/07\/ds1803-digital-potentiometer\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"http:\/\/farm4.static.flickr.com\/3053\/2645309524_c9e66a40ec.jpg\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/blog.nearfuturelaboratory.com\/2008\/07\/07\/ds1803-digital-potentiometer\/#webpage\",\"url\":\"https:\/\/blog.nearfuturelaboratory.com\/2008\/07\/07\/ds1803-digital-potentiometer\/\",\"name\":\"DS1803 Digital Potentiometer - Near Future Laboratory\",\"isPartOf\":{\"@id\":\"https:\/\/blog.nearfuturelaboratory.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/blog.nearfuturelaboratory.com\/2008\/07\/07\/ds1803-digital-potentiometer\/#primaryimage\"},\"datePublished\":\"2008-07-07T06:06:56+00:00\",\"dateModified\":\"2017-08-18T18:02:10+00:00\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/blog.nearfuturelaboratory.com\/2008\/07\/07\/ds1803-digital-potentiometer\/\"]}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/blog.nearfuturelaboratory.com\/2008\/07\/07\/ds1803-digital-potentiometer\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/blog.nearfuturelaboratory.com\/2008\/07\/07\/ds1803-digital-potentiometer\/#webpage\"},\"author\":{\"@id\":\"https:\/\/blog.nearfuturelaboratory.com\/#\/schema\/person\/4648c18232bc2e176a1197eda0225c08\"},\"headline\":\"DS1803 Digital Potentiometer\",\"datePublished\":\"2008-07-07T06:06:56+00:00\",\"dateModified\":\"2017-08-18T18:02:10+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/blog.nearfuturelaboratory.com\/2008\/07\/07\/ds1803-digital-potentiometer\/#webpage\"},\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/blog.nearfuturelaboratory.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/blog.nearfuturelaboratory.com\/2008\/07\/07\/ds1803-digital-potentiometer\/#primaryimage\"},\"keywords\":\"Arduino,Circuit,Digital Potentiometer,DS1803,Electronics,Hardware,Maxim DS1803\",\"articleSection\":\"Arduino,Atmel,Hardware,How To\",\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/blog.nearfuturelaboratory.com\/#\/schema\/person\/4648c18232bc2e176a1197eda0225c08\",\"name\":\"Julian\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/blog.nearfuturelaboratory.com\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"http:\/\/0.gravatar.com\/avatar\/f8c8f20a3bedb22c3adce22082147ae4?s=96&d=mm&r=g\",\"caption\":\"Julian\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/blog.nearfuturelaboratory.com\/wp-json\/wp\/v2\/posts\/2193"}],"collection":[{"href":"https:\/\/blog.nearfuturelaboratory.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.nearfuturelaboratory.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.nearfuturelaboratory.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.nearfuturelaboratory.com\/wp-json\/wp\/v2\/comments?post=2193"}],"version-history":[{"count":1,"href":"https:\/\/blog.nearfuturelaboratory.com\/wp-json\/wp\/v2\/posts\/2193\/revisions"}],"predecessor-version":[{"id":10595,"href":"https:\/\/blog.nearfuturelaboratory.com\/wp-json\/wp\/v2\/posts\/2193\/revisions\/10595"}],"wp:attachment":[{"href":"https:\/\/blog.nearfuturelaboratory.com\/wp-json\/wp\/v2\/media?parent=2193"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.nearfuturelaboratory.com\/wp-json\/wp\/v2\/categories?post=2193"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.nearfuturelaboratory.com\/wp-json\/wp\/v2\/tags?post=2193"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}