Go Down

Topic: Digital Pot Non Volatile Memory MCP4261 (Read 102 times) previous topic - next topic

HPB

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:

https://github.com/teabot/McpDigitalPot

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.

TonyWilk

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

DrAzzy

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!
ATtiny core for 841+1634+828 and x313/x4/x5/x61/x7/x8 series Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts (some assembled), mosfets and awesome prototyping board in my store http://tindie.com/stores/DrAzzy

HPB

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.


DrAzzy

#4
Jan 04, 2018, 12:53 pm Last Edit: Jan 04, 2018, 12:54 pm by DrAzzy
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!
ATtiny core for 841+1634+828 and x313/x4/x5/x61/x7/x8 series Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts (some assembled), mosfets and awesome prototyping board in my store http://tindie.com/stores/DrAzzy

HPB

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.

DrAzzy

Select the correct board from tools -> board menu. If no options there, drivers need to be installed.
ATtiny core for 841+1634+828 and x313/x4/x5/x61/x7/x8 series Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts (some assembled), mosfets and awesome prototyping board in my store http://tindie.com/stores/DrAzzy

Go Up