Elapsed timer function

Bonjour,
Je vous expliques en quelques lignes mon problème.
Je possède un compactRIO 9024, qui fera des mesure de résistance avec une carte NI 9219.
Je dois alimenter la bobine d'un relais (branchéé sur un contact), et démarrer un compteur à ce moment
Ensuite, le compactRIO devra mesurer la valeur de la résistance du contact du relais et stopper le compteur lorsque ce contact sera fermé (résistance nule ou proche de 0)
Ce test doit permettre de calculer le temps que le relais met entre le moment où sa bobine est alimenté ou le moment où le contact est réellement fermé.
J'ai pensé à utiliser la fonction Elapsed Timer function, mais je n'arrive pas à la faire fonctionner.
Quelqu'un aurait il un exemple ou une autre méthode?
Merci

Bonjour,
Je me suis amusé à vous faire une FGV timer qui renvoie des milliseconde (avec LV2010 et 2009 au cas ou):
Que vous pouvez mettre sur votre partie RT, en gros cet FGV à 4 etat:
Init pour reinitialiser le timer.
Start pour lancer le timer
Stop pour stoper le timer
Get pour avoir la valeur du timer.
J'espere que cela vous rendra service.
Cordialement.
Nacer M. | Certified LabVIEW Architecte
Pièces jointes :
timer.vi ‏10 KB
timer2009.vi ‏8 KB

Similar Messages

  • How to use elapsed time function with state machine in Lab VIEW

    Hello
    I've been trying to use state machine with elapsed time function in order to sequentially start and stop my code. The arrangement is to start the code for 1 minute then stop for 5 minutes. I've attached the code, the problem is when I place the elapsed time function out of the while loop it doesn't work, on the other hand when I place it inside the loop it does work but it doesn't give the true  signal to move to the next state. 
    Could you please have a look to my code and help me to solve this issue.
    Regards 
    Rajab
    Solved!
    Go to Solution.
    Attachments:
    daq assistance thermocouple(sate machine raj).vi ‏436 KB

    Rajab84 wrote:
    Thanks apok for your help
    even with pressing start it keeps running on wait case 
    could you please explain the code for me, the use of Boolean crossing, increment , and equal functions 
    Best Regards 
    Rajab 
    OK..I modded the example to stop after 2 cycles. Also recommend taking the free online LabVIEW tutorials.
    run vi. case statement goes to "initialize", shift registers are initialized to their constants. goto "wait"
    "start"= false, stay in current state. If true, transition to "1 min" case
    reset elapsed timer with True from shift register(counter starts at zero)."time has elapsed"=false, stay in current state(1 min). If true, goto "5min" case
    reset elapsed timer with True from shift register of previous case(counter starts at zero)."time has elapsed"=false, stay in current state(5 min). If true, goto "1min" case. Also, bool crossing is looking for "true-false" from "5 min" compare function to add cycle count.
    Once cycle count reaches 2, stop while loop.... 
    Attachments:
    Untitled%202[1].vi ‏42 KB

  • Restarting a elapsed time function in a for loop

    Hello,
    I am having an issue while using an elasped time function inside of a while loop (I wire the Time has elapsed? boolean to the stop function of the while loop), that is consequently inside of a for loop.  The elapsed time function works correctly on its own in a while loop, but when added to a for loop will not reset for each iteration of the for loop.  I can post an example if it is needed, but has anyone run into this problem before?  I have tried wiring all the reset boolean's but I cannot get the timer to reset untill the for loop has finished.
    Any suggestions on how to achieve this another way are welcome.
    Thanks,
    Andrew

    I found the issue, I was using 2 timers inside of the for loop on the assumption that they are completely independant of one another....they are not.  if time has elapsed on one timer then it uses that time to start off the next timer, kind of a wierd behaviour but I guess I am not really using the timer in a normal manner.
    Andrew

  • Help with quit function and elapsed time function.

    I have this annoying assignment game here and I am almost finished with it. I got two problems, the first is that the quit function partly works it quits from the game but it is giving me a "Guess is to high" message. I've tried so many things but nothing seems to work.
    The other problem is that the elapsed time " *(long f = System.currentTimeMillis()/1000;)* " starts to count before you actually write something for example if you run the program without writing something for 5 minutes, the highscore list will show your time you finished the game + these 5 minutes.
    If somebody could give me a hint or could explain to me how I could fix these problems I would be very thankful.
    import java.util.*;
    class Game  {
         public static void main(String[] arg) {
              int RAN,Entered_number=0,count=0;
              String guess1[] = new String[1];
              int guess2[] = new int[1];
              int time[] = new int[1];
              String NP1[];
              int NP2[];
              int NP3[];
              int j=0;
              Scanner scan=new Scanner(System.in);
              Scanner kb = new Scanner(System.in);
              Random myRandomizer = new Random();
              RAN= Math.abs(myRandomizer.nextInt() % 1000) + 1;
              System.out.println("\t\t\t"+"Hello and welcome to this guessing game!");
              System.out.println("\t\t\t"+"Start guessing, it's a number between 1 and 1000...");
              System.out.print("--------------------------------------------------");
              System.out.println("-----------------------------");
              System.out.println("please enter your number:");
              String control="";//control is just a name for the variable. it's used to read in the whole line if you have written something that is not a number.
              String name="";
              String answer="";
              boolean okgame=true;//is used so that you can play the game as long as the variable okgame is true.
              long f = System.currentTimeMillis()/1000;
              while((Entered_number!=RAN) && okgame)//controls if the number is different then RAN and that okgame is true.
                   System.out.print(RAN);
                   System.out.print(">");
                   if(scan.hasNextInt())//checks in advance that what you have written is a number, if so then it can read it as Entered_number.
                        Entered_number=scan.nextInt();
                   else
                        control=scan.nextLine();//Reads int the whole line to control what has been written in.
                        if(control.equalsIgnoreCase("quit"))//if control is = quit, then compare to will return 0.
                             okgame=false; //if you have written quit okgame, you put in false to quit the game.
                             // Entered_number=0;//initiates entered_number all over again to show message stupid guess i wont count that.
                   if(okgame)//as long as okgame is true it will show the result otherwise you go to else to show that the game is finished.
                        if((Entered_number>RAN)&&(Entered_number>=1)&&(Entered_number<=1000))
                             System.out.println("Guess is too high!");
                             count++;
                        else if((Entered_number<RAN)&&(Entered_number>=1)&&(Entered_number<=1000))
                             System.out.println("Guess is too low!");
                             count++;
                        else if((Entered_number>1000)||(Entered_number<1))
                             System.out.println("Stupid guess! I won't count that...");
                        else if (Entered_number==RAN)
                             long p = System.currentTimeMillis()/1000;
                             count++;
                             System.out.println("****Guess is CORRECT!");
                             System.out.print("****You guessed it in"+" "+count+" guesses and ");
                             System.out.print(p - f);
                             System.out.println(" seconds.");
                             System.out.println("please enter your name:");
                             System.out.print(">");
                             name=kb.next();
                             System.out.println("Do you want to play again ?(y/n)"); 
                             System.out.print(">");
                             answer=kb.next();
                             if(answer.equalsIgnoreCase("n"))
                                  System.out.println("**** The game is over.");
                                  okgame=false;
                             if(answer.equalsIgnoreCase("y"))
                                  Random myRandom = new Random();
                                  RAN = Math.abs(myRandom.nextInt() % 1000) + 1;
                                  System.out.println("current high score list:");
                                  long ttime = p-f;
                                  int ta = (int)ttime;
                                  j++;
                                  if (j > 1){
                                       NP1 = new String[j];
                                       NP2 = new int[j];
                                       NP3 = new int[j];
                                       for (int n = 1; n < j; n++){
                                            NP1[n-1] = guess1[n-1];
                                            NP2[n-1] = guess2[n-1];
                                            NP3[n-1] = time[n-1];
                                       NP1[j-1] = name;
                                       NP2[j-1] = count;
                                       NP3[j-1] = ta;
                                       guess1 = new String[j];
                                       guess1 = NP1;
                                       time = new int[j];
                                       guess2 = new int[j];
                                       guess2 = NP2; 
                                       time = NP3;
                                       for (int w = 1; w < guess2.length; w++) {
                                            for (int x = 1; x < guess2.length; x++) {
                                                 if (guess2[x] < guess2[x-1]) {
                                                      int z4, z5,z6,z7;
                                                      String z2, z3;
                                                      z4 = guess2[x];
                                                      z5 = guess2[x-1];
                                                      guess2[x] = z5;
                                                      guess2[x-1] = z4;
                                                      z2 = guess1[x];
                                                      z3 = guess1[x-1];
                                                      guess1[x] = z3;
                                                      guess1[x-1] = z2;
                                                      z6 = time[x];
                                                      z7 = time[x-1];
                                                      time[x] = z7;
                                                      time[x-1] = z6;
                                       for (int al = 1; al < time.length; al++) {
                                            for (int o = 1; o < time.length; o++) {
                                                 if (guess2[o] == guess2[o-1]) {
                                                      if (time[o] < time[o-1]) {
                                                           int z4, z5, z6 ,z7;
                                                           String z2, z3;
                                                           z2 = guess1[o]; z3 = guess1[o-1];
                                                           z4 = guess2[o]; z5 = guess2[o-1];
                                                           z6 = time[o]; z7 = time[o-1];
                                                           guess1[o] = z3; guess1[o-1] = z2;
                                                           guess2[o] = z5; guess2[o-1] = z4;
                                                           time[o] = z7; time[o-1] = z6;
                                  else {
                                       guess1[j-1] = name;
                                       guess2[j-1] = count;
                                       time[j-1] = ta;
                                  System.out.println("Number\t\tName\t\tHigh Score\tTime (Seconds)");
                                  System.out.println("------\t\t----\t\t----------\t--------------");
                                  for (int h = 0; h < j; h++) {
                                       System.out.println(" " + (h+1) + "\t\t" + guess1[h] + "\t\t" + guess2[h] + "\t\t" + time[h]);
                                  System.out.println("");
                                  System.out.println("Start guessing, it's a number between 1 and 1000...");
                             count=0;
    //-----------------------------------------------------------------------------------------------------------------------------------------------------PS I'm not done with the comments yet so that could be a little confusing for you guys =P
    Thanks!
    /chill

    else {
                                       guess1[j-1] = name;
                                       guess2[j-1] = count;
                                       time[j-1] = ta;
                                  System.out.println("Number\t\tName\t\tHigh Score\tTime (Seconds)");
                                  System.out.println("------\t\t----\t\t----------\t--------------");
                                  for (int h = 0; h < j; h++) {
                                       System.out.println(" " + (h+1) + "\t\t" + guess1[h] + "\t\t" + guess2[h] + "\t\t" + time[h]);
                                  System.out.println("");
                                  System.out.println("Start guessing, it's a number between 1 and 1000...");
                                                                                               f=System.currentTimeMillis()/1000;////////////include this line here
                             count=0;
                   }

  • Elapsed time to run subvi

    hi....
    first of all ..sorry if the subject title didn't match with my problem. I have no idea what is the suitable title should i put there.
    anyway my question is..how should i do to set every one hour i can run a subvi?for example i have a subvi that use to send a msg to the gsm card to delete all the read msg inside the simcard. so means that I want to delete all the messages every one hour. if i have delete the msg i will stop the subvi and wait for next hour to delete the message.
    anyone can help?..pls..hope that's all clear..
    thanks..

    Or you could use the Elapsed Time function wired to a case statement with you subVI inside that.

  • Multiple indicator from elapsed time

    Hello all,
    I need help in simplifying my block diagram. In my semII)timing.vi, i include multiple LED indicators that would light up on specific time. I've also included a time display to indicate the elapsed time. I've also included and On/Off light tht would turn red when the test time(6mins) has ended.
    But recenlty, i came across the Elapsed Time function as seen in the sem11)elapsed time.vi. I'm trying to incorporate that function, but it only allows one set timed.
    Could anyone suggest how i could include multiple controls, so multiple LEDs can light up at different times (at every mins)
    regards,
    beplusso.
    Attachments:
    semII) Timing.vi ‏45 KB
    semII) elapsed time.vi ‏38 KB

    Here's something that should at least give you the general idea. I don't know what version of LabVIEW you have, but these are in 8.2.
    I put the comparisons for your LED indicators into one vi, and the code that calculates the (m) and (cm) into another. In a simple program like this, they are not really necessary, but if your code were to grow (which it easily can) it might make things cleaner later on.
    Finally, you should always use labels for all of your controls and indicators. You can simply hide them if you don't want to see them on the front panel (right-click on the front panel item and select Visible Items - Label), and it makes wiring and debugging much easier.
    Good luck!
    Attachments:
    FieldIndicatorsBD.PNG ‏35 KB
    Field Indicators.zip ‏196 KB
    FieldIndicatorsFP.PNG ‏43 KB

  • Elapse timer

    Hi, 
    I am doing this motion sensor project. i have gotten it to work like when it senses a motion it will light up the boolean led. so now i am suppose to add a some sort of timer which some has recommended me elapsed time, i tried figuring out but i dont know how to wire it to my program. My task is to set a timer, so that when 10 mins has passed and no motion is detected it will trigger a logic 1 ( Digital Input ) to another program. But right now im focusing on this program as i need to integrate both. So how do i wire it to make it like how i had described. And lastly i need a reset button so that after it input a logic 1 ( which will trigger a alarm - another program ) it can be reset and countdown 10 mins again. Thankyou

    First, you should continue in your original thread.
    Next, take the LabVIEW tutorials. 
    LabVIEW Introduction Course - Three Hours
    LabVIEW Introduction Course - Six Hours
    Then, read the help file for the Elapsed Time function.
    Finally, set up a simple VI where you can experiment with how that function works.
     

  • How can I display the elapsed time of the course using Advanced Actions in Captivate?

    I have a Captivate course which is approximately 35 minutes in length. On each slide I would like to display to the user, the current elapsed time.
    EXAMPLE:
    25/35 minutes complete
    The 35 would remain static, so I have been working with the elapsed time system variable in CP: elapsed:$$cpInfoElapsedTimeMS$$
    I can't seem to get the variable to properly display the elapsed time in minutes, rather than miliseconds. Attached is a screen shot of my advanced action.
    Can anyone provide guidence regarding how I should structure this differntly?

    I talked about that Timer widget in that blog post and pointed to another one:
    http://blog.lilybiri.com/timer-widget-to-stress-your-learners
    If you are on CP7, you'll have this widget also as an interaction, which means it is compatible with HTML5 output. Amd there is also an hourglass interaction, with similar functionality but... did not blog about that one
    PS: Check Gallery\Widgets to find all widgets. Default path is set to Interactions

  • Write elapsed time to a spreadsheet in hours:minutes:seconds format

    Hi everyone,
    I've been trying to write an elapsed time to a spreadsheet file in an hours:minutes:seconds format, but the time is displayed in a floating point value of seconds..
    how can I write to a spreadsheet in an hours:minutes:seconds format.
    Thank you,
    James-

    I often use a subVI that converts Seconds to Hours, Minutes and Seconds. Use the Quotient and Remainder function to divide your elapsed time by 3600, 60 and 1. You can then convert those values to a modified string and use the Write to Spreadsheet File.
    As Dennis said, newer versions of LabVIEW's Write to Spreadsheet File.VI can handle arrays of Double, Integer or String automatically, and in older versions, the Write to Spreadsheet File.VI can be modified and copied to handle strings.
    Hope this helps.
    (Written in 8.5)
    Message Edited by LabViewGuruWannabe on 01-18-2008 09:28 PM
    Attachments:
    TimeToSpreadsheet.vi ‏26 KB
    SecondstoHMS.png ‏32 KB

  • How to keep Nano showing the elapsed time of song?

    Hi,
    I'm trying to figure out how to keep the page that shows the elapsed time / time remaining on instead of flipping back to the album artwork in 10 seconds. I need this function. any help would be appreciated.

    I don't think you can, sorry. But I have emailed Steve and sent feedback to Apple to fix various issues: http://www.apple.com/feedback/ipodnano.html

  • Does the Timer() function support multithread?

    Hello,
    In my application, there would be more than 1000 conversations to be monitored. I am going to design a woker thread for each conversation to determine the timeout of the communication, so I must using the timer mechanism. Due to just can create (max )16 async timers, so I want to use Timer() in the worker thread. I'd like to know if the function support multithread and if it will not be disturbed in a thread?
    David

    Hi David,
    The 'timer' used by the Timer() function is global and not thread specific. Note that Timer() returns the number of seconds elapsed since the FIRST call to the Timer() function. This is independent of the thread where the FIRST and current calls take place. So, the values returned are kind of a global 'time' since the first Timer() call in your program. I would recommend that you FIRST call Timer() in your main thread before running your other threads and then the other values returned in any thread are the 'seconds' since this call.

  • Query Execution time - Elapsed time v Actual time taken

    Hi All,
    I have this scenario where I am querying a single table with the following results. It is a very heavy query in that there are multiple aggregate functions and multiple unions on it. Even if the query is written poorly (i doubt it is) why would the actual
    time taken to execute the query be much more than the statistics provided through the following commands?
    SET STATISTICS IO ON;
    SET STATISTICS TIME ON;
    Attached are the stats provided for the relevant query in question.
    Table '123456789_TEMP_DATA'. Scan count 178, logical reads 582048, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
    Table 'Worktable'. Scan count 0, logical reads 0, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
    SQL Server Execution Times:
       CPU time = 936 ms,  elapsed time = 967 ms.
    2014-01-06 17:36:41.383
    Now, although the CPU Time/Elapsed time shows that it takes less than a second, it actually takes more than 15 seconds to fetch the results. (This is the actual time that you get on the bottom bar of the Query pane as well.)
    What is the reason? Why is it that there is such a big discrepancy between the numbers? How can I improve this situation?
    Thanks!

    Yes. I am returning a huge number of rows to the client. 
    The query is simply against a single table. 
    Select
     'First Record',AVG(COLUMN1),STDEV(COLUMN1
    ),COUNT(COLUMN1)
    FROM [TABLE1] WHERE (SOME CONDITION)
    UNION ALL
    Select  'Second Record',AVG(COLUMN2),STDEV(COLUMN2),COUNT(COLUMN2) FROM [TABLE1]
    WHERE (SOME OTHER CONDITION)
    Imagine there are 178 records fetched in this manner with 178 UNIONs. The WHERE clause will always change for each SELECT statement.
    Now, the question is not so much about the query itself, but why the execution time is actually 15 seconds whilst the SQL STATISTICS show it to be 936ms (<1 second)
    Thanks!

  • How to display elapsed time on TPC-2006 (Pocket PC 2003) as mm:ss?

    The small attached PDA vi is a simple "egg timer" that measures elapsed time in minutes and seconds.  I've tried every formatting trick I can think of, but cannot get my TPC-2006 to display the elapsed time as mm:ss.  It always displays single digit minutes and seconds using one digit instead of 2.  By this I mean that an elapsed time of 1 minute and 6 seconds will display as 1:6.  My customer expects that elapsed time to display as 01:06.
    I tried attaching a %t constant to the "format string" input of the "format into string" sub-vi, but the deployed display showed %t instead of elapsed time.
    The second question is, how do I get rid of the up/down icons in the strip display box?  They do not show in the virtual front panel, but always show up in the deployed application.
    Jeff
    Climbing the Labview learning curve!
    Sanarus Medical
    Pleasanton, CA
    Attachments:
    MinSecTimer.vi ‏12 KB

    Hi Jeff,
    I solved your first problem. The format string you were looking for to wire into the Format Into String function is %02.0f. Honestly, I can never remember what the syntax is for format strings, but I've devised a method anyone can use to make it really easy. First of all, place a numeric constant on the block diagram. Right click the constant and select Format and Precision. From that dialog, make the changes you like. You can actually see the changes propogate to the constant in real-time if you can see the block diagram constant. In your case, the change you wanted to make was Zero Padding - 2 spaces - pad with zeros on the left. After you've configured your number to look like you want, click on the Advanced Editing Mode radio button at the bottom. This is where you can manually enter in Format Strings for numeric constants or controls. The trick is, whatever changes you currently have made in the default editing mode will show up as a format string that you can copy and paste and use as you like. Hope this helps!
    Message Edited by Jarrod S. on 05-25-2006 11:02 AM
    Jarrod S.
    National Instruments
    Attachments:
    double_digit_MinSecTimer-2.vi ‏12 KB
    Default_edit.JPG ‏41 KB
    Advanced_edit.JPG ‏43 KB

  • How to calculate elapsed time(including time and date)?

    Hi all,
    I want to realize a function that can calculate the elapsed time which include time and date.Below is my thought:get the current time and date and store it to a .txt file then using the latest time and date subtract the time and date stored in the .txt file.how can realize it using the simplest way?I'm using LV7.1.

    Hi Idragon,
    you can do it like this.
    Mike
    Attachments:
    DateTime.PNG ‏12 KB

  • Starting and stopping Elapsed Time

    I have some code in LabVIEW 8.2.1 I am writing for Qual test with a customer. The basics of the test are the following: monitor and record pressure (thru transducers), temperatures (fluid and ambient), and monitor the opening and closing a valve. The valve has two light switches orientated in such a way, that mechanical counters will count a cycle when it is fully closed to open to closed.
    The problem I am having, is that I need the elapsed time vi to start counting, once it has moved off of the full open switch. It needs to count to 240 seconds, at which time it will pass on to an on bit, which will energize the valve again. I can get it to start running at the right part, but it will stop once
    it gets in between the two light switches. It almost seems like the elapsed time vi doesn't have enough flexibility for what I need. That or I need to write a bunch of code that would enable it to do what I want.
    I am not sure on how I can post code so it can be viewed in LabVIEW, so here is a word doc.
    Attachments:
    elapsed timing vi.doc ‏45 KB

    Hello Chadius, 
    Thanks for posting,
    I took a look at your code this morning. We at NI recommend using varibales as one of the last resources when trying to pass data out in cases where this is rseally necesary, when looking at your code I realized that the variables to pass data are not needed and that actually there are some misconceptions about the functionality of the vi funtions, do not be ashamed that is totally understandable when you are new to a concept and more understandable if you are new to labVIEW.
    Before proceeding with the code I would like to encourage you to check the Getting started with LV It gives you the basis to start programming in labVIEW and helps us understand better how LV executes.
    There is also a lot of good help loaded in Labview that can help us determine what to use and what is expected of each function, you can access this by pressing ""CTRL+H" and accesing the detailed help when hovering over a specific VI and clicking detailed help.
    Then if you are a new user to labview and would likely use labview for long term development I will suggest the training.
    Now, getting to your code I can see that you are doing a bit more code than what you actually need, so for instance:
    -we can eliminate the constants and the selector and just pass the boolean.
    -we can also use less while loops so the part where you write to the variables can be done in the same while loop on the right.
    -Instead writing to the variable and reading from that same variable you can just wire a cable so you have the same data
    -You can use the error wire out/in of the functions to control code execution.
    Last but not least, I am asumming here that this application you are coding is most likely to be a state machine where you are making a choice depending of the inputs you have, If "A" then "B"
    This is an example of a simple state machine based on user input, you can change that input to be an event, a trigger etc.
    Hope this helps, 
    Luis
    Application Engineer
    National Instruments. 
    Attachments:
    LV_Getting_Started.pdf ‏918 KB
    This way looks better.JPG ‏20 KB
    Delete constants pass only bbolean.JPG ‏15 KB

Maybe you are looking for

  • En-Countering Error While trying to Open the Database

    Hi Everybody, Database Version:Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64bit Production Os: Solaris9 This is one of our Test Database which is running in No-Archivelog Mode and having no backup of Physical Datafiles. Due to some Server issues

  • IMac G4 (Flat Panel) Hard Drive Replacement Cost

    I have an 800 mHz iMac G4 (Flat Panel) that was originally purchased in approximately 2002 or 2003. The hard drive has died. I have three questions: What is an approximate cost for a new hard drive? Where can a hard drive for this computer be purchas

  • Monitor viewing problem

    When I print to video the sequence records fine onto tape but when I just want to use my video camera as a monitor the picture stays on freeze frame. It's like the camera is on pause or something. Why can't I view it as a moving picture? Sputnik

  • Recommended ExpressCards for new 17" MBP for video editing

    Ok, so after sitting on the fence for months I had to buy the new 17" MBP. I just couldn't wait any longer and my trusty PB G4 is getting slow. After reading the enormous amounts of posts I can see why people are so upset about losing the ExpressCard

  • Greyscale tiff won't colorize placed in Illustrator

    I was working with a scan today, Greyscale and I was able to place it  into an Illustrator file then colorize it without issue. When I went  into the Photoshop file and duplicated the original locked scanned layer  and saved out the tiff would not co