Handling serial data

I'm not sure how to handle the serial data I'm receiving from a touchscreen panel.
All I want to do is display the two sets of coordinates, which are made up of two 4 digit numbers.
What I'm struggling with, is the carriage return/line feeds (Cr/Lf).
For example I receive,
TP  CrLf                  TP = touchscreen pressed
0100 CrLf             0100 = first set X of coordinates where these values may be anything from 0000 to 4000 and like wise for all coordinates
0200 CrLf             0200 = first set Y of coordinates
TR CrLf                   TR = touchscreen released
0100 CrLf             0100 = last set of X coordinates
0200  CrLf            0200 = last set of Y coordinates
If the stylus is dragged on the touchscreen, then I may receive numerous TP CrLf plus the coordinates before I final get the touchscreen release set. 
If I didn't have all the CrLf's but just one CrLf' after TP nnnn nnnn it wouldn't be problem.
I've had a go using shift registers, but I'm unsure of the best way forward.
Some guidance would be most appreciated.
Solved!
Go to Solution.
Attachments:
Shift1.vi ‏17 KB

I would advise to have several readouts in one iteration of the main loop:
First readout - search the received string for valid command (TP or TR).
If found: run the FOR LOOP to read 2 more times - you will get a string array of your coordinates.
If not found: skip, go to next iteration.
First check this: Each readout should give you one message (TP, TR, or coordinates) and properly terminates on linefeed.
You do not need string concatenations from previous iterations, all shift registers. If not, something is wrong with ViSA settings: wrong termination char, etc.

Similar Messages

  • Searching Incoming Serial Data

    Greetings!
    I was trying to get visual studio to filter through the incoming serial data it is receiving from an Arduino. The program shows the incoming data, so I know the serial port is working, but I'm not sure how to get it to look through that data ( I was thinking
    I could use StreamReader to do this). My goal is this: When certain data is received, change the background color of a textbox. I am very new at this and any direction would be appreciated! I feel like i'm throwing spaghetti at a wall... 
    Here is my current code:
    Imports System
    Imports System.Threading
    Imports System.IO.Ports
    Imports System.ComponentModel
    Imports System.IO
    Public Class Form1
    Dim myPort As Array
    Delegate Sub SetTextCallBack(ByVal [TEXT] As String)
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    myPort = IO.Ports.SerialPort.GetPortNames()
    portCmbo.Items.AddRange(myPort)
    End Sub
    Private Sub startBtn_Click(sender As Object, e As EventArgs) Handles startBtn.Click
    SerialPort1.PortName = portCmbo.Text
    SerialPort1.BaudRate = baudCmbo.Text
    SerialPort1.Open()
    startBtn.Enabled = False
    closeBtn.Enabled = True
    End Sub
    Private Sub closeBtn_Click(sender As Object, e As EventArgs) Handles closeBtn.Click
    SerialPort1.Close()
    startBtn.Enabled = True
    closeBtn.Enabled = False
    End Sub
    Private Sub SerialPort1_DataReceived(sender As Object, e As SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
    ReceivedText(SerialPort1.ReadExisting())
    End Sub
    Private Sub ReceivedText(ByVal [text] As String)
    If Me.inputTxtBox.InvokeRequired Then
    Dim x As New SetTextCallBack(AddressOf ReceivedText)
    Me.Invoke(x, New Object() {(text)})
    Else
    Me.inputTxtBox.Text &= [text]
    End If
    End Sub
    Private Sub outputTxtBx_TextChanged(sender As Object, e As EventArgs) Handles outputTxtBx.TextChanged
    Dim myReader As StreamReader = New StreamReader("Me.inputTxtBox")
    Dim line As String = ""
    End Sub
    End Class
    ps: If there is an easier way of doing this, please let me know!

    You should read a good book on "Communications".  When processing received data (from any device) you need to wait until you get the end of message before parsing the data.  The data will be received in chunks that can contain from 1
    to a million bytes.  When you get the word "Hello" you could get "H" then "ello" or "Hel" and then "lo".  You can't start looking through the data until you get the entire word "Hello". 
    So you first have to define a protocol for sending commands to the device and the amount of data that gets returned.  So normally you have to terminate a message using one of the following methods
    1) Ascii : Terminate a message with a fix character like a return or EOM.
    2) Ascii or binary : Includes a bytes count at the beginning of the message.
    3) Ascii or binary : Each type message is a fixed length.
    You can use combination of the 3 methods above.
    jdweng

  • I want to use the SQL Toolkit of NI and SQL Server as my databasis on a server. Do I need to install a client in each computer I want to handle the data into SQL tables or I need only a ODBC driver?

    I want to use the SQL Toolkit of NI and SQL Server as my databasis on a server. Do I need to install a client in each computer I want to handle the data into SQL tables or I need only a ODBC driver?

    You only need the ODBC driver on each computer. If you are distributing the SQL Toolkit app as an executable and do not install the whole toolkit on each computer, you'll need the SQL Toolkit support files. This is about a dozen files. You can get the list at http://digital.ni.com/public.nsf/websearch/b814be005f9da9258625658700550c75?OpenDocument.

  • In  BDC how you handled header data and item data

    In  BDC how you handled header data and item data

    Raja,
    Can you be more clear ?
    Usually you load the header data one and then loop at the item data and then load the item data.
    This example should help you.
    http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
    Regards,
    Ravi
    Note - Please mark all the helpful answers

  • How to handle the Date & Time Object?

    Hi,
    I have big problem.I am working on j2ee application(using jsp & servlets).I am using Jboss App Server. The server is placed in India.
    But there is two offices, one is in India ,another one is in USA.
    But i want to handle the date and timestamp object commonly,
    But this object should be able to calculate their own date & timestamp object( e.g.,India,USA ).How can i solve this issue?.
    Help appreciated!
    P.Saravanan

    Hi,
    I have big problem.I am working on j2ee application(using jsp & servlets).I am using Jboss App Server. The server is placed in India.
    But there is two offices, one is in India ,another one is in USA.
    But i want to handle the date and timestamp object commonly,
    But this object should be able to calculate their own date & timestamp object( e.g.,India,USA ).How can i solve this issue?.
    Help appreciated!
    P.Saravanan

  • How to handle unsaved data in portal through webdynpro ABAP ?

    Hi Experts ,
         I  need to handle unsaved data in SAP Enterprise Portal through webdynpro for ABAP . I got a sdn link which explained some code for this..
    http://help.sap.com/saphelp_nw70/helpdata/EN/45/b76f4169e25858e10000000a1550b0/frameset.htm
    I tired to implement this in EXIT method of the view. but im not able to get this . Can any one help me in this ? .
    Regards ,
    Kalpana .

    Hi ,
    Yes i have checked the code . But the example itself not working when i linked the same with portal . If EXIT is not the right method , Can you help in placing the code in right method ? The code i pasted in EXIT method is 
    data L_COMPONENTCONTROLLER type ref to IG_COMPONENTCONTROLLER .
    data L_API_COMPONENTCONTROLLER type ref to IF_WD_COMPONENT.
    data L_PORTAL_MANAGER type ref to IF_WD_PORTAL_INTEGRATION.
    L_COMPONENTCONTROLLER =   WD_THIS->GET_COMPONENTCONTROLLER_CTR( ).
    L_API_COMPONENTCONTROLLER = L_COMPONENTCONTROLLER->WD_GET_API( ).
    L_PORTAL_MANAGER = L_API_COMPONENTCONTROLLER->GET_PORTAL_MANAGER( ).
    call method L_PORTAL_MANAGER->SET_APPLICATION_DIRTY_FLAG
      exporting
        DIRTY_FLAG = ABAP_TRUE .

  • Handling large data -urgent

    i have to compare fieldname from 2 different servers(as in newly added/deleted/length) the problem here im facing is handling huge data ..
    i have made an rfc for fetching fieldname from remote server n then reading on tabname n then comparing the fields...
    even scheduling in the b/g doesnt help ..its taking around 6 hours of time..
    is there ne ways through which i can segregate the data n execute ,i cant make a select option for tabname in the selection screen ..
    someways through which i can pass alphapets dynamically/groups to rfc ..

    pass chunk of data (i.e. 200 to 300 records ) to RFC ... and fetch records w.r.t to that data only..
    this will improve RFC performance

  • How does everyone handle sweep data from loops

    There's a type of test I've done a few times over the years and I'm researching what are some standard ways to handle the data in TestStand. The test type is sweeping multiple parameters in a nested loop. For example, sweep Vcc from 5.1V to 5.5V in .1V steps, at each voltage sweep Q DC Bias from 1.9 to 2.3 in steps of .2, and at each Q DC Bias sweep LO Drive Level from -5 to -20 dBm in steps of .5 dBm. For each input combination record IM3 Suppression. This example produces 310 data records.
    If I did all this inside a single code module I could pass it back to TestStand as four arrays, one for each input param and one for the data. Done. I'd still need to log it.
    What if I want to do the looping in TestStand? Here's how I could collect data.
    1. Record the three params and one data into the ResultList as single points with Numeric Limit steps and sort it out in some datalogger callback.
    2. Collect four arrays or a 2D array in Locals and then copy the arrays into the ResultList as four arrays (or 1 2D), not as scalars in #1 above. Log it in some datalogger callback.
    3. Collect four arrays or a 2D array in Locals and just use a code module in the client sequence to save the data.
    4. Any others?
    Thanks

    Hi dowNow,
    I can't immediately think of any significantly different alternatives to accomplish what you are wanting to do.  In the past, I have personally used the external code module to do the looping and measurements and then returned the data as a 2-D array.  You can then add this array to the ResultList.  This has typically given me the most efficient tests and the simplest overall setup.
    Additionally, I am not sure if you are planning to store the results in a Database, but if you are, you will need to keep in mind that logging a 2-D array to a Database works differently than a 1-D array.  I have included a link to one of our KnowledgeBase articles that details exactly how to store a 2-D array in a Database:  http://digital.ni.com/public.nsf/allkb/1307679F845B162286257160000510ED
    Thanks,
    Jonathan C
    Staff Application Engineering Specialist | CTD | CLA
    National Instruments

  • Using Digital I/O to generate serial data stream

    Hello All,
    I am in need to generate a serial data stream. HW I use is MIO-16E-10.
    I am planning to use the digital line out to generate the serial data stream.
    I seems that if I use the wait timer the minimum pulse width I can get is
    1ms. But for my application the pulses have to be shorter than that. I was
    wondering about an alternative way to achive this. Any one who has worked
    with a similar application please help!
    Thanks in advance!
    Anand.

    Anand,
    What you are looking to do is not possible with the digital lines on the board you have.
    Depending on what other connections you have on the board, you could use one of the two analog outputs to generate your required serial data stream using pattern generation. Check the DAQ solution wizard=>Custom DAQ applications=>Analog Output=>Generate continuous sine wave. This example should give you a baseline to get started. Substitute the sine wave generator for your desired digital stream Logic 0 =0V, Logic 1=5V.
    If you need more than 2 lines, or some form of handshaking, I would suggest using the PCI-6534 or (DIO-32-HS as it was previously called) This will give you the ability to generate serial data streams with timing and/or handshaking.

  • Can express vi handle large data

    Hello,
    I'm facing problem in handling large data using express vi's. The input to express vi is a large data of 2M samples waveform & i am using 4 such express vi's each with 2M samples connected in parallel. To process these data the express vi's are taking too much of time compared to other general vi's or subvi's. Can anybody give the reason why its taking too much time in processing. As per my understanding since displaying large data in labview is not efficient & since the express vi's have an internal display in the form of configure dialog box. Hence i feel most of the processing time is taken to plot the data on the graph of configure dailog box. If this is correct then Is there any solution to overcome this.
    waiting for reply
    Thanks in advance

    Hi sayaf,
    I don't understand your reasoning for not using the "Open Front Panel"
    option to convert the Express VI to a standard VI. When converting the
    Express VI to a VI, you can save it with a new name and still use the
    Express VI in the same VI.
    By the way, have you heard about the NI LabVIEW Express VI Development Toolkit? That is the choice if you want to be able to create your own Express VIs.
    NB: Not all Express VIs can be edited with the toolkit - you should mainly use the toolkit to develop your own Express VIs.
    Have fun!
    - Philip Courtois, Thinkbot Solutions

  • Serial data tab page missing during Goods Receipt for Mvt type 501

    I have created and asigned the Seria data profile in plant data/Storage 2 of the material master record. Now i want to do the Goods receipt of this material with Mvtr type 501 w.r.t any documents for 5 no's and want the serial number to be createdment. I also have made relevant settings for automatic serial number and equipemnt number synchr, but wen i m in MIGO--Goods Receipt OtherMvt type 501 and enter, the serial data tab page is missing..
    How can I activate this tab page....Any steps missing....
    Can some one throw lights on this.....
    Refered relevant threads but not much useful to my query....
    Thanks
    Murad Shaikh

    Try 501 with MB1C, OR
    Check through Path SPRO -> Sales and Distribution -> Basic Functions -> Serial Numbers -> Determine Serial Number Profiles -> Select Profile 'MM' & double click on Serializing procedure at left & maintain obligatory(03) for procedure MMSL i.e. Maintain goods receipt and issue doc. Also press F1 in Serial Number Usage to read the usage.

  • Reading and analyzing serial data

    Hello,
    My question is about interpreting periodic serial data.
    I'm trying to read a serial rs232 port, through which I'm receiving periodic data which is made up of 4 repeating messages.
    Each message consists of several parameters of various length and fomates (for example, the first parameter could be an unisgned byte while the second parameter could be a word-long float). Each message begins and terminates with known character sequences.
    I need to read this periodic data and display it to the user, so that each of the parameters (of which the messages are made) is displayed
    by a different indicator.
    Right now, I've used the basic read/write rs232 LabView tutorial but now I'm pretty much stuck...
    I've built a similar program using Visual Basic and I've started using LabView in order to build better user interfaces but so far I'm stuck...
    Any suggestions?

    First, I think you really could have come up with a better user name then falling asleep on your "N" key.
    Data that comes in through the serial port is a string.  So your problem really comes down to how to parse the string into its respective parts.  Look at the functions on the string pallete.  Functions such as Match String, Search/Split String, or Scan String for Tokens, should do what you need.  Once you have the parts broken up, the String to Number conversion functions would convert the strings into their appropriate datatypes.

  • How to handle time&date

    can anyone tell me how to handle time&date correctly?using Calendar,GregorianCalendar,TimeZone,Locale
    thank you very much

    This is too large a topic to discuss in depth here. Here is a link to a tutorial on times and dates, and a search link that references many documents on the subject.
    http://java.sun.com/docs/books/tutorial/i18n/format/dateintro.html
    http://onesearch.sun.com/search/developers/index.jsp?and=calendar+&nh=100&phr=how+to&qt=&not=&field=&since=&col=javatecharticles&col=javatutorials&col=devall&rf=0&Search.x=20&Search.y=7
    When you have specific questions, just ask.

  • How does OS X handle my data?

    Im getting my first and brand new Macbook Pro this week and have to admit although i researched a lot i still dont know how it will handle my data which i currently have stored on my dvds (because i have to format my external hdd). will for example iTunes handle the data in the same way as it does on a PC? i mean by this that the PC version of iTunes only makes a copy of the files where as the files can be stored somewhere else. i dont wanna have the same thing on my mac. for example what happens if i change the name of a file (again in iTunes or iPhoto). will it change the name of the original file as well or IS it already the original file which is seen in such programs on the OS X? its a kinda confusing question i know but i am uncertain of what to do with the data once i put in a DVD into my new mac. please help....
    hope this is the right forum for the question. thank you anyways.

    Tharanon,
    From your latest post, it sounds to me like your main concern is, in fact, file organization. If that's correct, you'll have no worries!
    There's not terribly much different between the file systems (even though they are two different formats). At least, not so in the way you will interact with them. You will have one "volume," named "Macintosh HD" by default. You can choose to have this volume appear at all times on your Desktop, with an appropriate "hard drive" icon, or not- according to your taste. It will always show up in the "Sidebar" of any open Finder window as a shortcut. This volume, when opened in the Finder, will show several folders; "Applications," "Library," "System," and "Users" (at the very least). Obviously, the "Applications" folder is where your applications will be stored. Your own HOME folder, and those of any additional users you create, will reside in the "Users" folder. All very simple, all very organized.
    Any additional "volumes" can/will also show up on your Desktop, provided you set that as a preference in the proper location. This includes any attached device that can potentially house files: A CD/DVD, an external hard drive, a remotely mounted network "share," a thumb drive, etc. Your access to the contents of these volumes will be as seamless and as logical (concrete) as accessing the files on your internal hard drive, through an open Finder window.
    Your HOME folder stores absolutely every file you use, with the exception of those that reside solely on external/secondary volumes. Do not confuse this with the applications that allow you to access and/or view those files (as stated above, these live in the "Applications" folder). Inside your HOME folder, you will have "Music," "Movies," "Pictures," "Documents," "Downloads," and "Desktop" folders (and a couple others) by default, each intended to house the appropriate files and libraries. iPhoto, for example, will store its library within the "Pictures" folder by default. You can change this behavior as you like, of course. As you can see, however, everything is set up for you out of the box to maintain strict- and logical- organization.
    I'm afraid you have been mislead a bit concerning the format of your existing external drive. You should have no trouble accessing this drive, as it is right now, from OS X. If it is formatted as FAT-32, you'll even be able to write to it. If it is NTFS, you will only be able to read.
    Regardless of the format, you will have the ability to import from it, into the appropriate Apple application. And, you'll be able to import as is most convenient to you. If you find a single audio file, for example, it can simply be dragged into iTunes to effect the importation. Or, you can use the "Import..." dialogue in iTunes to scan a single folder or an entire directory structure for audio (and video, since iTunes supports video) files. iPhoto operates in the same way, of course, and it won't matter to any of the iApps where the source files you want to import reside, provided the volume can be read by OS X.
    Perhaps your only hurdle will be the fact that some "generically" named files will be imported as such, and it will be up to you give them meaningful names. What I mean by this is that you may end up with a bunch of tracks in iTunes named simply "track 1," track 2," etc. This is a problem regardless of how one imports, and it is up to the user to grant meaningful names at the time the files are imported, or to slog through tracks at some later time to determine what's on them (and to name them according at that time).
    Getting back to the issue of your external drive's format.... Unless you intend to continue using this drive with PCs, you will at some point want to reformat it as HFS+ (Mac OS Extended), if only to use it as a Time Machine backup drive (and BTW, begin using Time Machine to make regular backups as close to immediately as you can manage). I wouldn't recommend that you erase this drive right off the bat, since you may have some files on it that are important to you. If you know this is not the case, and that everything you want to keep is stored on your DVDs, go right ahead. Just be sure, and keep in mind that OS X will undoubtedly read it just fine (even if it cannot write to it).
    If you have further questions, ask away.
    Scott

  • Write serial data directly to file

    I am using DasyLab 9. I am reading a com port for serial data. if i issue the command to output a log of stored data from the RSMASTER when the program is not running I get all the data that is in the log. however, when I run the program and send the received strings to a global variable, a$1\r and log it to a file using a message module when the string changes I dont get all the data, there are one out of 10 lines missing. so I would like to output directly to a file or maybe there is a better way to set up the log so that i dont miss data while I am writing to the file.

    What is the time base of the module that feeds the Action module? That may determine the update rate -- it should be faster than you expect the data to change.
    There's also a question of whether the RS232->string is always catching the string.
    Rather than use String changed, you may want to use a timer function for the input to the Action, and write regularly. 
    Is the string alphanumeric? If so, there aren't many choices for logging to a file. You can log strings via ODBC, but it has the same limitation of the Action module response time. 
    - cj
    Measurement Computing (MCC) has free technical support. Visit www.mccdaq.com and click on the "Support" tab for all support options, including DASYLab.

Maybe you are looking for