Hello Hello ! 🙂
I am thrilled to inform you that my last driver for Maxim MAX5487 digital potentiometer has just been accepted into Linux Kernel and will be available in the next release. I’m happier than Oscar winning Leo right now 😀 Many many many thanks to my mentor Daniel Baluta for guidance.
Let me present some technical details of the implementation:
This is MAX5487, a digital potentiometer which did not have driver support in Linux:
First of all, I will explain how a digital potentiometer works in comparison with the old fashion one.
In the mechanical potentiometer is a 3-terminal resistor with a rotating contact used to adjust the position of the middle terminal in order to create a variable resistor or a voltage divider.
In comparison, the digital potentiometer has no rotative slide and sets the middle terminal according to a value held in one of the internal registers. The following image emphasises exactly what I am talking about. VH and VL are the circuit points for high and low potential, respectively, while VW is the sliding point. If VW is set to VL the resistence is equal to the maxim resistence of the potentiometer and if VW is set to VH the resistence is almost 0. VW’s position is determined by the value of the corresponding register.
As you can notice in a previous image, MAX5487 has 2 similar circuits A (HA, WA, LA) and B (HB, WB, LB) which represent two different input channels from the driver’s point of view.
Perhaps you wonder how to set the VW values onto the potentiometer’s registers.
MAX5487 receives input via SPI, a popular protocol for embedded devices. Since the PC does not have and SPI interface, I made use of a device called Diolan which is able to intermediate the USB interface of the PC with the SPI interface of the potentiometer.
Wires connect the SPI interface of the potentiometer to the SPI interface of the Diolan. The Diolan makes the translation and communicates with the PC via the USB cable. The extra wire from the upper pin of MAX5487 represents the Chip-Select pin and is controlled by a GPIO pin of the Diolan.
This assembly enables the potentiometer to be detected as being directly connected to the PC. The driver permits the user to set in software the VW values which will be sent to the potentiometer and written into the dedicated registers. For device communication I used the kernel functions offered by SPI and GPIO APIs. Further, the code speaks for itself. The complete implementation can be found here.
Thanks ! 🙂