Jump to content

Program flow, best way to update GUI with data?


Recommended Posts

My program takes in a lot of async serial data, runs a checksum and checks it with the checksum in the datastream. If it checks out I would like to send the data array (2D) to the front panel for UI. If the data is bad I want it to NOT update the UI basically exiting the while loop, what's the best way to do this? As of right now when I get a bad checksum my program reads in the next byte in the serial buffer and checks to see if it's the start bit 55h, if it's not, it exits the case structure and after exiting the while loop it has to send out data to the UI so I get a lot of "crap". My temp solution was to use a shift register of the array so that if the checksum is bad it sends the last "good" packet of data to the front panel. The problem with this is that while the while loop is checking for the start/stop bytes "55AA" it might have to read in a LOT of bytes before coming up with the start of the next packet so while it's looking I get a lot of repeat data that shouldn't be displayed at all.

So the questions is this; Do I use notifiers, local variable, global, lv2 global, or occurance with local variable? I believe I'm going to have to go from an embedded while loop to a parallel. I'm familiar with this as this is already in the VI handling events :) . Any help would be appreciated.

One last tid bit of info, the data packets are 277 bytes, start and stop bytes, followed by 256 ram bytes from hardware, followed by some 10-bit AI, then the checksum. The serial rate is ~33.6kbps which works out to around 17 packets a second.

Link to comment
  • 2 weeks later...

i use locals (globals) if i have to update from one while-loop to an other, but normally i try to avoid such things.

if you want to update and it does not matter if you loose some values, use notifyers. use notifyers also, if you dont want to care about queues which "run full", but be aware, that you can loose some notifications

use queues, if you can't afford to loose a value, but be aware, that you have to poll the queues continiously, otherwise they can consume lots of memory, if they are filled continiously, eg. in a subVI

Link to comment
Without knowing the details of your setup, the first thing that comes to my mind is: why not use the Select function (from the Comparison pallette) and pass out an empty array (constant) when the checksum fails?

-Khalid

Passing an empty array causes the GUI (which is in it's own loop) to display default values. This is the data I was calling "crap" because the user gets confused and my eyes hurt when the gauges and charts go bonkers. Not to mention that the loop that sends the data is "looking" for the next start/stop bytes which means if I get a bad packet, it will then sometimes run the minor loop 270+ times before getting the next start/stop bytes. This means the GUI gets 270+ empty arrays screwing up the line charts (not xy graphs).

With queues I'm able to collect the valuable data and the GUI loop waits for the queue to have an element in it meaning low cpu usage and clean data being sent to the GUI.

i use locals (globals) if i have to update from one while-loop to an other, but normally i try to avoid such things.

if you want to update and it does not matter if you loose some values, use notifyers. use notifyers also, if you dont want to care about queues which "run full", but be aware, that you can loose some notifications

use queues, if you can't afford to loose a value, but be aware, that you have to poll the queues continiously, otherwise they can consume lots of memory, if they are filled continiously, eg. in a subVI

I was going to use globals and occurances but the queues seem to be working too well to change anything. Thanks for the bit about the memory, I'll keep an eye on it. I might go to notifiers although I don't want any dropped packets. Thanks :)

Link to comment
Who's Jon?

Anyway, it seems like you solved your problem. I think the easiest solution would have been to use a case structure. You don't really want to update anything, so when data is bad, case-out the data updating code. Am I missing the point?

I'll try casing it out and see if it performs any better. Thanks for that apparently obvious solution :headbang:

Link to comment
  • 8 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.