[Digi-Key Follow me Issue 3] + Supplement: ESP32C3 controls digital potentiometer and op amp to achieve programmable gain
[Copy link]
The AD5270 is an excellent 1024-position, 5 ppm/°C temperature coefficient in rheostat mode, 1% resistor tolerance error, SPI interface, and 50-TP memory digital rheostat.
It combines industry-leading variable resistor performance with non-volatile memory (NVM) and provides 50-time programmable (50-TP) memory. Unlimited adjustments can be made before the resistance value is programmed into the 50-TP memory. These devices do not require any external voltage source to help blow the fuse and provide 50 permanent programming opportunities. During the 50-TP activation, a permanent blow fuse command will fix the wiper position. The SPI interface control timing is as follows:
ESP32C3 is programmed with Arduino and is easy to drive. The test code is as follows:
// AD5270 commands - new digital potentiometer
#define CMD_WR_RDAC 0x01
#define CMD_RD_RDAC 0x02
#define CMD_ST_RDAC 0x03
#define CMD_RST 0x04
#define CMD_RD_MEM 0x05
#define CMD_RD_ADDR 0x06
#define CMD_WR_CTRL 0x07
#define CMD_RD_CTRL 0x08
#define CMD_SHTDN 0x09
void vspi_write_word(const int chip_select, uint16_t data_to_send, const uint8_t bit_order, const uint8_t mode) {
vspi->beginTransaction(SPISettings(SPI_FREQ_FAST, bit_order, mode));
digitalWrite(chip_select, LOW); //pull SS slow to prep other end for transfer
vspi->transfer16(data_to_send);
digitalWrite(chip_select, HIGH); //pull ss high to signify end of data transfer
vspi->endTransaction();
}
/* Write a 4-bit command and a 10-bit data word */
void AD5270_Write(const int chip_select, uint8_t cmd, uint16_t data){
uint16_t data_word = ((cmd & 0x0F) << 10) | (data & 0x03FF);
vspi_write_word(chip_select, data_word, MSBFIRST, SPI_MODE1);
}
/* Enable/disable rheostat value changes */
void AD5270_LockUnlock(const int chip_select, uint8_t lock){
AD5270_Write(chip_select, CMD_WR_CTRL, lock ? 0 : 0x002);
}
/* Enable/disable hardware shutdown */
void AD5270_Shutdown(const int chip_select, uint8_t shutdown){
AD5270_Write(chip_select, CMD_SHTDN, shutdown ? 1 : 0);
}
/* Set the value of the digital rheostat - range is 0-0x3FF (0-100kOhm) */
void AD5270_Set(const int chip_select, uint16_t val)
{
AD5270_Write(chip_select, CMD_WR_RDAC, val);
}
#define CHIP_SEL_MEAS 10 // Chip select pin for measuring digital rheostat potentiometer
void setup() {
// put your setup code here, to run once:
// Set voltage measurement gain to 1 (maximum current (5V pk-pk) must be within ADC range)
AD5270_Shutdown(CHIP_SEL_MEAS, 1);
AD5270_Set(CHIP_SEL_MEAS, 100);
}
void loop() {
// put your main code here, to run repeatedly:
}
Wiring diagram and test board:
Effect:
|