ni.com checkout is currently experiencing issues.

Support teams are actively working on the resolution.

LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

millis()

How can i use the millis() function in labview?

0 Kudos
Message 1 of 4
(3,704 Views)

That depends on what you are trying to do with it.  Could you explain in detail what you are needing?

0 Kudos
Message 2 of 4
(2,988 Views)

I am trying to make this code to labview:

void loop()

{

  delay(100);

  int rpm=getRPM();

  }

int getRPM()

{

  // sample for sampleTime in millisecs

  int kount=0;

  boolean kflag=LOW;

  unsigned long currentTime=0;

  unsigned long startTime=millis();

  while (currentTime<=sampleTime)

  {

    if (digitalRead(hallPin)==HIGH)

    {

      kflag=HIGH;

    }

    if (digitalRead(hallPin)==LOW && kflag==HIGH)

    {

      kount++;

      kflag=LOW;

    }

    currentTime=millis()-startTime;

  }

  int kount2rpm = int(60000./float(sampleTime))*kount;

  return kount2rpm;

}

0 Kudos
Message 3 of 4
(2,988 Views)

Something like this cannot be easily implemented with an unmodified version of LIFA.

To calculate the speed of a device (with your sensor) you would want to use a counter implemented with the Arduino interrupts.  I would recommend using this method even without LabVIEW.

So, the first step would require that you convert your algorithm to be a counter using the interrupts and then either calculating the speed on the arduino first and then send the speed value to LabVIEW with a custom LIFA function or sending the raw count data to LabVIEW with a custom LIFA function and then calculating the speed there.  The former of the two is probably the more accurate method.

0 Kudos
Message 4 of 4
(2,988 Views)