12-16-2014 10:38 AM
Hi.
I use VISA serial in my program in LV2013 for read data from MCU. each time MCU send 14 byte for LabVIEW and in LabVIEW I use this VI to read data. if data read count was 14 byte, my VI in the case will be executed. here is snippet from my code. (I simplify the VI and in case other functions will be executed and it worked well).
I run this code and it use pooling method and CPU worked always for it. it may be cause to VI run slowly.
then I meet EVENT structure in LabVIEW. it seem to be good and professional. so I use EVENT structure in my VI. but when I use below VI it doesn't work !!
in your opnion why this cannot work and what is your suggestion ?
I use and indicator that named " x= y? " for add compare function to event structure.
in final LabVIEW code ,data will come with high baudrate like 460800bps. this worked well without EVENT structure.
Thanks.
12-16-2014 11:55 PM
Hi everybody.
I right question in better explainations:
I use VISA read functions for communicate MCU with LV2013. each time I send 14 byte that contain a begin char (like 'T'), a termination char (like 'R') and 12 byte data between them. MCU send 14 byte with high baud rate like 460800bps or higher.(I use PL2303TA USB to Serial). time distance between each send is approximately 100us. I put my function and other stuff in a case loop. read function is in while loop which you can see a snip from VI below :
everything is OK.
but recently I met EVENT structure in LV and have been interest to it. I want to use EVENT structure for reduce CPU load. but when I put EVENT structure in my VI, it odesn't work. the picture o my VI is below :
I use an indicator for create an event on "equal " function output in EVENT structure.
have anybody any idea for that ?
Thank you.
12-17-2014 12:06 AM
12-17-2014 02:13 AM
first of all, thank you Dennis for reply.
how I can write to a value signaling property outside the event structure ?
in my final program in case statement I use more functions like filtering data, write data, calculate data, and showing on chart for 4 seerate data whici extract from incomig data from seial port. for this reason I sayed CPU load is high.
I want to use EVENT structure to save CPU time and power.
Thanks.
12-17-2014 02:32 AM
12-17-2014 03:56 AM
I used 1ms delay before, but in this time data send from MCU every 100 us and I couldn't use delay function with value equal to 100us (it is ms).
but I want to read function work every 100 us and therefore while loop run in every 100 us .
can I say my goal correctly ?
@Dennis_Knutson wrote:
In any case, just create a separate loop or place the read in your timeout event.
can you explain more about this ?
12-17-2014 08:03 AM
By putting your reading of the serial port into a seperate loop, it can run completely independant of the rest of your code. Your read loop does nothing but read the data on the serial port. You can then use User Events or Queues to send the read data to whoever needs it. This is how I set up all of my streaming serial applications.
12-17-2014 08:44 AM
what is your point from "Queue" ? can yo axplain a litle example ?
12-17-2014 10:45 AM
@ajapyy wrote:
what is your point from "Queue" ? can yo axplain a litle example ?
I use a form of the Producer/Consumer.
12-17-2014 10:47 AM - edited 12-17-2014 10:48 AM
Basically this (https://decibel.ni.com/content/docs/DOC-2431) or this (https://decibel.ni.com/content/docs/DOC-30005) except with visa instead of the DAQmx VIs or the event structure.
Edit: ^^his is better