La parte electronica terminada a falta de instalar:
[ You are not allowed to view attachments ]
[ You are not allowed to view attachments ]
Este es el código que estoy utilizando:
// Include the library:
#include <TM1637Display.h>
#include <TimerOne.h>
// Define the connections pins:
#define CLK 4
#define DIO 5
const int hallPin=2;//pin para interrupcion desde sensor
volatile int contador=0;//contador de pulsos
volatile int rpm=0;
volatile bool flag=false;
int valueToShow=0;//valor mostrado en el display
int UltimaMedicionFiltrada=0;//valor de la ultima medicion filtrada
double Medicion=0;//medicion actual del sensor
double w=0.6; //constante de filtrado 0 muy filtrado 1 sin filtrar
// Create display object of type TM1637Display:
TM1637Display display = TM1637Display(CLK, DIO);
// Create array that turns all segments on:
const uint8_t data[] = {0xff, 0xff, 0xff, 0xff};
// Create array that turns all segments off:
const uint8_t blank[] = {0x00, 0x00, 0x00, 0x00};
// You can set the individual segments per digit to spell words or create other symbols:
const uint8_t done[] = {
SEG_B | SEG_C | SEG_D | SEG_E | SEG_G, // d
SEG_A | SEG_B | SEG_C | SEG_D | SEG_E | SEG_F, // O
SEG_C | SEG_E | SEG_G, // n
SEG_A | SEG_D | SEG_E | SEG_F | SEG_G // E
};
// Create degree Celsius symbol:
const uint8_t celsius[] = {
SEG_A | SEG_B | SEG_F | SEG_G, // Circle
SEG_A | SEG_D | SEG_E | SEG_F // C
};
void setup() {
// Clear the display:
//Serial.begin(9600);
display.clear();
delay(1000);
Timer1.initialize(600000); // Dispara cada 600 ms
pinMode(hallPin,INPUT_PULLUP);//entrada señal
Timer1.attachInterrupt(ISR_ShowSpeed); // Activa la interrupcion cada 0.6s
attachInterrupt(digitalPinToInterrupt(hallPin),cuenta,RISING);
display.setBrightness(7);
}
void loop() {
if(flag)//hace el calculo de velocidad y lo muestra
{
Medicion=((rpm*15)/0.6);
valueToShow=Medicion*w+(1-w)*UltimaMedicionFiltrada;//filtro exponencial
UltimaMedicionFiltrada=valueToShow;//almaceno la ultima medicion filtrada
//Serial.println(Medicion);
//Serial.println(UltimaMedicionFiltrada);
//Serial.println(valueToShow);
display.showNumberDec(valueToShow);
flag=false;
}
}
void cuenta()//incrementa el contador
{
contador++;
}
void ISR_ShowSpeed()
{
rpm=contador;
contador=0;
flag=true;
}
Esquema y pcb definitivos:
[ You are not allowed to view attachments ]
[ You are not allowed to view attachments ]
Cuando lo monte ya pondre más fotos y comentare si realmente funciona...