Hola! Quiero usar la familia de potenciómetros digitales X9C104 y X9C503 https://www.intersil.com/content/dam/Intersil/documents/x9c1/x9c102-103-104-503.pdf y estoy teniendo problemas con el control en lenguaje C.
He leído el datasheet, teniendo el cuenta todos los aspectos pero sólo soy capaz de hacer "subir" el wiper, no puedo bajarlo y no se qué hacer. Os muestro el código por si se me está escapando algo (los delay los he puesto tan altos por hacer pruebas, lo tengo a 5 ms normalmente)
Gracias de antemano, si conocéis un código que funcione os lo agradecería, porque no entiendo el problema
He leído el datasheet, teniendo el cuenta todos los aspectos pero sólo soy capaz de hacer "subir" el wiper, no puedo bajarlo y no se qué hacer. Os muestro el código por si se me está escapando algo (los delay los he puesto tan altos por hacer pruebas, lo tengo a 5 ms normalmente)
Código:
#define Dpot_increment PIN_A4 // POT1
#define Dpot_direction PIN_A2 // POT2
#define Dpot_select PIN_A0 // POT3
int target_value; // sus valores son definidos en el .c principal
int current_value; // sus valores son definidos en el .c principal
int Dpot(){
output_high(Dpot_increment);
if (target_value > current_value) {
delay_ms(50);
output_low(Dpot_select) ; // changes available
delay_ms(50);
output_high(Dpot_direction) ; //subir
for (int i = target_value - current_value; i>0; i--){
delay_ms(50);
output_high(Dpot_increment);
delay_ms(50);
output_low(Dpot_increment);
output_high(pin_b3); // enciende led verde
}
}
if (target_value < current_value) {
delay_ms(50);
output_low(Dpot_select); // changes available
delay_ms(50);
output_low(Dpot_direction); //BAJAR
for (int j = (current_value - target_value); j>0; j--){
delay_ms(50);
output_high(Dpot_increment);
delay_ms(50);
output_low(Dpot_increment);
output_high(pin_b0); //enciende led rojo
}
}
delay_ms(100);
output_high(Dpot_increment);
delay_ms(100);
output_high(Dpot_select); //configuración para guardar en memoria no volátil
delay_ms(100);
output_low(pin_b3);
output_low(pin_b0);
return 0;
}
Gracias de antemano, si conocéis un código que funcione os lo agradecería, porque no entiendo el problema