Digital Pot Non Volatile Memory MCP4261

Hi there and thank you for your time.

I am trying to write to the non volatile memory of the MCP4261. I have used the code from 'teabot' off of github:

I have connected the digital pot as per the data sheet. The code works and writes to the volatile memory but does not save this wiper position.

Any advice or comments are much appreciated.

MCP4261 Code.ino (3.14 KB)

Does it work if you run the example code ?

How do you know it's not saving the wiper position ? what circuit is it in ?

Yours,
TonyWilk

The digipots with NV memory have both volatile and nonvolatile wiper position; you are only setting the volatile one (that library does not support writing to the nonvolatile one as far as I can tell - it also looks like it hasn't been touched since dinosaurs walked the earth - note the .pde extension on the example).

It's a good thing though, because if you'd been writing to the nv memory every pass through loop, you'd blow through the lifetime write cycle spec in no time!

TonyWilk - Thank you for your response - Yes it does work with the example code. I know that it is not saving as I am testing the resistance of the wiper once programmed and then again on restarting the pot without arduino connections. The circuit is simply connecting the relevant arduino pins and measuring the resistance.

DrAzzy - Thank you also for your response - Please can you advise exactly which aspect of the code I need to alter or give an example of some other code that I could use instead? Like you advise I will add a simple statement so that the code will only write once to the digipot each time it is uploaded.

See page 45-46 of the datasheet; it has to send 2 bytes to write to a wiper register, one with address/command and 2 data bits, followed by the rest of the data. You need to write to address 0x02 or 0x03 instead of 0x00 or 0x01.

Figuring out where precisely to make the change in the library requires more patience than I have (when doing this for free); it's not rocket surgery. I think there must be a newer version of that library, everyone and their mom uses these digipots - when someone says "I need a digipot", they use an MCP4xxx series - I refuse to believe that there isn't an Arduino library that lets you write to the NV registers!

Thank you and I understand that this was a simple topic and I have solved it now. There was really no need for a library and I was over complicating matters with this. My problem lay in transferring the right information to the pot.

Example_Digi_Pot_Code.ino (504 Bytes)

Select the correct board from tools -> board menu. If no options there, drivers need to be installed.