From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

adding event to VISA Read N Write

Solved!
Go to solution

Dear all,

I am attaching the snapshot of the VI i am working on.

When the No. of bytes at Port >= 1054, it reads from the port.

Presently i am executing the VISA Read function in a case structure.

 

Now, i want to execute that Read function in an event node. like whenever the bytes at port >=1054, it should initiate some event and the read function should be called in that event node rather than in a case structure.

 

How is it possible ?

 

Thanks,

Ritesh

0 Kudos
Message 1 of 7
(2,855 Views)

If you use an event which will wait 1054 bytes to be executed, and for some reason there is no communication your vi will wait forever.

To solve that, you need some kind of polling...

So your code is ok. Just add a wait function in the loop

0 Kudos
Message 2 of 7
(2,851 Views)
Keep waht you have. You will only have to add a user event when you have more than the set amount of bytes. An event structure can then be used to handle the data received.
Regards,
André (CLA, CLED)
0 Kudos
Message 3 of 7
(2,840 Views)

Hi Pnt and Andre,

I am working on an application which is completely designed on user events. And getting data from my hardware is also a user event action.

 

Could anyone of you please post a sample example showing an event which will wait for 1054 bytes to be there on the port and execute the Read function ?

 

 

Thanks,

Ritesh

0 Kudos
Message 4 of 7
(2,824 Views)
Solution
Accepted by topic author LVCoder

Just use the timeout event, and put inside your existing code.

 

Message 5 of 7
(2,818 Views)
You can also theoretically use the VISA Enable Event and VISA Wait on Event functions. These, however, do not tie into the event structure. Thus you would need to use user events to trigger your event structure. Depending on how you code it you would need to either have the VISA Wait on Event inside your Timeout case and the function itself would need to have a short timeout so it does not interfere with the processing of other events, or you would need to have the VISA Wait on Event outside your case structure. While you could make it work, by the time you got done you will probably find it easier to go with the suggestion of simply putting the "No. of Bytes at Port" in your Timeout case as the last suggestion indicated.
Message 6 of 7
(2,812 Views)

Hey Pnt,

Thanks alot for your suggestion.

Putting the entire code in the timeout event really works gr8.

 

Thanks,

Ritesh

0 Kudos
Message 7 of 7
(2,785 Views)