Discusiones sobre Productos NI

cancelar
Mostrando los resultados de 
Buscar en lugar de 
Quiere decir: 

anemómetro

hola ,saludos ,lo probé pero no puedo ver los datos en Labview,

 

Cargo este programa de Arduino :

#define uint  unsigned int

#define ulong unsigned long

 

#define PIN_ANEMOMETER  2     // Digital 2

#define PIN_VANE        5     // Analog 5

 

// How often we want to calculate wind speed or direction

#define MSECS_CALC_WIND_SPEED 5000

#define MSECS_CALC_WIND_DIR   5000

 

volatile int numRevsAnemometer = 0; // Incremented in the interrupt

ulong nextCalcSpeed;                // When we next calc the wind speed

ulong nextCalcDir;                  // When we next calc the direction

ulong time;                         // Millis() at each start of loop().

 

// ADC readings:

#define NUMDIRS 8

ulong   adc[NUMDIRS] = {26, 45, 77, 118, 161, 196, 220, 256};

 

// These directions match 1-for-1 with the values in adc, but

// will have to be adjusted as noted above. Modify 'dirOffset'

// to which direction is 'away' (it's West here).

char *strVals[NUMDIRS] = {"W","NW","N","SW","NE","S","SE","E"};

byte dirOffset=0;

 

//=======================================================

// Initialize

//=======================================================

void setup() {

   Serial.begin(9600);

   pinMode(PIN_ANEMOMETER, INPUT);

   digitalWrite(PIN_ANEMOMETER, HIGH);

   attachInterrupt(0, countAnemometer, FALLING);

   nextCalcSpeed = millis() + MSECS_CALC_WIND_SPEED;

   nextCalcDir   = millis() + MSECS_CALC_WIND_DIR;

}

 

//=======================================================

// Main loop.

//=======================================================

void loop() {

   time = millis();

 

   if (time >= nextCalcSpeed) {

      calcWindSpeed();

      nextCalcSpeed = time + MSECS_CALC_WIND_SPEED;

   }

   if (time >= nextCalcDir) {

      calcWindDir();

      nextCalcDir = time + MSECS_CALC_WIND_DIR;

   }

}

 

//=======================================================

// Interrupt handler for anemometer. Called each time the reed

// switch triggers (one revolution).

//=======================================================

void countAnemometer() {

   numRevsAnemometer++;

}

 

//=======================================================

// Find vane direction.

//=======================================================

void calcWindDir() {

   int val;

   byte x, reading;

 

   val = analogRead(PIN_VANE);

   val >>=2;                        // Shift to 255 range

   reading = val;

 

   // Look the reading up in directions table. Find the first value

   // that's >= to what we got.

   for (x=0; x<NUMDIRS; x++) {

      if (adc[x] >= reading)

         break;

   }

   //Serial.println(reading, DEC);

   x = (x + dirOffset) % 8;   // Adjust for orientation

   Serial.print("  Dir: ");

   Serial.println(strVals[x]);

}

 

 

//=======================================================

// Calculate the wind speed, and display it (or log it, whatever).

// 1 rev/sec = 1.492 mph

//=======================================================

void calcWindSpeed() {

   int x, iSpeed;

   // This will produce mph * 10

   // (didn't calc right when done as one statement)

   long speed = 14920;

   speed *= numRevsAnemometer;

   speed /= MSECS_CALC_WIND_SPEED;

   iSpeed = speed;         // Need this for formatting below

 

   Serial.print("Wind speed: ");

   x = iSpeed / 10;

   Serial.print(x);

   Serial.print('.');

   x = iSpeed % 10;

   Serial.print(x);

 

   numRevsAnemometer = 0;        // Reset counter

}

 

 

2.- DESPUES CARGO EL LIV DE LABVIEW.

3.- selecciono el puerto

no se si el procedimiento es el adecuado,

 

 

Y nuevamente gracias por tu ayuda.

0 kudos
Mensaje 11 de 16
2.689 Vistas

Hola celsotf,

 

         La velocidad la tienes en 9600 (cuando pones Serial.begin(9600); ) y en el VI esta en 115200 (baud rate), tienes que seleccionar el puerto antes de darle para que se ejecute, te adjunto nuevamente el mismo VI con el cambio en la velocidad y unos indicadores adicionales para que muestre si esta ocurriendo algún error y que efectivamente se estan recibiendo los datos.


Saludos,

Luis A. Mata C.
Ing. Electrónico
Whatsapp: +58-414-1985579
BBM Pin: 2B83E99A
Thanks: Kudos
0 kudos
Mensaje 12 de 16
2.685 Vistas

Buenas noches , un saludos ya  probé de nuevo pero sin ningún resultado aquí te dejo una imagen de la pantalla espero que te pueda servir

 

 

 

Configure el puerto , y antes de darle a RUN pongo el puerto, no se si hay que cargar el toolki LIFA _Base

 

Un saludo y gracias por tu tiempo ,estoy muy agradecido saludos.

 

imagen.GIF

0 kudos
Mensaje 13 de 16
2.683 Vistas

Sigo sinpoder resolver el problema si alguien me puede ayudar estaria muy agradecido.

0 kudos
Mensaje 14 de 16
2.313 Vistas

Excelente aporte Inge!!!!   Gracias!!!!

0 kudos
Mensaje 15 de 16
1.264 Vistas

Hola amigo buen dia, si pudiste conectar el anenometro con el arduino?

0 kudos
Mensaje 16 de 16
1.082 Vistas