While loop stopped by press of button

Hello

I build an applitation who, in a single time loop, collects a multimeter data and displays it on the .uir Panel.

I have a problem with the breaking of this loop. I want to do by pressing any key, but it does not work.
I realized that when the program is in this loop, there is no recognized reminder.

I tryied with GetUserEvent, but it did not work.

It could also be a solution to have a reminder that generates every 0.5 s and updates these data, but I don't know how to do this.

Code:

/////////////////////////////////////////////////////////

int eventPanel, eventCtrl;
QueueUserEvent (2000, panelHandleFILTER, FILTER);
{}
...

eventPanel = panelHandleFILTER;
GetUserEvent (0, & eventPanel, & eventCtrl);
} while(eventCtrl!=2000);

//////////////////////////////////////////////////

Best

Chris

Well, it's a different philosophy : If you're new to ICB I wouldn't start with the more complex issues such as multi-threading, although it may be more elegant, more efficient cpu etc.

The following code works; He will not win a prize but can be implemented in two minutes (or less, depending on the speed of typing ). It can also be easily adapted to use a timer for the acquisition of data, as shown in the example timer I suggested to look at earlier.

#include        
#include
#include "keypress.h".

public static int data = 1;
public static int panelHandle;

int main (int argc, char * argv [])
{
If (InitCVIRTE (0, argv, 0) == 0)
Returns - 1;    / * memory * /.
If ((panelHandle = LoadPanel (0, "keypress.uir", PANNEAU)))<>
Returns - 1;
DisplayPanel (panelHandle);
RunUserInterface ();
DiscardPanel (panelHandle);
return 0;
}

int CVICALLBACK PanelEvents (int Panel, int event, void * callbackData,)
int eventData1, int eventData2)
{
switch (event)
{
case EVENT_KEYPRESS:
data = 0;
SetCtrlVal (Panel, PANEL_LED, 0);
break;
}
return 0;
}

int CVICALLBACK (int, int int event control panel Start,
void * callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
data = 1;

SetCtrlVal (Panel, PANEL_LED, 1);
While (data)
{
; take data
ProcessSystemEvents ();
}
break;
}
return 0;
}

int CVICALLBACK (int, int int event control panel Quit,
void * callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
QuitUserInterface (0);
break;
}
return 0;
}

Tags: NI Software

Similar Questions

  • While loop stops unexpectedly

    Hello world

    I have a problem with while loops.

    Im trying to write a program that allows me to control the temperature of a hot plate, using as a starting point one of the examples in LabVIEW (basic series writing and reading). So basically the program sends an order asking the real temperature of the heating plate and it then reads a response with the State, then the user writes a temperature (the sub - VI creates the command that is sent to the cooking plate), then he reads a confirmation response. the while loop is to monitor the temperature and change it if necessary

    Sometimes it works for about 30 seconds and sometimes for a few minutes, and then everything stops playback, I don't get the error messages, it stops just a response.

    The hot plate is a pro H550 MS7 and im using a USB to RS232 converter

    PD, I'm pretty new using labVIEW, sorry for my bad English.

    Greetings and thanks for the help

    Bob_Schor wrote:

    Found the manual.  Here is a summary (edition - in fact, it is essentially all of the manual, just condensed and without 'images'):

    • The statement format: prefix, Instruction, data frame, Checksum
    • Command: Prefix is 0xFE
    • Answer: The prefix is 0xFD
    • Add at least 50 msec between pairs of bytes
    • Data frame, send high and low bytes
    • Checksum = sum of the instructions, the frame data, but not prefix
    • Commands and responses seem to be mainly sequences of 6 bytes

    OK, this helps a lot.

    The first issue with the OP code: turn off the stop character.  The protocol uses binary communication protocols.  The stop character is only useful for communications ASCII protocols.  Nor if he was being a 0x0A in data, VISA Read stop reading right there because it's the stop character and it is enabled by default.

    Second, always do not have need of the bytes to the Port.  You know what you send and you know what should be the answer.  Therefore, suffice to say the VISA of reading to read the required number of bytes.  If your delay is long enough, you do also not waiting for him by saying the VISA must read the number of bytes to read.

  • stop another WHILE loop

    I have two while loops running independently.

    The first has a Structure of the event that controls the STOP button for a user by clicking.

    The second series a bed to a port.

    When I get an error messages entering the serial port, I want to provoke the other WHILE loop stop.

    What is the best way to do it?

    Connect a case structure wire to the error and write to a signaling value property of the button stop in the case of error.

  • Stopping at two simultaneously while loops in a sequence

    I'm under two loops while at the same time. A while loop is used to produce a square using the acquisition of data USB of NOR-6343 wave. The another while loop contains my main code. I make sure that my square wave while loop stops after the hand while the loop is over. I used the function "To highlight the Excution" to see if my code is excuting in order and the way I expected to and it seems to do, but when I hit the button stop the square wave while loop stops so that the main while loop always ends excuation. The main while loop takes a series of measures using the data acquisition Toolbox, so I need to make sure that the square wave is being emitted during the execution of the loop of mian.

    Currently to work around this problem, I wired a constant numberic (101) inside the large loop for a numberic out indicator. And I used a cheque codition "Equal" in the square wave while loop and set it so that this loop stops when he sees the value. This seems to work and made sure my square wave still series, while the main loop is excuting finishing. Even if it works, I want to know if there is a better way. Attached are a couple of screenshot of the loops.

    I vote for using a notification utility.  You must order the loop at the end.  Do a front panel indicator to stop a loop is not a good practice.

  • How get a while loop that will not run at least once?

    I am very very new to LabVIEW and I try to use a while loop to control a device. For the moment, I have a very simple setup of a slide linked to a comparison of vi, when the blade is higher or equal to a value all the while loop stops. However, I wonder if there is a way that the while loop will works do not "at least once" in the case when the blade is greater than the value set when the program starts. I have a situation like this in a program more complex so any help or suggestions would be appreciated. Thank you.

    One solution is to drop your loop inside a structure of business and your comparison before falling into the while loop.

    Another possibility would be to use a conditional to the loop where you have the possibility of wiring from scratch to the final iteration based on a comparison.

  • While loop, wait for the function and the stop button!

    Hello

    I have a while loop and a stop button. Inside my While loop - I have a 'Wait (x ms)' function. If I press the stop button, it does not block the program immediately, he expects ms x then stops the program. How can I get rid of this?

    Thanks in advance for the help!


  • While loop with stop unwired FPGA button?

    I've seen examples FPGA with a while loop where nothing is plugged to the stop button. On a target PC, it would throw an error. What it means?

    I think you are talking about "Timed loops" that are "single-Cycle timed loops" on FPGA.

    FPGA is intended to be run until it is powered, a 'Stop' software does not much sense.

    Norbert

  • How to stop the While loop in the Structure of the event with the same button?

    Hello

    I have a problem. I want to use a single control to activate an event in a structure of the event and the same control to end a while loop in this case.

    It is possible to use 2 controls to do this, but I need to be alone.

    Thank you

    You should NEVER place while loops inside the case of the event, and it is never necessary to do. Think about it: all you have to do is spin the code. You can easily use the outside while loop for everything. Simply place the code of the loop internal (without the inner loop) inside the case of delay and manipulate the time-out period between a pending finished and the infinite (-1), depending on the State of the Boolean value.

    A very simple example (LV 8.0)

  • Stop correctly with While loop

    Hello

    I can't stop the information that moves in stages with a while loop I created (see below). I joined the program (LabView 8.5) for reference, just in case.

    Currently, whenever I press the stop button designated for the control of the scene, the stages will not stop until the last part of the scene movement pattern is complented (in this case part 7 of the stacked sequence). Now, I have tried various things, but it was the best I could do to make the stage stop at all. (all other attempts resulted in a clumsy scene movement afetr the boss or not at all stop). Any ideas on what I can do? I'm positive that comes to a while loop on the stacking sequence was probably not a good idea. I also stacked sequences are usually wrong (or it seems) but I it is rather tedious otherwise.

    Thanks for the help, Amend sorry if this question seems pretty basic, I haven't used LabVIEW much until last week.

    It's one of the reasons why the stacked sequences should be avoided at all costs!   They can ALWAYS be replaced by a state machine with several advantages.  No. 1 among the benefits to replace a sequence of stacked with a state machine is the ability to STOP a stacked sequence between state transitions should complete each picture before stopping.

  • stop the loop inside while loop

    Hi all

    Is there a way to stop a loop within a while loop? Error-free program will stop running when you press the stop button, but I want to while loop continues to run in and only for the loop stops when the condition is met.

    Thank you!

    Hi TayAus 1.

    If you want to run the execution once? Maybe something like below? The code inside the structure of events can only run when the event source is triggered. For example, the code in the digital works only when it detects a change in the numerical value (just an example).

    When the button is selected, it should raise the event to stop as shown below:

    If you want to create the event source, create the structure of the event > right-click on the frame and select edit events dealing with this... > This should open Edit events.

    The example below is that I put the event source for the change in the value of x and x 2.

    So when x or x 2 value is changed, executes the code in the sous-schema event shown below.

    Warm greetings,

    Lennard.C

  • While in a while loop loop will not stop running

    HY, I have a while loop and hand inside the other 2 If. The attached VI supposed to work like this:

    1. define the input data

    2 - Press START to "animate" the data in the chart

    3 - Press STOP to stop the animation

    and the hand while the loop must travel 1-3 until you type EXIT, and then it stops the program.

    The problem is the EXIT doesen't button stops the program, not always. Sometimes, it sounds like the key EXIT "JAMS" and stops the program, when I hit the STOP button.

    You have a solution to my problem, or a better way to do this?

    Thanks for the help in advance!

  • Start stop while loop with tab control

    I want to be able to start and stop a while loop by entering and leaving a tab.  I use a structure of the event to do so, but it seems not elegant or the right way to do it.  The only way I could get to the kind of work is by unchecking the lock front panel in case of structure.  I have attached a sample vi of what I have so far.

    The problem is that you can't even stop the program by pressing the stop button until you exit the tab, which is not a user friendly interface.

    The event should just manage basic user events.  Any given event does not take a lot of time to run.  While you are in the diagnostics tab, your code is stuck in this while loop.  Although the setting of the front panel of the lock allows you to do other things, the LabVIEW is just put on hold all these other events of the UI (like Stop button value change) and cannot handle them inside while the loop stops and allows outside while loop to go through again.

    You should have a parallel while loop to manage waveform graph.  You can use notifiers or queues or a motor of action FGV (see Ben Action Engine Nugget) to switch the starting or stopping of the update of the chart of waveform until the parallel of while loop.

  • Structure of the event to increase a value while pressing a button

    I want to use a structure of the event to increase / decrease the value.

    It works with the 1 step.

    But I want to increase the value (steps of 200ms) continuously while I press the button with the mouse. If the user could increase the value a little more comfortly. And when I stop pressing the button the value stops increasing.

    I don't work...

    LV 8.2

    I got it!

    Thanks for any help. I have the end of the loop. The problem was that the structure of the event has allow access of the façade, so that the button was able to deliver.

    See attached vi!

  • Can not on the button while loop

    Hi all... hoping to get a few design tips as I am very, very new to LabVIEW. I got a project that someone else had started and I've encountered a problem that I don't know how to solve.

    I'm using LabVIEW version 8.0.1 and I think my problem has to do with the help of DAQmx in a while loop. In "Working.vi" (including the Sub - VI 'Temp data to CSV.vi'), I copied - and stuck the while loop in a vacuum VI for testing. In this VI, with nothing else, it works - slowly, but it works.

    In the real VI, I can see the data of temperature updated every 4 seconds, so I know that the program is not frozen or something like that. However, by pressing the button "Return to main Menu" does nothing - the image of the button does not show that it is to be depressed, regardless of how many times you click or click and hold the button. I've attached a screenshot of the while loop inside the real VI; I prefer not to fix the real VI (especially because it contains references to many of the Subvi, and it is not currently contained within a LAW degree).

    I'm this coding the wrong way? I have the feeling that it might be caused by my settings DAQmx (continuous samples, 2 samples to read, 250 mHz). The very low rate would be the cause? Is there a better way to have readings of temperature taken every 4 seconds (approximately)?

    You have your case of event the value "lock the front panel" until full?  If so, then no other presses the button will be recognized until the ongoing case event complete.

    It is never a good idea to have a code in an event business that takes a long time to run.  It will make your UI seems to lag or even functional.  Any time I see someone with a while loop inside a case of the event, I'm afraid.  (By the way, I am also concerned all nodes comments hovering over the structure of your event?  What are doing?  Why some operate on the default data?)

    In general, events should take is no longer running then what ordinary person could be expected until they feel like the user interface is delayed.  Perhaps at the top of 1-2 seconds.  You should look at a model of design of producer/consumer with events.  The structure of your event should respond to UI events, then pass orders by a queue path to the part of your program that does the real work.

  • force stop while loop

    Hello

    I'm writing a VI that make a transaction within a while loop. I replaced the operation with a simple mathematical operation in the attached photo of the VI. For loop in the picture, I just want to add 1 every 15 secs until it reaches 10 and stops. However, I also want to be able to force the while loop to stop immediately all 15 sec until the next iteration. Is there a way out of the waiting time for the while loop? Thanks for the help!

    Altenbach says:

    Use the event with a timeount 15000ms structure and an event for the stop button. Urgent stop immediately interrupts the time-out.

    Here's what I had in mind (LV 8.5).

Maybe you are looking for

  • Why on the mozilla icon appears and desappears a kind of bubble?

    Why on the mozilla icon appears and desappears a kind of bubble? »

  • Install Windows 7 on HP DV7 7373ca Envy

    Hello I would like to install windows 7 on the laptop. I tried, but it seems that it is blocked or not, given that windows 7 displays an error because of the configuration of the hardware. Can it be done? where can I get the recovery with windows dis

  • Toshiba 32BV801B looking for a replacement stand

    Hi, I have a 32 "32BV801B TV model. I am currently looking for a replacement stand but can't find one that says it fits this particular model. No one knows what the other models have the same position that will fit. Thank you

  • New HP Photosmart 7520 won't print from the photo tray

    EDIT: He will feed from the phototray if I print the photo in Windows Photo Viewer.  However, he still refuses to print directly from the jpg format, even if I specify explicitly in all the settings I want to print a 4 x 6 from the photo tray. Is thi

  • HP Photosmart 2575: HP Photosmart 2575 on Windows 10?

    I know that this unit is old and out of taking care of and so I realize that there is a very long shot, but I wonder if anyone has found a way to get a HP Photosmart 2575 network to work 10 (home, 64-bit) Windows? I did a clean install of WIndows 10