VisuSerialCom Project suffering from severe lag

2015-04-02
2015-04-02
  • Matt-Engels - 2015-04-02

    I am using the VisuSerialCom example project - albeit altered - to read an integer from an Arduino, which sends it every second as a high and low byte in order.
    I've edited the project to receive the data as an array of 1 int and it displays properly. That integer is a base number plus a randomization band (i.e. 6000 + random number between -100 and +100), hence the update every second is important to capture the most recent value.

    The problem I run into is this: After running for a while, the number reads suffer from very severe lag. I can force the Arduino output to zero manually and observe that change immediately on an attached 7-segment display as well as on an oscilloscope.
    I left the program running for 12 hours and the lag is now at about 25 minutes. So I force a change to zero, and the Raspberry Pi with the modified VisuSerialCom project still updates the number once every second, but it will take about 25 minutes of 1-second updates before the value goes to zero.
    What should I be looking at to fix this? Perhaps forcibly flush the readBuffer after every read? (How do I do that?)

    Thanks for any help,

    Matt

     
  • Matt-Engels - 2015-04-02

    For what it is worth, the delay in the read block is set to 1000 ms. The Arduino writes a new value to its serial port every 1000 ms.

     
  • Matt-Engels - 2015-04-02

    Never mind - I think the problem is gone now. I reduced the read delay from 1000 ms to 250 ms and the delay appears gone, even after running the application for two hours.

     

Log in to post a comment.