Support for digital potentiometer
Moderators: grovkillen, Stuntteam, TD-er
Support for digital potentiometer
----- EDIT : -----
I'have a working plugin but i need your help... See comments please .
Is it possible to implement support for a digital potentiometer, as mcp41010 for example?
There is a library here : https://github.com/mensink/arduino-lib-MCP42010
or example with spi.h only here : http://electroniqueamateur.blogspot.fr/ ... en-de.html
I need to have 2 mcp41010 or equivalent, on one ESP8266, with differents value on each. value between 0 and 255 and maybe saving last value in the eeprom and restoring at reboot?
Can anyone help me?
Sorry for my bad english.
I'have a working plugin but i need your help... See comments please .
Is it possible to implement support for a digital potentiometer, as mcp41010 for example?
There is a library here : https://github.com/mensink/arduino-lib-MCP42010
or example with spi.h only here : http://electroniqueamateur.blogspot.fr/ ... en-de.html
I need to have 2 mcp41010 or equivalent, on one ESP8266, with differents value on each. value between 0 and 255 and maybe saving last value in the eeprom and restoring at reboot?
Can anyone help me?
Sorry for my bad english.
Last edited by antibill on 28 Dec 2018, 20:30, edited 1 time in total.
Re: Support for digital potentiometer
Nobody can help me?
Re: Support for digital potentiometer
Your best bet is to try yourself. I don't know how well spi works at this point, I think there is at least one supported spi device but you would have to do some reading.
Most people tend to work on what devices they have. If it was I2C someone might be able to put something together without having to test, but probably not a good idea with spi. Also you are asking for a pretty substantial time investment as well.
Most people tend to work on what devices they have. If it was I2C someone might be able to put something together without having to test, but probably not a good idea with spi. Also you are asking for a pretty substantial time investment as well.
Re: Support for digital potentiometer
Indeed SPI might be a problem here.
But as far as i know there are several digital potentiometers on the market that run with I²C,
From Analog there is the AD5243 witch is a double potentiometer out of the box.
Analog offers the AD5171, equivalent is the CAT5171 by Onsemi. Both are single
potentiometers but have one adress line so two can be combined on I²C.
All types above have 256 taps.
You may use an existing I²C device plugin for starting to make your own plugin for digital potentiometer.
Regards
Shardan
But as far as i know there are several digital potentiometers on the market that run with I²C,
From Analog there is the AD5243 witch is a double potentiometer out of the box.
Analog offers the AD5171, equivalent is the CAT5171 by Onsemi. Both are single
potentiometers but have one adress line so two can be combined on I²C.
All types above have 256 taps.
You may use an existing I²C device plugin for starting to make your own plugin for digital potentiometer.
Regards
Shardan
Regards
Shardan
Shardan
Re: Support for digital potentiometer
Thanks all, i will try again to build a plugin.
Re: Support for digital potentiometer
Hi.
I made a functional plugin, which corresponds to my expectations, except that ...
When I activate the plugin in device tab, I can not change the state of a GPIO anymore. I have to disable my plugin for it to work again ...
I'm using this Library : https://github.com/mensink/arduino-lib-MCP42010
Can you help me?
Thanks.
And sorry for my bad english...
My plugin is :
I made a functional plugin, which corresponds to my expectations, except that ...
When I activate the plugin in device tab, I can not change the state of a GPIO anymore. I have to disable my plugin for it to work again ...
I'm using this Library : https://github.com/mensink/arduino-lib-MCP42010
Can you help me?
Thanks.
And sorry for my bad english...
My plugin is :
Code: Select all
//#######################################################################################################
//#################################### Plugin 151: MCP42010 ############################################
//#######################################################################################################
// written by antibill
// List of commands:
// (1) VAL1,<chambre 0-255>
// (2) VAL2,<second 0-255>
// Usage:
// (1): Set value to potentiometer (http://xx.xx.xx.xx/control?cmd=chambre,255)
#include <MCP42010.h>
static float Plugin_151_PotDest[2] = {0,0};
#define PLUGIN_151
#define PLUGIN_ID_151 151
#define PLUGIN_NAME_151 "MCP42010"
#define PLUGIN_VALUENAME1_151 "P1"
#define PLUGIN_VALUENAME2_151 "P2"
int Plugin_151_pin[3] = {-1,-1,-1};
boolean Plugin_151(byte function, struct EventStruct *event, String& string)
{
boolean success = false;
switch (function)
{
case PLUGIN_DEVICE_ADD:
{
Device[++deviceCount].Number = PLUGIN_ID_151;
Device[deviceCount].Type = DEVICE_TYPE_DUMMY; // SPI pins for ESP8266 are CS=15, CLK=14, MOSI=13
Device[deviceCount].Ports = 0;
Device[deviceCount].VType = SENSOR_TYPE_DUAL;
Device[deviceCount].PullUpOption = false;
Device[deviceCount].InverseLogicOption = false;
Device[deviceCount].FormulaOption = true;
Device[deviceCount].ValueCount = 2;
Device[deviceCount].SendDataOption = true;
Device[deviceCount].TimerOption = true;
Device[deviceCount].TimerOptional = true;
Device[deviceCount].GlobalSyncOption = true;
break;
}
case PLUGIN_GET_DEVICENAME:
{
string = F(PLUGIN_NAME_151);
break;
}
case PLUGIN_GET_DEVICEVALUENAMES:
{
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[0], PSTR(PLUGIN_VALUENAME1_151));
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[1], PSTR(PLUGIN_VALUENAME2_151));
break;
}
case PLUGIN_WEBFORM_LOAD:
{
// char tmpString[128];
addHtml(F("<TR><TD>GPIO:<TD>"));
addHtml(F("<TR><TD>1st GPIO (CS):<TD>"));
addPinSelect(false, "taskdevicepin1", Plugin_151_pin[0] = Settings.TaskDevicePluginConfig[event->TaskIndex][0]);
addHtml(F("<TR><TD>2nd GPIO (CLK):<TD>"));
addPinSelect(false, "taskdevicepin2", Plugin_151_pin[1] = Settings.TaskDevicePluginConfig[event->TaskIndex][1]);
addHtml(F("<TR><TD>3rd GPIO (MOSI):<TD>"));
addPinSelect(false, "taskdevicepin3", Plugin_151_pin[2] = Settings.TaskDevicePluginConfig[event->TaskIndex][2]);
success = true;
break;
}
case PLUGIN_WEBFORM_SAVE:
{
String plugin2 = WebServer.arg("taskdevicepin1");
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = plugin2.toInt();
String plugin3 = WebServer.arg("taskdevicepin2");
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = plugin3.toInt();
String plugin4 = WebServer.arg("taskdevicepin3");
Settings.TaskDevicePluginConfig[event->TaskIndex][2] = plugin4.toInt();
success = true;
break;
}
case PLUGIN_INIT:
{
int pCS = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
int pCLK = Settings.TaskDevicePluginConfig[event->TaskIndex][1];
int pMOSI = Settings.TaskDevicePluginConfig[event->TaskIndex][2];
Plugin_151_pin[0] = pCS;
Plugin_151_pin[1] = pCLK;
Plugin_151_pin[2] = pMOSI;
success = true;
break;
}
case PLUGIN_WRITE:
{
String command = parseString(string, 1);
MCP42010 digipot(Plugin_151_pin[0], Plugin_151_pin[1], Plugin_151_pin[2]);
if (command == F("chambre"))
{
int val1;
val1 = event->Par1; //Pot1
Plugin_151_PotDest[0] = val1;
digipot.setPot(1,val1);
}
if (command == F("second"))
{
int val2;
val2 = event->Par1; //Pot2
Plugin_151_PotDest[1] = val2;
digipot.setPot(2,val2);
}
success = true;
break;
}
case PLUGIN_READ:
{
UserVar[event->BaseVarIndex + 0]= Plugin_151_PotDest[0] ;
UserVar[event->BaseVarIndex + 1] = Plugin_151_PotDest[1] ;
success = true;
break;
}
}
return success;
}
Re: Support for digital potentiometer
nobody has an idea for helping me ?
Re: Support for digital potentiometer
Bonjour,
je suppose que vous parlez français ?
votre plugin m'intéresse fortement. avez-vous trouvé une solution ?
Merci !
je suppose que vous parlez français ?
votre plugin m'intéresse fortement. avez-vous trouvé une solution ?
Merci !
Re: Support for digital potentiometer
Effectivement je suis français.
Pour le moment non je n'ai pas pris le temps de m'y repencher. Mais il va bien falloir que je trouve une solution... As tu fais des essais de ton coté?
Pour le moment non je n'ai pas pris le temps de m'y repencher. Mais il va bien falloir que je trouve une solution... As tu fais des essais de ton coté?
Re: Support for digital potentiometer
The plugin is merged on GitHub
Re: Support for digital potentiometer
Salut, non malheureusement, et je dois t'avouer que j'ai abandonné mes recherches. Je ne pouvais pas attendre et pour cette fois je me suis tourné vers une solution a base d'arduino. Mais apparemment ça bouge du côté du GitHub.
Ça m'intéresse, je vais approfondir cela...
Re: Support for digital potentiometer
Please can someone confirm where I can access the code for this plugin. I have tried the link and a search of github with no success.
Who is online
Users browsing this forum: No registered users and 132 guests