03-29-2024 03:28 AM
Dear All,
my aim was to send a string command via serial (LV) to my arduino, let the arduino create some signals (sine waves, rect signal etc.) and send the data with the correct delay back to the serial port and read out the data with LV. Further, whenever the data is being read by LV, I am creating a cluster adding a TimeStamp (since windows was started (dll running the getime command in c++)) so I can later check whether the read signal in LV has the correct timing (additionaly I am also checking this with an oscilloscop at the arduino analog output Pin). The Arduino sends the signal values with12Bit resolution (0.00 - 4095.00) with additional carriage return and line feed so it sends between 6 - 9 Bytes every 10ms.
So far I was able to do all the above. And the timing looks good (Bytes At Port don't accumulate and match the read count) and checking the TimeStamps also looks good. However, I was also planning to implement a preview window where the data is plotted in "real time" so I can check the signal course. But I was not able to implement the LivePreview without introducing a time delay (BytesAtPort accumulate) and the timing doesnt match anymore at the end.
I tried to implement a seperate while loop with an additional queue, then I tried to make use of Notifiers, then I tried to check the queue status and preview the last element, however all of these approaches introduced delays.
Therefore I would like to know, whether you could help me implementing this LivePreview?
Attached are the LV Files. The main vi is called StimulusArduino.vi
Solved! Go to Solution.
03-29-2024 07:43 AM
Your file IO needs to be in a completely different loop, not just in a different case as the serial read. Read up more on the Producer/Consumer.
I actually doubt the need for the State Machine architecture here and even the Event Structure. I think you could clean up this code a lot by letting the initialization happen before the loop and eliminating structures.
The attached code has some clean up done, but the main focus is showing the writing of the file in a separate loop. I also changed your graph into a chart.
04-04-2024 02:38 AM
Thank you very much crossrulz. Your suggestion was very helpful!