LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Visa buffer read in event case

I think you should do as little as possible in the event structure and make a state machine with a case that handles the writing and reading of data. Your event structure will be

in a "Monitor" state, looking for changes in controls. Then, the event structure changes what state to go to next instead of trying to do everything in an event structure.

 

If oyu are not familiar with state machines, read this:http://zone.ni.com/devzone/cda/tut/p/id/3024

Message 11 of 16
(287 Views)

ok...i've an event structure (see fig. 1.jpeg). In every event a subVI (like that in fig. 2.jpeg) sends a command to the stepper motor driver. I have thought to modify SubVi, leaving write visa only in it,  and using the new code read visa in a common while loop.

0 Kudos
Message 12 of 16
(286 Views)

sorry about my last post... I was referring to your sub-vi which writes and reads to/from the serial port.  I had not gone back to figure 1.  And while reading many posts in a short time, I tend to forget past contents... 😉

 

Again I agree with zenthoef that you should do as little as possible within the event structure.  The reason being that once the task is accomplished within an event, the structure will sit and wait for the next event.  The other end of the spectrum is that if you spend too much time within the event, then the structure will not handle pending events in a timely fashion.

 

A good approach with event strucutres is to use it as a producer in a producer/consumer arrangement.

 

Also...  you should not implement an event structure within sub-vi's.  Well... I would not recommend it.

 

______________________________________________________________________
0 Kudos
Message 13 of 16
(263 Views)

Thank you very much for all your support. I've resolved my problems inserting timeout time in event structure. So in this way my 'visa read' reads the buffer correctly.

Now my VI works great. I'll try to rewrite the  vi using Moore machine structure.

And I think i'll request your help again when i'll have to implement ssi communication protocol using labview FPGA, in order ti read an ssi absolute encoder.

Thanks a lot again

Francesco

0 Kudos
Message 14 of 16
(253 Views)

That's awesome it worked! Not only will it work better now, but polling for responses is so much more efficient than delays between a read and write. With polling it takes, more or less, only the time needed for the device to respond and not the time of an arbitrary delay.

0 Kudos
Message 15 of 16
(242 Views)

I'm trying mixed approach Moore machine-event structure...It's fabulous!

Thank you very very much

Francesco

0 Kudos
Message 16 of 16
(233 Views)