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.

Tags: NI Software

Similar Questions

  • 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;
    }

  • 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!


  • 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).

  • While loops inside while loops, how to stop?

    Hey, I'm confused with a simpler question to multiple while loops. My goal: stop or pylone2, just jump out of the small loop and stay in the big one. and if I click on stop 3. the entire program would cease... How can I do this? The following script does not at all... Thanks in advance!

     

    Yes you are completely right Mike... now, I solved the problem with another structure of the event and the Boolean variable local... Thank you very much!

  • Stop and start the task in while loop

    I try to start and stop an output meter (creates pulsed output) in a while loop and I don't know how this is possible. I have a while loop running who is taking measures from a digital compass. If my title is within acceptable limits, the outputs of the meter (2 of them to turn to the left and right) must be turned off. If the title is out of the acceptable range, let say too far to the right, I want to start one of my outings of the counter to activate the object to the left. The issue I am having is that if I put the block 'Start the task' in the while loop the system will try to start each iteration of the loop, even if it is already on. I don't know if there is a problem, but it does not appear effective from a programming perspective. I remember reading somewhere that stop and start tasks can really slow a loop. Any suggestions?

    I actually just to understand it. If you use some if statements and the "fact of task is" block you can make it work.

  • Stop a while loop in a sub - VI in a message in queue manager

    Hi all

    I am trying to program a control for certain manufacturing equipment. For this I use a message in queue manager. Within the QMH, I have a VI that controls a particle size probe (called a PPC, at the bottom of the first image. When I start the main-vi, the PPC.vi is on the case "Parsum measurement", in which measurement data are repeatedly called in a while loop (screw for call data provided by the manufacturer of the probe. Also, I am aware that I don't connect the data again. That will come later.). When I want to stop the measure, I have send the message "Exit" to the PPC.vi (last photo). However, the vi is stuck in the while loop in the case of the measure and is unresponsive. I tried to send a notifier with a constant value true, but that did not work as well.

    You have any suggestions, how can I stop the while loop before you send the message "Exit"? Or is the completely different way to approach this problem?

    Thank you!

    I just threw together a framework very fast to help you get started.  The thing I noticed is that the library of the queue doesn't have a time-out of the waiting message entry.  Since it is your own local copy (to the project), add a timeout and connect to the element Dequeue function.  I by default set to-1 and make it "recommended".

  • How to stop a while loop structure in the event of a main vi

    Hello;

    Sorry for my English

    I have to stop to a Subvi my main VI, the Subvi contains a while loop and an event structure, so I need to stop this loop while I tried directly from my main vi, global variable, but it did not work

    any help please or example!

    How about something like this (solution see attachment) using a user event.

    Explore the User Interface--> range of events and dialogue. To display the dynamic event of the terminals in the structure of the event just right click and select 'display the dynamic event posts '.

  • 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

  • stop a while loop in slot - VI

    Hello

    I have a Subvi, which has a while loop and it is in my main vi in a sequence structure, I want to stop the loop inside the Subvi using a Boolean value in primary vi.

    I tried global variable, but it has not worked since the stop in my main vi botton is not updated when the program is running...

    could you please help me?

    I appreciate any ideas

    Thank you

    Darya

    As a general rule, avoid using Structures of the sequence.  The reason being that they are violating data streams.  If you can control the flow of data with threads, it is the most effective way to make your program work.  The idea to get rid of your sequence structures is therefore to make an another Subvi to your expectation that also has an error and output error.  Then, you can use the cluster of error to force execution.

    And while loops inside the subVIs is a common beginner problem.  If you do not order when the loop ends based on a front panel of the mainVI control, then the loop must be in the main VI.

    I hope it's a good summary of what was said.

  • 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.

  • Code Golf: stop two while loops with guaranteed ratio iteration

    Proposal

    In the vein of the tradition of Perl, I would like to see if there is any interest to solve a few puzzles programming in LabVIEW. Can someone post a problem and define the rules to solve.

    Here's a question for beginning/intermediate to sharpen your "palette".

    Description

    With a user action, how you would stop two while loops such as the relationship between iterations is the still the same? Concrete to view this situation is to take action: both instruments use the same source of synchronization to take measures, but second divides the clock down so that it is a little slower than the first whole factor. For example, if the slower instrument is four times slower, then at the end of the VI, the slower instrument takes 100 measures the fastest instrument took 400.

    Rules

    • You can use vi.lib
    • You cannot include any other subVIs
    • Your solution should pass for loop1 interval as low as 25 ms

    Model (joint in LabVIEW 2009)

     

    If people are interested in this, then we will find a way to improve future problems. Please post your suggestions and criticisms, but only if you also post a presentation ;-)

    MacNorth wrote:

    [..]

    If we choose the first suggestions, the VI has yet to recover the data at different speeds. You can dedicate a loop for each instrument to disassociate a jitter and latency introduced by their connectivity or the inner workings. This adds a margin of safety when there is a conflict of thread and the pilot. You can also implement a simple counting as altenbach loop and renounce the multiloop complexity.
    [..]

    It is a very good point. But I wanted to make sure, you should / need to discuss the benefits, but also the disadvantages of the design. Implementation of an application is most often a process of 'special cases '. If a framework/design for a single application model does not necessarily correspond to another application.

    Designs are always strongly according to the requirements and constraints. What gives here designs will result in educational services, of course, but not necessarily as reference models for specific applications.

    Advantage of simple loop:

    • No synchronization between several loops required
    • Can easily implement any whole factor between services (quotent & function remains for a case structure

    Disadvantage of simple loop:

    • Take advantage of the multi core systems (at least not much)
    • Can easily run out of the time constraints (material not "not responding" enough, fast manipulation of data takes too long,...)
    • Code will accumulate within the structures of the case, where the readability could suff

    The advantage of multiple loops:

    • See essentially the disadvantages of single loop (several loops solve those)

    Disadvantage of multiple loops:

    • More complex, especially for the sync switch (not beginner friendly, requires a more/better design)
    • May contain easily questions source such as race conditions and locks

    A little side note:

    Even if the equipment works different acquisition rate, this does not necessarily that the software must use different rates for data extraction. You can use the same model of an hour, but get X times more values for the task faster than the slower running. The 'only' thing to care of are the sizes of buffers and bottlenecks in the data transfer.

    MacNorth wrote:

    [..] The best advice published OR shutter multiple while loops (https://www.google.com/search?q=labview+stop+multiple+while+loops) are laughable (and the 'solution' in my model). [..]

    No, it's not laughable. For many applications, this approach to shutter at the same time several loops running is OK. The constraint: only for simple parallel running loops.

    More complex loops (producer/consumer and similar) with the more complex data relationship ships require more valiant approaches such as queues, declaring events or user.

    My 5 cents only,

    Norbert

Maybe you are looking for

  • Facial recognition error

    I have upgraded to iOS 10 the other day and it is very good even on my iPhone 6plus. However in the photos app, the facial recognition software is great, but it is not perfect. He can see me and group all my photos into an album (JanuaryShark) and th

  • When and where can Tecra M4-133 - I buy it?

    No one knows when the m4-133 model goes on sale in the United Kingdom? the 128 MB nvidia version would also like that someone knows where you can buy a m4 spec albums in the United Kingdom? for example. 2.2 ghz 2 GB ram 128 graphic dvd - rw. Council

  • Error No. Boot Disk was detected or the drive failed - h8-1020 Desktop

    1 hp pavilion HPE h8-1020 2. windows 7 64 bit 3. Realtek PCIe GBE Family Controller series v2.38 24/12/10 Error: No boot disk was detected or the drive failed. 4. no changes to the system. After I restarted my computer about 7 times it finally starte

  • DD Realtek Audio Manager

    I have Windows 7 ultimate (64 bit) in my computer. I also installed Realtek HD Audio driver but I couldn't listen to songs of Mr. I also checked all the settings in the detroit and Realtek Audio driver.In Realtek Audio Manager rear panelBlue - speake

  • OEDQ-UCM: Match individual real time does not

    HelloWe have created personalized for the individual and entity matching rules and added custom fields (which are used to match) in the fields of the seller for account and Contact deduplication parameter. We tested the rule through web services in r