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