03-01-2013 04:00 PM
Hi friends,
I am wokring on a project where I use 4 analog sensors and I have ADCs to convert them and a propeller uC chip to transmit digital data to the PC. I am using serial communication for this. I am sending out the digital equivalent of the individual sensors serially( one after the other ). It was very difficult for me to control this serial data and read them separately in labview. One problem that I noticed was the serial data kinda acts like marquee text, where it scrolls from right to left ( i know this is because the buffer gets the data serially). But my problem is I could not separate individual sensors. So , I then used Carriage return to identify 1 cycle of all the samples and still dint work. Now, I am trying to use "scan for Token" VI and I am adding token and carriage return after each sensor data in the series.. Now , My serial data looks something like this..
1408=
1058+
926-
507/
=,+,-,/ being tokens and the token are succeeded by carriage returns and after the last carriage return, I send a Line Feed, so that labview serial VISA can terminate on receipt of this . Now what I need is, The numbers 1408, 1058, 926 and 507 extracted separately and must not clash with other sensors. I am not sure if my understanding of scan for tokens is right I think I have made my situation and problem clear, If there is any question , Please let me know and I will provide all details that I possibly can. Hoping for a possible solution !!
Thanks,
Pram
03-01-2013 04:11 PM
For previous versions, I have attached 8.5 compatible VI.
03-01-2013 04:15 PM
You can put all the tokens in one array and scan the string in a loop with a shift register. The token index output will tell you which token was found.
However, there may be an easier way. If you separate the sensor data with tab characters and end the string with carriage return or line feed, you can use Spreadsheet String to Array fucntion to convert the entire string to an array of numerics in one step.
Lynn
03-01-2013 04:39 PM
Thanks a lot Lynn,
That solved my problem ! kudos 🙂
03-01-2013 04:54 PM
I was able to extract the data to arrays.. but still the marquee problem exists, hence the data in sensor 4 moves to sensor 3,2 and to 1. Thus I end up getting the wrong answer... is there any possibility to stop this from happening ?
03-01-2013 05:18 PM
Exactly how do you now have the data formatted?
This is what I suggest:
<sensor1><tab><sensor2><tab><sensor3><tab><sensor4><carriage return><line feed>
Set the serial port to terminate on <line feed>. Then each string you get from the VISA Read will have the four sensor data sets in succession with the <line feed> stripped off. Apply that string to the Spreadsheet String to Array functions and you should get an array with the data in the proper order.
Only the first read might be "short" because the remote device is already sending when you start your program.
Lynn