Clear VISA with event structure

Hello

I have a number of virtual serial ports of bluetooth as stream very quickly as soon as you open them with VISA configures port. I have set up/open these ports one after the other and it takes a lot of time (2 min), I think it's because they are com ports virtual bluetooth.  However, as soon as a single port is open, the data streams in and fills the buffer (eventually crashing the program), while I open other ports. I was invisioning something similar to an interrupt driven microprocessor to erase the buffer whenver it exceeds 2000 bytes to the port, my friend told me about event structures is similar to interrrupts. So, ideally, I would like to create a user event customized, defined by the property (bytes to the port) of a VISA com port node when it exceeds 2000 bytes. I would like just to run code that was going to free the buffer when occurs the same. Seems like a simple idea, I searched and did not find what I wanted to do.  Any help would be appreciated

Thank you

Chris

Its delicate, but I think it would work.

LV allows multithreading, so you can certainly run screws in parallel which are completely independent of each other.  But the challenge is that your code cannot access the same COM port simultaneously.  But the way you described the problem, which could be circumvented.  I think your 'COMPortMonitor' could sit and wait for each port to open before their follow-up... so that your main loop before opening the following COM port.

Here's what the flow would look like:

VI of HAND PORTMONITOR.VI                                      

0 Begin execution of this

1 separate launch PORTMONITOR.VI

2 open COM1 begin implementation of this loop

3 tell PORTMONITOR COM1 is open

4 begin to monitor COM1

5 open COM1 empty COM2 buffer when it becomes large

7 tell PORTMONITOR COM2 is open

8. start monitoring COM2

9 empty COM1 & COM2 when they become large

10 stop this loop when last COM is open

11 more...

In step 5, your parallel loop will work with COM1... so that your main loop is busy opening COM2.  In theory, I expect to run independently.  And you can try to put them in separate threads, too.  This links talking about parallel loops in series:

http://forums.NI.com/T5/LabVIEW/multiple-parallel-asynchronous-continuous-serial-visa-reads/m-p/8090...

BTW: I think that you must ensure that your VISA application is asynchronous to operate (right-click on them).

Tags: NI Software

Similar Questions

  • logical AND with the structure of the event

    Hello world

    The structure of the event can manage several events at once to do the same thing: looks like an OR logical operator. But I have not found a way to sequence events to approach a logic and example: you must click on a button to draw, then enter the image would change the mouse cursor. With a structure of the event, I can handle these 2 events separately or together (i.e. change the cursor), but I can't do a sequence of events.

    Is this possible to do with a structure of the event?

    I hope that I am clear (sorry for English btw). And thanks in advance.

    Christophe

    I don't think this is possible directly. You will need to add status information to your event loop that could enforce the order of events and the rules of logic you want. Where transformation you would have to check whether the required event has occurred before this event. If that were the case, perform your treatment. If this isn't the case, ignore the event. Your first event would need set this status information. You can also include some kind of time-out for the second event were to occur within a specific period.

    This type of logic may be better treated with the help of producer/consumer architecture and a state machine in the task of the consumer.

  • major error with the structure of the event

    IM under LABVIEW 13.0 PRO

    I don't know when this strarted bug happening, but now when I add a business to a structure of the event. Freezes in LabVIEW. I have to close labview with the Task Manager.

    It doesn't matter what code I'm working with, even a new VI, with nothing else than a structure of the event.

    I tried this on my desktop PC, my laptop and my CPU DAQ.

    The error occurs on my desktop and my laptop. But it does not occur on my CPU DAQ.

    Whenever I click on add event usually case, you get a popup to configure and add cases, but with the popup error never comes to the top and labview crashes.

    Theres no code to share the problem ocured when adding events to the event structure. It happened with any structure of the event, in any code, all the time.

    I spoke to an engineer of apllication of labview and suggested to delete the labview.ini file located in the installation of labview directory. I did this and the problem was solved.

    Still not sure what caused this to happen.

  • Remiain data in buffer with event VISA

    Hello

    I'm trying to use the VISA event to read data from a serial port. I created a simple VI to test this (see attachment).

    1. I initialize the port and the event

    2. in a while loop: whenever I press a button 'help' of the order is sent to my Board of directors who responds with some help instructions, which should be to trigger a series of events and lines to be read.

    The event is on the characters of the term. The strange thing is that whenever I press the help, I get 'event 5' or 5 printed lines, not all 8 lines that are actually sent by the Board of Directors. If I then press 'help' once again, the 3 remaining lines (2 news since the last aid application) are read on the VI. I don't understand what is happening?

    I tried to change the length of the max queue (which has no effect, if it is set to 1 or 100).

    I tried to change the timeout of 50ms, but also it has no effect.

    I don't know that the Board of Directors came out the right commands, I read this in a terminal.

    If I jump the functionality of the event (just read the bytes to port), I can get out all the lines as expected, however I had other problems with this approach and would really like to fix this with an approach to the event. Also, I would like to understand what is happening... I would be grateful for the advice!

    Best,

    Maria

    Do NOT use the bytes to the Port for this.  Just set the number of bytes to read if something really high.  The VISA of reading stops when the stop character is located.

    In addition, I'm actually just make a separate loop that does nothing but read from the port.  No VISA necessary event.  Let just wait times occur on playback VISA if nothing comes.

  • Synchronization of 2 loops while one with a structure of the event.

    Hi fellow users of LabVIEW

    I try to incorporate a structure of the event in my current exisiting VI to Save certain values of control as shown in this post

    http://forums.NI.com/T5/LabVIEW/using-the-quot-make-current-values-default-quot-as-a-control-on/TD-p...

    It's the VI that I use as model with my exisiting VI.

    http://forums.NI.com/NI/attachments/NI/170/547715/1/defaults%20Demo.LLB

    In case the 'stop, change the value' I use in the main VI and a 'real' constant instead of Boolean control of wire structure. While the loops are not connected. The table that I use in my exisiting VI (another while loop) is indexed and unbundled to be used here.

    The work combined well screw and it gives me the results, my question is, in the long run it will give me issues. Do I still need to synchronize?

    Thanks for all the help.

    There's no problem because loop additional lower with the structure of the event.

    Personally, I worry about the top loop. Why so complicated? Why so much duplicate code? Why all these hidden indicators serve as local variables?

    Why don't simply place you the table in the entire cluster in a shift register and the index and ungroup by name wharever value, that you need to access. No hidden local variables or indicators.

  • problem with tab structure control and event

    Hello

    My program has a tab control. In each tab, I have an event structure to control some events.

    I encountered some problems. These are:

    1. in each tab, I set tab as an event control, to altogether from the structure of the event as tab change (for example, the image below). My first problem is that when I change the tabs, in the arch depending on whether my program is entered in the next tab environment, happening at the event: change value to main tab! And gives bad result.

    2 - I've scheduled two final tabs as below in the image. I had no routine in these two tabs. Simply, I want when I change the tab, it goes to the next case of the tab control. But when I run the program, it goes to something as busy after one or two changes tab and did not work properly.

    Could someone help me please?

    Thanks in advance

    Baran

    Rebecca wrote:

    I want to have 4 tabs, each tab having 3 Boolean control.

    If in each tab all Boolean control wins 1, a Subvi should be run.

    I wrote this code with some time within each tab loop this case hase 3 for each Boolean control. The result is true.

    But I think that if I write it with a structure of the event within each tab instead of 3 cases, the cpu load will be lower.

    Is it not true?

    Make a unique Structure of the event.

    Add events for all controls (buttons, Boolean)

    When the event is triggeredcheck for active tab control and decide what void / vi to run

    It will work fine you

  • Problem with nested structures event

    Hello

    I'm rather new to Labview and I wanted to use a structure of nested in one of my programs at the event.

    However, I seem to fail to do things.

    I created a minimal example of construction that I use, you will find in the attachment.

    The idea behind this program is as follows.

    1. I have run the program and go into a while loop

    2. once I have hold down a button on front of a counter is increment every 100 ms.

    3. when I release the incrementing buttun stops.

    However, this does not work. What I am doing wrong?

    Thanks in advance!

    Never stack event structures. Never ever.

    That being said, your code contains a lot of illogical parts, for example a queue time when using a case of 0-timeout event.

    Please use a unique event structure. Where growth is expected to run, set the timeout case e .g. 100 (using the shift register) and once it is based again on set it back to-1. Initialize the shift with-1 register.

    Also avoid using references and nodes property to read/write the values. These are bad practices (in most cases) and bury a lot of run-time performance.

    A second shift register allows to keep the numerical value and increase the value in the case of timeout. Update of the terminal after the structure of the event.

    Norbert

    EDIT: My first line is a rule of thumb. With the increase in the skills of LV and appropriate design, the stacking of the structures of the event is possible, but you must know the rules. If this isn't the case, you won't fail hard.

  • Produce data of a loop with a structure of the event

    I'm relatively new to Labview programming (as discussed in my program below). I found a vi online which collects data from an analog USB card to 9237 bridge. The upper part of the vi is which collects the data. The original place the output into a chart, but I changed it to a digital indicator.

    The lower part, trying to get the operator to use the start, stop, buttons to interact with the system to reset. I used an event structure to do this. It all works well, except the event that the value of the load of data (from the loop above) cells. I want to follow up on the new value continuously, but is only once. All other features work fine. Can someone explain how I would best accomplish this?

    Any help would be apprciated.

    Why do you use a queue to pass data to a loop at the other?  The reason why it doesn't work once, it is the lower loop will wait until an event has occurred.

    I would eliminate the queue.  Wire the Total in a property for the total value (signalling) node.  That will trigger the occurrence for Total: change value event.

    Don't read property nodes in the upper loop when you have indicators and the son here to read from.

  • Unexpected behavior with several structures of events manages the event itself.

    Hi, does anyone have an explanation of the following behavior?

    After 'Boolean 2' is enabled and then disabled the program "freezes". You can always pause the program but nothing does.
    For example, by pressing one of the file, Edit, View, project, Operate, tools, Windows, help or any other object inside the VI.

    This happens if I have two event structures who want to handle the same event, even if the flat sequence should be allowed only one run.

    This isn't a bug.

    Structures of the event should be used to handle different events. Given that you have entered your Boolean event in the two structures of the event, the event gets queued both when it occurs. This means one or the other be expected to manage the event and will, by default, lock the application. In the scale-measure of LabVIEW architectures, usually there is a structure of single event that handles all the events and then sends messages to the coast to the rest of the application to manage these events.

    There is a "Table locking" checkbox in the event dialog box which is by default enabled, but you should leave it on because it leads to bad practices otherwise.

  • Reading of RS232 event structure

    Hello

    I use the Write.vi to read RS232 attached as a starting point and do RS232 - help.vi him. successfully, the original written 1 posts, then wait a little, then reads 1 message. What I'm trying to do is to be able to read several messages. So I would write 1 message and I would read 1, 2 or 3 messages back or however many messages to ever come back, I guess that.

    Here is how I modified the original vi to get where I am now:

    I tried to add a structure of the event around half 'read' RS232 program. My structure of event triggers when the bytes to read the changes, this value can range from 0 to several bytes to be read, or muliple bytes to read 0. Up to half of the time I would trigger and not need, so I then added the accession of case which only works when the bytes to read the value is not 0, which means that it must be something waiting to be read whenever the program inserts this box. (I hope that's clear).

    At the moment, my program will not read and I don't know why. Through the program of first base, I can read and write properly. (I just hooked pins 2 and 3 on my cable so I read everything I write for testing purposes). So I know that the problem is spoil me the 2nd joint program

    Any help would be appreciated! Thank you.

    EDIT: I added 2 .jpgs incase you are on an different labview version.

    Better.

    But I don't think that permutation of the structure of the event for the structure of the case actually has really helped what.  In fact he madet worse.  You had the case of locking Panel event before the value until the end of the event.  But with the structure of the event within the structure of the case, there is a chance that the structure of the event will never run and therefore the façade will be locked up forever.

    1. you want to only 1 VISA close.

    2. event structure has been set.  I also added an event for writing switch is restored.  So now, it'll write if you change the channel or when you turn the switch to True.  (Note, you will not be able to always send the same string as in the original example because you must press the power button or change the channel.

    3. I used the structure of the event to stop the loop of both Scripture by trigger on the event that the button is pressed.

    4. I don't know what you mean by a «black» read

  • Event structure vs business structure?

    I'm developing an application that can be fairly entered user based... a lot of command buttons Boolean to do different things.

    In the past, I was able to avoid the event structures "change value" and went instead with a while loop, stacked sequence and series of structures of the case. After, I decided that it was a terrible idea. This time, I intend to build an array from a Boolean, convert it to a number and feed it in to a unique business structure. This will give me the ability to add cases for different combinations of the Boolean being pressed.

    I guess the question is: what is the best way to do something like that?  Does have advantages over the other?

    Edit: I was not clear.  I would like to a comparison between the method of structure of event 'change of value', and just feeding into a table-> structure of the case.  I also fear that with the bool-> structure table affair I'll run problems where I find myself with too much control variable and the value of the resultant becomes ugly number very quickly. The application has several buttons... then, finally, save, load, several different configure configuration buttons etc.

    Thank you!

    Aalenox wrote:

    I guess I could do two separate loops running simultaneously.

    ^ ^ ^ THIS!

    Search for architecture producer consumer

  • How to merge the event structures?

    I have a program of VI script that reads a text file of records and displays a structure of the event.  It works very well because it creates all the controls and indicators I need associated with the defined registry and code backend (i.e. the structure of the event).

    After I generated all this code, I copy and paste in the main VI I develop.  Everything works very well.  The only problem is that there are 100 text files from separate registry.  This means that I end up with 100 separate event structures.  Although it works, it takes a lot of space and I prefer to combine them.  However, each event structure has anywhere from 15 to 75 entries, so to do this manually is not an option.

    Is it possible to selectively merge the event automatically structures?

    I guess I could write a labview scripting routine that could get a reference to the structure of the event in VI, then merge... but part of the problem there is that there are a handful of structures of event I want to separate them just because they are not associated with the set of registers, that I mentioned.


  • Event structure/state machine

    Here's the scenario.

    I use the buttons controlled by the user in an event structure to control a state machine. Currently, I have a different State for each button. However, 4 or 5 of these buttons could ideally correspond to the State, which is what I would like to get... Each of these 4 or 5 buttons causes flow data and the results are stored in a table, but listened data are different for each button! Therefore, if each of those 4 or 5 buttons caused the same condition occur how I could decipher what button was pushed? Ideally, I would have 4 or 5 different paintings once all the buttons are out of the same State.

    Is there anyway that I can achieve this?

    Hi the shots.

    you have access to the refnum of the element inside the event. With the Ref, you can simply get the name or any other property of the control to distinguish them.

    Mike

  • Slow assisatnt DAQ with events

    I have a question on the DAQ assistant. I'm currently programming an application automation at least 8 simultenously FOR loops and I use 3 different converters AD / DA. My problem is that when I'm working with the DAQ assistant nor (NI USB 6229) in this program and I communicate between the loops using son of the event (structure), the loop where are elements of DAQ assistant really slowing down. I mean I cycle every 3 seconds, this one is really kill me because everything else is really fast enough and only this one is slow (other two converters AD / DA are ok, they are not OR). Have you any idea where can be a problem and what to do to speed up my request?

    Sounds like a race condition, your local variables read an old value, which causes a loop to stop that you start the program. If you use local variables to stop several loops, it is very important to ensure that they are properly initialized at the beginning of the program.

    /Y

  • mouse event structure entrance decoration

    I want one of my events in my event structure to detect my mouse entering a specific decoration that surrounds a control. I used the property pane to find what decoration is # but now I don't know how to call this specific décor as one of my events.

    The goal is that I want the user to have pushed a button to make a data folder before hitting to start generating data. I need the user to get an error message that they did not create the folder if they get even close to the Start button. I don't want to get the error after what they already hit early, because my Start button is linked to the data to a network variable that will get the ready message even if my host program has generated an error.

    Decorations of the façade are not the type of objects that can be associated with events.

    I think you have several options.

    1. follow the mouse move event and to compare the coordinates of the mouse with a few constants that you set that based on the location of the decoration.  This seems to be a large number of polling stations.

    2. not to associate your button start a dependent shared variable in the network.  When you press the Start button, make your comparison, if that's OK, and if not, the error.  If it is allowed, activate another hidden Boot button that is associated with your shared variable.

    3. use the mouse down? event on the Start button.  If you find that it is not a valid time press the button, ignore the event.

    4. use the event mouse input on on the button itself.

    5. use the event mouse entry on another button, which is located behind the actual button.  It could be transparent, or disabled, or disabled and greyed.

    6. If the button get press, the program automatically creates the folder for them instead to raise a dialog box and forcing them to manually.

    I think #6 or #2 would be the best option.  As a user, I would find it quite annoying that whenever I swept the mouse over an area of the screen especially involuntarily to have a pop up dialog box.

Maybe you are looking for