04-20-2016 11:23 AM
So it appears that the code reads the seial data (which is comma separated strings of numerical values e.g. 3802 , 3867, 3761), but it's not able to split this up into an array of elements, which could then be used to plot a graph.
Instead it periodically 'chops'(?) a value, and places it int he first element of the array. Hopefully this is demonstarted in the screenshot which shows 55, clearly not of in the same set of ~3000 values.
I know the data is successfully received at the comms port (illustrated by using XCTU), but LabVIEW appears not to be configured correctly. The serial configuration matches that of other's I've seen online using XBee.
Any ideas? Much appreaciated!
04-20-2016 11:35 AM
I ran your VI and it worked just fine. I don't have your hardware, so I just manually entered your raw data. There must be someething in your actual data stream that is causing the "spreadsheet string to array" to chop(?). Right click your "read buffer" indicator and select '\' Code Display, re-run your VI and make sure there is nothing the the read buffer that you don't expect.
04-20-2016 11:41 AM
The other thing that you can try is to make your BYTE COUNT number very (larger than the amount of data you expect) and terminate the VISA read on the termination character. typically 0xA
04-20-2016 12:24 PM
Hey thanks for the reply!
So on code display I'm getting:
3007\00,\003006\00,\003007\00,\003004\00,\003005\00,\003006\00,\003006\00,\003
I'm guessing \00 is a null character or something? Could this be thorwing it off? Not sure how to recitfy as I'm not placing the \00 there...
04-20-2016 12:44 PM
The \00 is definitely your problem. Try using the search and replace pattern.vi in the "Strings>>additional String Functions" Pallet. Just remember to set Boolean to TRUE to delete all instances and leave replace string as default "".
04-20-2016 12:50 PM
Oh I forgot. Be careful how you create the Regular Expression. Right click the regular expression and set it with '\' Display Codes BEFORE you enter the \00 in the string.
04-20-2016 12:57 PM
I haven't benchmarked it to the search and replace method, but this works too. Just set the delimeter to include the NULL character
04-20-2016 06:41 PM
Yes this works! Thank you!
However, it's 100% there...
I think this should be simple to fix, but I'm not competent enough with LabVIEW to figure out the solution. So you'll notice in my program there's a 'byte count' control (limits the no of bytes to read).
If this is say 50, the program will aquire 7 array cells worth of informaiton, load them to the array, and plot the graph, all simultaniously (i.e. it waits until 50 bytes have been received before displaying anything). It will then run this process again, overriding the first 7 cells and the graph.
The desired operation is: read 1 value (i think 4 bytes value 1 byte comma 2 byes null chars), place in array, display on graph, read another value, add to array, add to graph, ... (frequency of values is around 1 per seccond)
I'm guessing the solution to this is in while loops... but no idea how. Essentially the array and graph shouldn't be overwritten which they are sitting in the main while loop, but not sure how data can be added once they're outside the loop.
Any thoughts?
04-20-2016 07:31 PM
Does your device send a special character stating that the message is complete? Typically it is a Line Feed (0xA). If it does, what you really want to do is set the Byte Count to something really large so that you get the entire message with 1 read.
And you actually want a Chart instead of a graph since a chart keeps a history.
04-21-2016 02:34 AM
Hey thanks for your reply!
So there's no special character sent to say the 'message' is complete. The purpose of the proram however is to display the data as the data is being transmitted, this then stops when the sender says so.
Thanks for the tip on the chart, that has helped!
However the 'byte count' is chopping the data after a fixed no. of bytes. The data values being sent are of variable number of bytes so this inevitably means the first and last of each set are usually 'chopped' (not the full value). Each value is separatd by a comma (,), is it possible to somehow replace the bytle limit with a requirement based on the comma separation?
Any help appreciated!