Menu

New MAX5481–MAX5484 1potentiometer library

Anobium
2020-06-18
2020-06-19
  • Anobium

    Anobium - 2020-06-18

    The MAX5481–MAX5484 10-bit (1024-tap) nonvolatile, linear-taper, programmable voltage-dividers and variable resistors perform the function of a mechanical potentiometer, but replace the mechanics with a pinconfigurable 3-wire serial SPI™-compatible interface or up/down digital interface. The MAX5481/MAX5482 are 3-terminal voltage-dividers and the MAX5483/MAX5484 are 2-terminal variable resistors.

    The MAX5481–MAX5484 feature an internal, nonvolatile, electrically erasable programmable read-only memory (EEPROM) that stores the wiper position for initialization during power-up. The 3-wire SPI-compatible serial interface allows communication at data rates up to 7MHz. A pin-selectable up/down digital interface is also available.

    The MAX5481–MAX5484 are ideal for applications requiring digitally controlled potentiometers. Two end-toend resistance values are available (10kO and 50kO) in a voltage-divider or a variable-resistor configuration.

    These devices ideal for applications requiring low-temperature-coefficient voltage-dividers, such as low-drift, programmable gain-amplifiers.

    The MAX848xDigitalPotSetWiperPosition and MAX848xDigitalPotDecrement methods ONLY support software SPI.

    Methods

    MAX848xDigitalPotSetWiperPosition ( word value where range is 0 to 1023 ) Sets the pot value
    MAX848xCopyWiperRegistertoNVRegister Sets the NVRAM to the current pot value
    MAX848xCopyNVRegistertoWiperRegister Sets the current pot value to MVRAM
    MAX848xDigitalPotIncrement Increment the current pot value
    MAX848xDigitalPotDecrement Decrement the current pot value

    Configuration

    Three ports and one optional port are required as shown below.
    
    #DEFINE MAX848XDIGITALPOT_CS       PORTC.0
    #DEFINE MAX848XDIGITALPOT_SCK      PORTC.1
    #DEFINE MAX848XDIGITALPOT_DO       PORTC.2
    #DEFINE MAX848XDIGITALPOT_IOMODE   PORTC.3   - Optional
    
    MAX848XDIGITALPOT_IOMODE to control SPI or Up/Down modes automatically, or if you do not define MAX848XDIGITALPOT_IOMODE then set the SPI/UD in the Max848x as follows:
                SPI/UD = HIGH (connected permanently to high voltage ) then the you can only use the SPI controls as follows:
                         MAX848xDigitalPotSetWiperPosition
                         MAX848xCopyWiperRegistertoNVRegister
                         MAX848xCopyNVRegistertoWiperRegister
                SPI/UD = LOW (connected permanently to 0v ) then the you can only use the SPI controls as follows:
                         MAX848xDigitalPotIncrement
                         MAX848xDigitalPotDecrement
    

    The library is easy to use. Set up the ports, decide on SPI methof (software or hardware), attach the MAX848x and it should work,

    Enjoy

     
  • mkstevo

    mkstevo - 2020-06-19

    Many thanks. I appreciate you sharing this code.

     
  • Anobium

    Anobium - 2020-06-19

    Cheers. It was so easy to do. I took the existing digital pot and improved.

    The best part... seeing the pot values come up on my bench meter!!

     
  • mkstevo

    mkstevo - 2020-06-19

    That's the "fun" part!

    What's less "fun" is when it doesn't work, and you can't for the life of you see why. Is it a wiring error? A misunderstanding of the datasheet? Or (and more likely in my case) a silly coding error?

    I spent ages yesterday trying to figure out why something wasn't working. I finally spotted that in trying to do something else I'd changed Timer1 to Timer2. As that hadn't worked, I changed everything back to Timer1. Everything that is apart from the code that actually started the timer, it was still starting Timer2. Left with my original problem of why an overflow interrupt triggered every time, when I wasn't expecting it, it took me way too long to realise that my "expected" event should have triggered in 40,000 timer counts. As this then had to wait for another (potential) 40,000 counts before the next event, there was no surprise that the overflow ocurred. No surprise, except to me who'd spent well over four hours on this one problem...

    Still, my Grid Frequency Meter is now working and once I've drawn up the circuit I'll post the circuit and code in the Projects and Guides section.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.