mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.3.4 AD524X
This commit is contained in:
parent
a393271f22
commit
c5860b1584
@ -1,7 +1,7 @@
|
||||
//
|
||||
// FILE: AD524X.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.3.3
|
||||
// VERSION: 0.3.4
|
||||
// PURPOSE: I2C digital potentiometer AD5241 AD5242
|
||||
// DATE: 2013-10-12
|
||||
// URL: https://github.com/RobTillaart/AD524X
|
||||
@ -9,7 +9,8 @@
|
||||
// HISTORY
|
||||
// 2021-10-16 0.3.2 fix build-CI, update readme.md
|
||||
// 2021-12-10 0.3.3 update constants, library.json, license
|
||||
|
||||
// 2022-08-13 0.3.4 fix AD524X_LIB_VERSION
|
||||
// minor edits,
|
||||
|
||||
|
||||
#include "AD524X.h"
|
||||
@ -161,7 +162,7 @@ uint8_t AD524X::midScaleReset(const uint8_t rdac)
|
||||
}
|
||||
|
||||
|
||||
// read datasheet P.15
|
||||
// read datasheet P.15
|
||||
uint8_t AD524X::shutDown()
|
||||
{
|
||||
uint8_t cmd = AD524X_SHUTDOWN; // TODO TEST & VERIFY
|
||||
@ -185,7 +186,7 @@ uint8_t AD524X::send(const uint8_t cmd, const uint8_t value)
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DERIVED CLASSES
|
||||
//
|
||||
//
|
||||
AD5241::AD5241(const uint8_t address, TwoWire *wire) : AD524X(address, wire)
|
||||
{
|
||||
_pmCount = 1;
|
||||
@ -197,4 +198,6 @@ AD5242::AD5242(const uint8_t address, TwoWire *wire) : AD524X(address, wire)
|
||||
_pmCount = 2;
|
||||
};
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// FILE: AD524X.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.3.3
|
||||
// VERSION: 0.3.4
|
||||
// PURPOSE: I2C digital PotentioMeter AD5241 AD5242
|
||||
// DATE: 2013-10-12
|
||||
// URL: https://github.com/RobTillaart/AD524X
|
||||
@ -12,7 +12,7 @@
|
||||
#include "Wire.h"
|
||||
|
||||
|
||||
#define AD524X_VERSION (F("0.3.3"))
|
||||
#define AD524X_LIB_VERSION (F("0.3.4"))
|
||||
|
||||
|
||||
#define AD524X_OK 0
|
||||
@ -29,7 +29,7 @@ public:
|
||||
#endif
|
||||
bool begin();
|
||||
bool isConnected();
|
||||
|
||||
|
||||
uint8_t reset(); // reset both channels to 127 and O1/O2 to LOW
|
||||
uint8_t zeroAll(); // set both channels to 0 and O1/O2 to LOW
|
||||
|
||||
@ -69,7 +69,7 @@ private:
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DERIVED CLASSES
|
||||
//
|
||||
//
|
||||
class AD5241 : public AD524X
|
||||
{
|
||||
public:
|
||||
@ -85,3 +85,4 @@ public:
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -24,6 +24,12 @@ An important property of the devices is that they defaults
|
||||
to their mid position at startup.
|
||||
|
||||
|
||||
#### Related libraries
|
||||
|
||||
This library is related to - https://github.com/RobTillaart/AD5245
|
||||
The AD5245 is a single port digital potentiometer.
|
||||
|
||||
|
||||
## I2C address
|
||||
|
||||
The AD524X has two address lines to configure the I2C address. 0x2C - 0x2F
|
||||
@ -91,5 +97,5 @@ The examples show the basic working of the functions.
|
||||
## Future
|
||||
|
||||
- improve error handling.
|
||||
- sync with AD520X library?
|
||||
- sync with AD520X library
|
||||
|
||||
|
@ -1,12 +1,11 @@
|
||||
//
|
||||
// FILE: AD524X_followA0.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.2
|
||||
// PURPOSE: AD524X demo program
|
||||
// DATE: 2013-10-12
|
||||
// URL: https://github.com/RobTillaart/AD524X
|
||||
//
|
||||
|
||||
|
||||
#include "AD524X.h"
|
||||
|
||||
AD524X AD01(0x2C); // AD0 & AD1 == GND
|
||||
@ -15,11 +14,17 @@ AD524X AD01(0x2C); // AD0 & AD1 == GND
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println();
|
||||
Serial.println(__FILE__);
|
||||
Serial.println(AD524X_VERSION);
|
||||
Serial.println();
|
||||
Serial.println(AD524X_LIB_VERSION);
|
||||
|
||||
Wire.begin();
|
||||
Wire.setClock(400000);
|
||||
|
||||
bool b = AD01.begin();
|
||||
Serial.println(b ? "true" : "false");
|
||||
Serial.println(AD01.isConnected());
|
||||
}
|
||||
|
||||
|
||||
@ -43,3 +48,4 @@ void loop()
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -1,9 +1,7 @@
|
||||
//
|
||||
// FILE: AD524X_isConnected.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.0
|
||||
// PURPOSE: AD524X demo program
|
||||
// DATE: 2021-01-27
|
||||
// URL: https://github.com/RobTillaart/AD524X
|
||||
//
|
||||
|
||||
@ -16,14 +14,16 @@ AD524X AD01(0x2C); // AD0 & AD1 == GND
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println();
|
||||
Serial.println(__FILE__);
|
||||
Serial.println(AD524X_VERSION);
|
||||
Serial.println();
|
||||
Serial.println(AD524X_LIB_VERSION);
|
||||
|
||||
Wire.begin();
|
||||
Wire.setClock(400000);
|
||||
|
||||
|
||||
bool b = AD01.begin();
|
||||
Serial.println(b?"true":"false");
|
||||
Serial.println(b ? "true" : "false");
|
||||
Serial.println(AD01.isConnected());
|
||||
|
||||
Serial.println("\nDone...");
|
||||
@ -34,4 +34,6 @@ void loop()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -1,33 +1,40 @@
|
||||
//
|
||||
// FILE: AD524X_midScaleReset.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.2
|
||||
// PURPOSE: AD524X demo program
|
||||
// DATE: 2013-10-12
|
||||
// URL: https://github.com/RobTillaart/AD524X
|
||||
//
|
||||
|
||||
|
||||
#include "AD524X.h"
|
||||
|
||||
AD524X AD01(0x2C); // AD0 & AD1 == GND
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println();
|
||||
Serial.println(__FILE__);
|
||||
Serial.println(AD524X_VERSION);
|
||||
Serial.println();
|
||||
Serial.println(AD524X_LIB_VERSION);
|
||||
|
||||
Wire.begin();
|
||||
Wire.setClock(400000);
|
||||
|
||||
bool b = AD01.begin();
|
||||
Serial.println(b ? "true" : "false");
|
||||
Serial.println(AD01.isConnected());
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
Serial.println(255);
|
||||
AD01.write(1, 255);
|
||||
delay(1000);
|
||||
|
||||
Serial.println("reset");
|
||||
Serial.println("midScaleReset(1)");
|
||||
AD01.midScaleReset(1);
|
||||
delay(1000);
|
||||
|
||||
@ -35,9 +42,11 @@ void loop()
|
||||
AD01.write(1, 0);
|
||||
delay(1000);
|
||||
|
||||
Serial.println("reset");
|
||||
Serial.println("midScaleReset(1)");
|
||||
AD01.midScaleReset(1);
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -1,26 +1,33 @@
|
||||
//
|
||||
// FILE: AD524X_read.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.2
|
||||
// PURPOSE: AD524X demo program
|
||||
// DATE: 2013-10-12
|
||||
// URL: https://github.com/RobTillaart/AD524X
|
||||
//
|
||||
|
||||
|
||||
#include "AD524X.h"
|
||||
|
||||
AD524X AD01(0x2C); // AD0 & AD1 == GND
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println();
|
||||
Serial.println(__FILE__);
|
||||
Serial.println(AD524X_VERSION);
|
||||
Serial.println();
|
||||
Serial.println(AD524X_LIB_VERSION);
|
||||
|
||||
Wire.begin();
|
||||
Wire.setClock(400000);
|
||||
|
||||
bool b = AD01.begin();
|
||||
Serial.println(b ? "true" : "false");
|
||||
Serial.println(AD01.isConnected());
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
for (int val = 0; val < 255; val++)
|
||||
@ -28,6 +35,7 @@ void loop()
|
||||
Serial.print(val);
|
||||
AD01.write(1, val);
|
||||
delay(100);
|
||||
|
||||
int x = AD01.read(1);
|
||||
Serial.print('\t');
|
||||
Serial.println(x);
|
||||
@ -36,4 +44,5 @@ void loop()
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
@ -1,50 +1,60 @@
|
||||
//
|
||||
// FILE: AD524X_readBackRegister.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.1
|
||||
// PURPOSE: AD524X demo program
|
||||
// DATE: 2016-04-10
|
||||
// URL: https://github.com/RobTillaart/AD524X
|
||||
//
|
||||
|
||||
|
||||
#include "AD524X.h"
|
||||
|
||||
AD524X AD01(0x2C); // AD0 & AD1 == GND
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println();
|
||||
Serial.println(__FILE__);
|
||||
Serial.println(AD524X_VERSION);
|
||||
Serial.println();
|
||||
Serial.println(AD524X_LIB_VERSION);
|
||||
|
||||
Wire.begin();
|
||||
Wire.setClock(400000);
|
||||
|
||||
bool b = AD01.begin();
|
||||
Serial.println(b ? "true" : "false");
|
||||
Serial.println(AD01.isConnected());
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
for (int rdac = 0; rdac < 2; rdac++)
|
||||
for (int rdac = 0; rdac < 2; rdac++)
|
||||
{
|
||||
for (int val = 0; val < 255; val++)
|
||||
{
|
||||
for (int val = 0; val < 255; val++)
|
||||
{
|
||||
test(rdac, val);
|
||||
}
|
||||
test(rdac, val);
|
||||
}
|
||||
delay(1000);
|
||||
}
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
void test(uint8_t rdac, uint8_t val)
|
||||
{
|
||||
Serial.print(val);
|
||||
AD01.write(rdac, val);
|
||||
delay(100);
|
||||
int x = AD01.read(rdac);
|
||||
int y = AD01.readBackRegister();
|
||||
Serial.print('\t');
|
||||
Serial.print(x);
|
||||
Serial.print('\t');
|
||||
Serial.println(y);
|
||||
delay(100);
|
||||
Serial.print(val);
|
||||
AD01.write(rdac, val);
|
||||
delay(100);
|
||||
|
||||
int x = AD01.read(rdac);
|
||||
int y = AD01.readBackRegister();
|
||||
Serial.print('\t');
|
||||
Serial.print(x);
|
||||
Serial.print('\t');
|
||||
Serial.println(y);
|
||||
delay(100);
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -1,26 +1,33 @@
|
||||
//
|
||||
// FILE: AD524X_sawtooth.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.2
|
||||
// PURPOSE: AD524X demo program
|
||||
// DATE: 2013-10-12
|
||||
// URL: https://github.com/RobTillaart/AD524X
|
||||
//
|
||||
|
||||
|
||||
#include "AD524X.h"
|
||||
|
||||
AD524X AD01(0x2C); // AD0 & AD1 == GND
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println();
|
||||
Serial.println(__FILE__);
|
||||
Serial.println(AD524X_VERSION);
|
||||
Serial.println();
|
||||
Serial.println(AD524X_LIB_VERSION);
|
||||
|
||||
Wire.begin();
|
||||
Wire.setClock(400000);
|
||||
|
||||
bool b = AD01.begin();
|
||||
Serial.println(b ? "true" : "false");
|
||||
Serial.println(AD01.isConnected());
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
for (int val = 0; val < 255; val++)
|
||||
@ -31,4 +38,6 @@ void loop()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -1,29 +1,36 @@
|
||||
//
|
||||
// FILE: AD524X_setO.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.2
|
||||
// PURPOSE: AD524X demo program
|
||||
// DATE: 2013-10-12
|
||||
// URL: https://github.com/RobTillaart/AD524X
|
||||
//
|
||||
|
||||
|
||||
#include "AD524X.h"
|
||||
|
||||
AD524X AD01(0x2C); // AD0 & AD1 == GND
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println();
|
||||
Serial.println(__FILE__);
|
||||
Serial.println(AD524X_VERSION);
|
||||
Serial.println();
|
||||
Serial.println(AD524X_LIB_VERSION);
|
||||
|
||||
Wire.begin();
|
||||
Wire.setClock(400000);
|
||||
|
||||
bool b = AD01.begin();
|
||||
Serial.println(b ? "true" : "false");
|
||||
Serial.println(AD01.isConnected());
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
int x = 10+analogRead(A0);
|
||||
int x = 10 + analogRead(A0);
|
||||
AD01.setO1(LOW);
|
||||
AD01.setO2(HIGH);
|
||||
Serial.print(AD01.getO1());
|
||||
@ -31,7 +38,7 @@ void loop()
|
||||
Serial.println(AD01.getO2());
|
||||
delay(x);
|
||||
|
||||
x = 10+analogRead(A0);
|
||||
x = 10 + analogRead(A0);
|
||||
AD01.setO1(HIGH);
|
||||
AD01.setO2(LOW);
|
||||
Serial.print(AD01.getO1());
|
||||
@ -40,4 +47,6 @@ void loop()
|
||||
delay(x);
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -1,26 +1,33 @@
|
||||
//
|
||||
// FILE: AD524X_write.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.2
|
||||
// PURPOSE: AD524X demo program
|
||||
// DATE: 2013-10-12
|
||||
// URL: https://github.com/RobTillaart/AD524X
|
||||
//
|
||||
|
||||
|
||||
#include "AD524X.h"
|
||||
|
||||
AD524X AD01(0x2C); // AD0 & AD1 == GND
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println();
|
||||
Serial.println(__FILE__);
|
||||
Serial.println(AD524X_VERSION);
|
||||
Serial.println();
|
||||
Serial.println(AD524X_LIB_VERSION);
|
||||
|
||||
Wire.begin();
|
||||
Wire.setClock(400000);
|
||||
|
||||
bool b = AD01.begin();
|
||||
Serial.println(b ? "true" : "false");
|
||||
Serial.println(AD01.isConnected());
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
for (int val = 0; val < 255; val++)
|
||||
@ -39,4 +46,6 @@ void loop()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -1,44 +1,53 @@
|
||||
//
|
||||
// FILE: AD524X_write_AD5241ino.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.0
|
||||
// PURPOSE: AD524X demo program
|
||||
// DATE: 2020-12-08
|
||||
// URL: https://github.com/RobTillaart/AD524X
|
||||
//
|
||||
|
||||
|
||||
#include "AD524X.h"
|
||||
|
||||
AD5241 AD(0x2C); // AD0 & AD1 == GND
|
||||
AD5241 AD01(0x2C); // AD0 & AD1 == GND
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println();
|
||||
Serial.println(__FILE__);
|
||||
Serial.println(AD524X_VERSION);
|
||||
Serial.println();
|
||||
Serial.println(AD524X_LIB_VERSION);
|
||||
|
||||
Wire.begin();
|
||||
Wire.setClock(400000);
|
||||
|
||||
bool b = AD01.begin();
|
||||
Serial.println(b ? "true" : "false");
|
||||
Serial.println(AD01.isConnected());
|
||||
|
||||
Serial.println(AD.pmCount());
|
||||
Serial.println(AD01.pmCount());
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
for (int val = 0; val < 255; val++)
|
||||
{
|
||||
AD.write(0, val);
|
||||
AD01.write(0, val);
|
||||
if (val == 200)
|
||||
{
|
||||
AD.write(1, val, HIGH, LOW);
|
||||
AD01.write(1, val, HIGH, LOW);
|
||||
}
|
||||
if (val == 0)
|
||||
{
|
||||
AD.write(0, val, LOW, LOW);
|
||||
AD01.write(0, val, LOW, LOW);
|
||||
}
|
||||
Serial.println(val);
|
||||
delay(20);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -1,44 +1,54 @@
|
||||
//
|
||||
// FILE: AD524X_write_AD5242.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.0
|
||||
// PURPOSE: AD524X demo program
|
||||
// DATE: 2020-12-08
|
||||
// URL: https://github.com/RobTillaart/AD524X
|
||||
//
|
||||
|
||||
|
||||
#include "AD524X.h"
|
||||
|
||||
AD5242 AD(0x2C); // AD0 & AD1 == GND
|
||||
AD5242 AD01(0x2C); // AD0 & AD1 == GND
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.begin(115200);
|
||||
Serial.println();
|
||||
Serial.println(__FILE__);
|
||||
Serial.println(AD524X_VERSION);
|
||||
Serial.println();
|
||||
Serial.println(AD524X_LIB_VERSION);
|
||||
|
||||
Wire.begin();
|
||||
Wire.setClock(400000);
|
||||
|
||||
bool b = AD01.begin();
|
||||
Serial.println(b ? "true" : "false");
|
||||
Serial.println(AD01.isConnected());
|
||||
|
||||
Serial.println(AD.pmCount());
|
||||
Serial.println(AD01.pmCount());
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
for (int val = 0; val < 255; val++)
|
||||
{
|
||||
AD.write(1, val);
|
||||
AD01.write(1, val);
|
||||
if (val == 200)
|
||||
{
|
||||
AD.write(1, val, HIGH, LOW);
|
||||
AD01.write(1, val, HIGH, LOW);
|
||||
}
|
||||
if (val == 0)
|
||||
{
|
||||
AD.write(1, val, LOW, LOW);
|
||||
AD01.write(1, val, LOW, LOW);
|
||||
}
|
||||
Serial.println(val);
|
||||
delay(20);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -25,7 +25,7 @@ shutDown KEYWORD2
|
||||
|
||||
|
||||
# Constants (LITERAL1)
|
||||
AD524X_VERSION LITERAL1
|
||||
AD524X_LIB_VERSION LITERAL1
|
||||
|
||||
AS524X_OK LITERAL1
|
||||
AS524X_ERROR LITERAL1
|
||||
|
@ -15,7 +15,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/AD524X"
|
||||
},
|
||||
"version": "0.3.3",
|
||||
"version": "0.3.4",
|
||||
"license": "MIT",
|
||||
"frameworks": "arduino",
|
||||
"platforms": "*",
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=AD524X
|
||||
version=0.3.3
|
||||
version=0.3.4
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Arduino Library for AD524X
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
unittest_setup()
|
||||
{
|
||||
fprintf(stderr, "\nAD524X_LIB_VERSION: %s\n", (char *) AD524X_LIB_VERSION);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user