Build a simple counter

Hi, I'm just getting started in LABView and I am a very slow learner. I have build a counter to count my gamepad operations as it is cycling on a tester of life. I put him in place to count the individual directional activations, but I join to have it count total cycles. I'm writing up to the VI I did so far. How can I do that after that he been rolled once in each direction (up, left, down, right), there is a cycle? Thank in advance for any help.

-Pascale

I think the only problem is that it's a loop so fast (10mS) at the point where the counter increments he already counted the next event.  You can add additional logic to prevent the inside while loop to stop until the direction of the joystick Returns Boolean 0.  The idea is that stop only once all 4 have been activated AND 4 are no longer in an active state.  I used the function NOT to make it more obvious that the logic was, you have also the output of arithmetic consisting be reversed but this watch only upward like a small point on the line of the value.

Like the other post, I don't have a way to test this, but I think my logic was scientifically.

Edit1: The post above beat me to it, and his suggestion would work just as well as mine, we just thought it differently.

Edit2: I noticed in one of your posts above you mentioned that you want to count only when it has been activated in a certain order.  This VI does not work like that, it would take a more complicated logic to do.  I see two ways that could be made, but don't have the time to get out to see which would be best.  Good luck and have fun.

Tags: NI Software

Similar Questions

  • Simple counter

    Hi team or,.

    I am trying to program a simple counter, see Appendix vi. Every time the temperature higher than 55 c she should count + 1 if it goes below of-18 + 1 cold cycle. Not sure why the structure of the event, never reached into the tank.
    Can someone help me pls.

    Thank you
    Martin

    DEGBM24 wrote: don't know why the structure of the event, never reached into the tank.

    This is because the value change event is not raised by you write to the Terminal.

    1. you don't need a case of timeout.

    2. you should have a value of Stop change event to stop your loop

    3. you should have a change in the value of your temperature control event

    4. you really should be using shift registers to keep your account of cycle instead of local variables

    5 look at the Boolean value through PtByPt VI.

  • I'm looking to build a simple site to accommodate a large number of photos.

    Hello

    I'm looking to build a simple site to accommodate a large number of photos. The site is not for a standard wallet - it's just that my team can look through a set of images as thumbnails low resolution and be able to download the versions high-resolution individually on the site. A simplified version of this: | Agami

    If we could, we would like to also password protect these downloads or the site itself.

    Does anyone have advice/tips/ideas/widgets which could help with this? I am aware of sites such as Photobucket etc however I have a decent level of experience with Muse and site, I thought it's maybe cheaper out in this way that the necessary storage volume is pretty huge.

    Thanks in advance!

    This discussion covers the aspects of protection:

    Re: Pass protection of word using webhostinghub.com.

    The typical layout of the Gallery (with thumbnail adjustment carefully, their own and irregular proportions) is a matter of selecting a different third party widget that does the trick. There are a zillion Gallery of widgets out there, but I do not know the typical term for this irregular pattern "brick layers. Someone at - he found an already?

  • Simple counter/dashboard (AS3)

    I need this for a simple iPhone app...
    I tried to create a dashboard for my iPhone with Flash CS5 in the Air for the iOS mode. I have add the timer and the timer of 24 seconds, but now I need help so much.
    Problems:
    1. when the timer reaches 0 mins, it only displays: 59, not 00:59
    2. I tried to add a button to the meter of the points, but it seems very complicated in AS3 (not in AS2 :/). I created a TLF read only text named "HomeScore. But it is a nonnumeric string, so I can't add a simple counter.
    4. I need help with the reset (timer and 24 seconds) and Start/Stop buttons (for the timer and 24).
    My code:

    import flash.events.MouseEvent; (true) Seconds.text = "06:00" var timer:Timer = new Timer(1000,360); timer.addEventListener(TimerEvent.TIMER, countdown); timer.start(); function countdown(event:TimerEvent) {     var totalSecondsLeft:Number = 360 - timer.currentCount;     Seconds.text = timeFormat(totalSecondsLeft); } function timeFormat(seconds:int):String {     var minutes:int;     var sMinutes:String;     var sSeconds:String;     if (seconds > 59)     {         minutes = Math.floor(seconds / 60);         sMinutes = String(minutes);         sSeconds = String(seconds % 60);     }     else     {         sMinutes = "";         sSeconds = String(seconds);     }     if (sSeconds.length == 1)     {         sSeconds = "0" + sSeconds;     }     if (sMinutes.length == 1)     {         sMinutes = "0" + sMinutes;     }     return sMinutes + ":" + sSeconds;     if (seconds/60 <= 0  && sSeconds != 0) { return "00" + ":" + sSeconds;}     if (sMinutes = 0 && sSeconds = 0) { return "00:00"} } Possesso.text = "24" var timer2:Timer = new Timer(1000,24); timer2.addEventListener(TimerEvent.TIMER, countdownpossesso); timer2.start(); function countdownpossesso(event:TimerEvent) {     var totalSecondsLeft:Number = 24 - timer2.currentCount;     Possesso.text = timeFormatpossesso(totalSecondsLeft); } function timeFormatpossesso(seconds:int):String {         var sPossesso:String;     if (seconds > 59)     {                 sPossesso = String(seconds % 60);     }     else     {                 sPossesso = String(seconds);     }         if (sPossesso.length == 1)     {         sPossesso = "0" + sPossesso;     }         return sPossesso; } import flash.events.*; HomeScore.text = "02" HomeScore.text = ScoreFormatHome(ScoreHome); var ScoreHome:Number     function ScoreFormatHome(ScoreHome:Number) {     var ScoreHome=1     if (ScoreHome <=9 ) {return "0" + ScoreHome}     if (ScoreHome >=10) {return ScoreHome}     } ButtonplusHome.addEventListener(MouseEvent.MOUSE_OVER, fl_MouseOverHandler); function fl_MouseOverHandler(HomeAdd:MouseEvent):void {     ScoreHome++; }

    you have too many questions for a single thread, unless you're already pretty savvy:

    1. when the timer reaches 0 mins, it only displays: 59, not 00:59

    use a string formatter function.
    2. I tried to add a button to the meter of the points, but it seems very complicated in AS3 (not in AS2 :/). I created a TLF read only text named "HomeScore. But it is a nonnumeric string, so I can't add a simple counter.

    You can convert strings to numbers using Number().
    4. I need help with the reset (timer & 24 seconds) and Start/Stop buttons (for timer and 24).

    the timer class has you use reset(), start() and stop() methods.  Follow with the start() method reset() method if you want to reset and start.

  • How to make a loop simple counter in labview 7.1?

    I'm trying to teach me how to use labview 7.1, but having trouble finding how to use functions properly. I am trying to create a simple loop to count from 1 to 10 with a delay of 1 second between each number. I would be grateful the help!

    Classes resumed?

    The key words are 'loop' (try a loop FOR the palettte of structures), 'delay' (try a wait (ms) of the range of timing). Use a constant instead of diagram for the "1 second" (or 1000 ms). and use a digital display to show the current number (for example by using an indicator connected to a terminal of the loop iteration FOR). Given that [i] starts from 0, first use a primitive of + 1. Wire a constant at the end of the loop to determine the number of iterations. You should be able to determine the correct value, math or by trial and error.

    Now try to gather all, shouldn't be too difficult. Where have you problems? Have you looked at the examples? Did you do tutorials?

    Once you have a project, post it here and we can propose possible improvements.

  • Simple counter in seconds

    Hello

    In my code, I have a while loop which may or may not take more than x seconds to run. Once the while loop has worked for x seconds I would to provide a series of commands. Therefore, I need a kind of counter. Number of cycles will help me with that? If so, how? If this is not the case, how can I create a counter for this simple task? Thank you.

    Alfredo

    Yes, the number of cycles can be used for this, and other mechanisms. For example, you can use the time to get the seconds. Here are some simple examples:

  • Simple counting the stopwatch will not stop.

    Hello

    I made a simple countdown timer, it works fine but I wish I had the sign next to the number % so it would look like a pre-order. But as I add the '%' sign to the function, the counting stops (100% more) ever and continues to count.

    What Miss me?

    var count: Number = 1;
    var myTimer:Timer = new Timer (10);

    myTimer.addEventListener (TimerEvent.TIMER, count);
    myTimer.start ();

    function countdown(event:TimerEvent):void {}

    myText_txt.text = String ((count) + myTimer.currentCount);

    myText_txt.text = String ((count) + myTimer.currentCount)+'%';


    If (uint (myText_txt.text) > = 100) {}
    myTimer.removeEventListener (TimerEvent.TIMER, count);
    }


    }

    Thank you!

    You should learn to use the trace() function to see why things don't work as expected.   The '%' is converting it to a uint not what you expect.  Trace uint (myText_txt.text) and you'll see why comparing the value of a string uint digital a number isn't going to work.  Try instead the following...

    var count: Number = 1;
    var myTimer:Timer = new Timer (10);

    myTimer.addEventListener (TimerEvent.TIMER, count);

    myTimer.start ();

    function countdown(event:TimerEvent):void {}

    myText_txt.text = String ((count) + myTimer.currentCount) + '% ';

    If (uint (String (+ myTimer.currentCount (County))) > = 100) {}
    myTimer.removeEventListener (TimerEvent.TIMER, count);
    }

    }

  • Using the mouse click simple counter

    Purpose to make a mouse click counter. (a simple button clicker/tally, which keeps the number of clicks a user sets).

    1. Progress-
      1. Done button
      2. variable passed to the completed text field.
      3. correct variable pass script to the incomplete text field.
    2. Problem-

    1 counter variable remains at 1 and does not increase by 1 when the button is clicked.

      Link to .fla

      script

      var myVar = 0;

      button_1.addEventListener (MouseEvent.CLICK, fl_ClickToPosition);

      var fl_TF:TextField;

      var fl_TextToDisplay:String = myVar;

      function fl_ClickToPosition(event:MouseEvent):void

      {

      fl_TF = new TextField();

      fl_TF.autoSize = TextFieldAutoSize.LEFT;

      fl_TF.background = true;

      fl_TF.border = true;

      fl_TF.x = 100;

      fl_TF.y = 100;

      fl_TF.text = fl_TextToDisplay;

      addChild (fl_TF);

      myVar ++;

      }

      any help is greatly appreciated.

      Thank you

      Try:

      var myVar = 0;

      button_1.addEventListener (MouseEvent.CLICK, fl_ClickToPosition);

      var fl_TF:TextField;
      fl_TF = new TextField();
      fl_TF. AutoSize = TextFieldAutoSize.LEFT;
      fl_TF. Background = true;
      fl_TF. Border = true;
      fl_TF.x = 100;
      fl_TF.y = 100;
      fl_TF. Text = String (myVar);
      addChild (fl_TF);

      function fl_ClickToPosition(event:MouseEvent):void
      {
      myVar ++;
      fl_TF. Text = String (myVar);
      }

    1. simple counter between 1-11

      Hey guys,.

      I just need a quick review on meter simple app. The main idea is that when the user clicks the button (+) the meter is incremented + 1 and when the user clicks the button (-) it decrements. In any case the value should be between 1-11 and should be in sequence, which means 1-2-3-4...-11 or conversely oder 11-10-9...-2-1... so I came up with this solution that I join you, but I want to know if there is a much simpler way to do this.

      Best regards


    2. How to build a simple calculator?

      I would build a calculator with the slide to control the operation (+ -* /).

      Maybe someone can help me?

      Thank you very much.

      I did also. If I'm not mistaken it is an activity from exercise of the book "LabVIEW for everyone..." ». I also did as mentioned for the slider part Altenbach. Fix is the vi. Try to make an assignment and activities by yourself it will help you a lot. Do not hesitate to ask, but I think that, first of all, you have to try something. That's what I've learned here in the forum of these people very very interesting, useful, and experts.

    3. Question on simple counting in oracle code

      have two tables table1 and table2

      Table 1A 5000 documents, table2 has 10000
      There is a column called num_id (number)
      in white table1
      There is a column in table2 num_id (number) with a number of seq data in table2 and the last num_id = 10000

      just take the max (num_id) table2 and begin the process of table1 with 10001, 10002, 10003, etc..

      Thank you
      Doug

      Hi Doug,.
      Suppose you want to use the sequence.nextval to update the table 1 then all you need is...

      declare

      vn_max_seq table2.num_id%type;
      vn_counter table2.num_id%type;

      Start

      Select max (num_id) in the vn_counter from table2;

    4. Counting of string separated by commas in the cells of a column

      Hi all

      Try to pass some of my Excel spreadsheets in numbers. I'd appreciate help with a specific string of text/number in the cells in a column. In the example below (no sheet of complete works) is a column, the packs work (WP01, WP02 and so forth)-which means work packs a particular Test & Validation document (e.g. TV-102) applies to.

      I would like to be able to simple counting the number of occurrences, say "WP05", is applicable. If I use COUNTIF, on the "WorkPack" column, he has only the cells that contain only the string "WP05" (i.e. in the sheet, I work with, I know there are 22 entries for "WP05" in the column of pack work, but only the 14 account)

      Note: I am building this on my MAC, but would like to be able to access and use these sheets on my iPad - don't know if that makes a difference.

      Any suggestions / ideas?

      Thank you in advance...

      ATB Perry

      ID

      Paper group

      WorkPack

      TV-91

      Validation of NFR

      WP05 WP06

      TV-102

      Certificate of conformity

      WP05 WP06

      TV-103

      Validation of NFR

      WP05 WP06

      TV-206

      Test EN

      WP05

      TV-207

      Test EN

      WP05

      TV-208

      Test EN

      WP05

      TV-209

      Test EN

      WP05

      TV-212

      Certificate of conformity

      WP01, WP02 WP03, WP04, WP05, WP06, WP07, WP08 MICROSOFT WINDOWS CURRENTVERSION, WP09, WP10, WP11, WP12, WP13, WP14, WP.15

      TV-213

      Validation of NFR

      WP01, WP02 WP03, WP04, WP05, WP06, WP07, WP08 MICROSOFT WINDOWS CURRENTVERSION, WP09, WP10, WP11, WP12, WP13, WP14, WP.15

      TV-214

      Test EN

      WP01, WP02 WP03, WP04, WP05, WP06, WP07, WP08 MICROSOFT WINDOWS CURRENTVERSION, WP09, WP10, WP11, WP12, WP13, WP14, WP.15

      TV-215

      Validation of NFR

      WP01, WP02 WP03, WP04, WP05, WP06, WP07, WP08 MICROSOFT WINDOWS CURRENTVERSION, WP09, WP10

      TV-308

      Validation of NFR

      WP01, WP02 WP03, WP04, WP05, WP06, WP07, WP08 MICROSOFT WINDOWS CURRENTVERSION, WP09, WP10, WP11, WP12, WP13, WP14, WP.15

      TV-338

      Test EN

      WP05

      Here's how I would approach (without more):

      Add additional columns to your table (those titled "WP01',"WP02", etc.).  Enter the names as shown

      The first line is a heading row.

      Also... Add an extra line at the end and make a footer row

      D2 = (LEN ($C2) −LEN (REPLACE ($C2, D$ 1, ""))) ÷LEN ($1 D)

      It's shorthand dethrone select cell D2 and type e (or copy and paste it here) the formula:

      = (LEN ($C2) −LEN (REPLACE ($C2, D$ 1, ""))) ÷LEN ($1 D)

      Select cell D2, copy

      Select cells D2 the bottom of column R, paste

      in the footer row (row 15 of this example) iff the following formula:

      D15 = Sum (D)

      Select the cell D15, copy

      Select the cells D15 thru R15, dough

      I could never find 22 WP05 instances (even when I search your message on this web page):

    5. Rare use FPGA build without sample FPGA build

      Hello

      I hope I can formulate my question in the right way. I want to test a routine of FPGA and do not always want to compilate hole streaming project (e.g., construction with bus register etc.). Is it possible to only build a simple FPGA bitfile (simple while loop, some fifos, my code) and test on the device of the USRP RIO or what I need to use the basic FPGA in Streaming Xcvr as base build? This would be really shorten the compilation time to test the new code.

      I hope that my question is understandable.

      Concerning

      Etuel

      Yes, you can start from a blank VI FPGA and develop FPGA code similar to other LabVIEW FPGA targets. There are a few things to point out:

      • You will not be able to use the host of the project example screws if you do this. If you don't have the FPGA of the sample project code, the host screws will not good FPGA logic to connect with.

      • I recommend not to put any code in the domain of Data Clock. Data clock requires the USRP RIO IDLs configure this field of clock. To do this properly, you need the '' necessary '' of the FPGA block diagram section. It is easier just to avoid all this. To use the clocks faster than the clock of 40 MHz, derive a new clock, the clock of 40 MHz.

      Good luck!

    6. DAQ 6008 &amp; 6211 counting

      Hi all.

      I work with an application that is count the pulses of an encoder hollow shaft renco to measure the distance traveled on a platform single axis powered by a ball screw and controlled by an engine step by step. The encoder is mounted at the opposite end of the motor directly to the ball screws.

      That said encoder has 100 impulses per revolution and at the moment im using only 1 channel on its release to make the count. I use the channel of single window on a DAQ 6008 real counting down.

      Here's my problem.

      When I run the engine at a moderate speed and measure count pulses from a full trip on the axis I get 8200 impulses. If I reverse the engine now and bring it back at the same speed, the full trip will give the same 8200 impulses which is exactly what I want. However, if I run the motor at extremely slow speeds the same 8200 impulses correspond to only 3 quarters of the race on the same axis.

      My hypothesis is that at top speed the DAQ 6008 lacks a large number of charges. I am correct in this assumption?  I will soon have access to a DAQ 6211. This will provide a more reliable metering device?.

      Thanks in advance guys. I'd appreciate comments.

      It is just as likely (if not more) that you are picking up additional indictments at the slower speed - you can confirm enough easily by calculating how many pulses to be emitted during the movement of the platform to the desired distance.

      The signal directly from a quadrature encoder can be quite noisy.  The 6008 is only able to edge simple counting, so no noise on a front amount could lead on Board being counted more than once.

      The 6211 supports a specific type of channel linear encoder, which configures the meter to use both signals A and B of the encoder.  In this mode, the meter requires alternating the edges of A and B to continue incrementing, which means a noisy transition will always only picked up like an edge.

      In case you do not have access to both A and B signals (or if the encoder is particularly noisy for some reason any and produced false edges in the middle of a period of high/low), the 6211 also supports filters PFI (link pdf Manual of use).

      Best regards

    7. Using a value Boolean true to increment a counter

      Hello world

      I would like to make a simple counter that waits just until a value Boolean true is passed and account 1, then wait until it happened again and goes up to 2 and so on. Just a single increment each time a real rose. I'm sure it's pretty simple, but I had no luck so far.

      Who does not resemble a need for a secondary loop.  You can add code to this loop to analyze the data.  If you do the calculations to determine a true, you already do the job.  Instead of going out a real, just increment a value of a shift register it.  Saves the hassle of sending one real constant for another loop for updating a shift register.  Do not create excess code just to have more code.

    Maybe you are looking for