Reading 16 & 22 bit signed integers using Scan From String

Last week it was suggested to use Scan from String which is a new tool for me and worked well to be able to read in ans parse strings.
After parsing the string, I'm having trouble converting the numbers into signed integers. The magnitude of some of the the outputs are unreasonably high then flip to near 0 then back up again.
Sample String (With spaces added)
$ 00 FCCE 00F6 3FFA93 0BFE 0C89 0DDB
Message Format:
Bytes 3-6 FCCE Heave acceleration bits 15-0 15-bit data, sign extended to 16 bits LSB : 0.001261g Sign “+” when accelerating upward
Bytes 11-16 3FFA93 FOG Gyro 1 bits 21-0 Bits 22-23 are always zero 22-bit signed data LSB = 97.275 µ˚/s Sign corresponds to MEMS axis
Sample Data File:
$00FCCE00F13FFD78100910A811FA
$00FCDF00F13FFCD3141614C71619
$00FCD600F33FFD20182118E61A39
$00FCDA00F73FFB3E1C2D1D051E58
$00FCDD00F73FFC32203921242278
$00FCDD00EF3FFDDC244525442697
The vi and a longer sample data file are uploaded to the ni ftp site. The zip file is named: IMU (9-15-08).zip. (Can't attach files to this message for some reason)
Any help appreciated.
Thanks,
Chris

Files uploaded to the "incoming" directory cannot be downloaded. That folder is intended to be used for submitting code to NI to investigate bugs and such things, not for forum posts.
What are you expecting FCCE to be? If the string is made of the characters "F", followed by the character "C", etc. (as opposed to the hex value of F, followed by the hex value of C, etc), then you can simply use Hexadecimal String to Number. Otherwise you need to use Type Cast.
Attachments:
Example_VI.png ‏5 KB

Similar Messages

  • Using scan from string

    Hi
    I am reading a string from an instrument in the format hr:min:sec, 0.000, 0.000, 0.000,0.000
    I need to separate each part and add it to an excel file. I have triend scan from string and
    string subset. I am unable to use scan from string as the first output is in different format than the others.
    I cannot use string subset as the value changes to a negitive value sometimes which makes it difficult to get the right string lenght.
    Can someone help me in figuring out the best way to split the string and add to an excel file
    Thank you in advance
    Raghu
    Attachments:
    pressure sensor.vi ‏27 KB

    Here is the screen shot after I ran the vi. Along with copying the data to an excel sheet I need the individual data to use in my program later.That is the reason I wanted to parse the string.
    Thanks,
    Raghu
    Attachments:
    string.JPG ‏153 KB

  • Using scan from string to convert a string into a number

    I wanted to use scan from string to change a string into a decimal number, but when the string is, for example, 9.14123E-2 it just returns 10. How can I get it to return .00914 or 9.14E-2(as a number not a string). Would there be something easier than scan from string? I'm using labview 5.1. Thank you!

    Hello,
    May be you can checkout the attached example.
    Perkash Mohan Lal
    Institute of Semiconductor Technology
    Technical University Braunschweig
    Attachments:
    string_conversion_1.vi ‏44 KB

  • Get string inside brackets - Using Scan from string

    I have a very basic question here. I would like extract a portion of a string which is inside brackets (Example: I work with [National Instruments]). In the string I only want to extract National Instruments, I do know logic to extract by finding the brackets and extracting them. But I am interested in using the Scan from string or possibly any other primitive in one shot. Please suggest if anyone has any idea, I am really not use to the format specifiers. I got this link for reference but I am not able to figure out a solution.
    The best solution is the one you find it by yourself
    Solved!
    Go to Solution.

    Hi,
    I cannot say that it is the best solution, I use two Scan From String functions instead of one but it does work, so far ;-)
    I use Characters in set.
    I could not attach VI so FP is below.
    Duri

  • How do I avoid Error 85 in Scan From String scanning VISA read buffer?

    I have encountered an Error 85 with my Scan From String VI. I have a timed
    loop to read data from a device (flowmeter) using a serial port. This device takes
    periodic measurements and sends the reading which contains a numerical value to the serial port COM1. It cannot be read continuously, and the period
    between measurements may vary, so I decided a timed loop would be better than a while loop.
    The VI begins with VISA Configure Serial Port and then
    goes to a VISA Write which sends the message to the device to begin
    taking measurements. After this, the device usually says "TAKE FLOWMETER READINGS" to the terminal, thereafter only sending numbers. Then begins my timed loop containing VISA Read. I
    am taking the read buffer two places.
    First, I am taking it to an Array to Spreadsheet String with the
    Format String %.3f, as was in the Write to Text File example. Then I am
    using Concatenate Strings with this string and also a string containing
    the System Time. This string goes to Write to Text File, which I have
    configured using Open/Create/Replace File outside of the loop.
    Second, I am taking the read buffer to a waveform chart. I thought
    it would be a good idea to use Scan From String to convert the string
    into a DBL which I am then sending to the waveform
    chart.
    I am not sure if the initial "TAKE READINGS" message is giving me an error. I was able to get one reading saved to my text file from the device.
    Also the format string for my Scan From String is %.3f
    I am getting the Error 85 at the Scan From String only sometimes.
    When this happens, there is no data being written to the text file. But
    other times, I get data and it writes to the text file just fine (but
    rounds to nearest whole number).
    Any help would be greatly appreciated! This serial port device has been giving me a lot of trouble.

    Is this what you mean? Did I wire the shift registers correctly?
    I didn't know if you meant to Concatenate before Scan From String or Concantenate before or after VISA Read?
    Message Edited by YeungJohn on 11-20-2008 03:48 PM
    Message Edited by YeungJohn on 11-20-2008 03:49 PM
    Attachments:
    SerialShiftVI.JPG ‏87 KB

  • Scan From String White Space

    i all,
    I'm trying to use Scan From String in order to parse some data coming in from UDP. 
    Input String: ASCII [00 01 02 03 ... FF]
    What I want: s[00 .. 30]  d[12], d[34], d[56] leftover s[37 38 39 ... FF]
    ATTEMPT1
    Format String: %49s%2d%2d%2d
    What I get: s[00-09] RUNTIME ERROR!
    ATTEMPT2
    Format String: %49[^]%2d%2d%2d
    What I get: Only allows first output. Will error out if I use any additional outputs from Scan From String
    ATTEMPT3
    Format String: %49[^(0xFF)]%2d%2d%2d Value in () is ASCII character FF.
    What I get: s[00 .. 30] d[12], d[34], d[56] leftover s[37 38 39 ... FF]
    It appears as though when I use %##[^] it thinks I'm looking for the ENTIRE string so it will not let me add any more Formatting.  If I add a delimiter other than ^ it will run, and it will work presuming that character isn't within the first 49 characters... and I can't guarentee that it won't.
    I'm aware I can parse my string using subsets and whatnot... but Scan From String is so elegant.  It would be great if %S allowed for white space... or if $##[^] would simply take the first ## characters and allow me to Format after that.
    Is there a simple, elegant way to do this?  I wish my dataset was only 3-4 outputs. It'd be ideal if I could.  Thanks.
    Edit:
    It might be more helpful if I provide a less abstract example:
    I have an ASCII Header (Finite Length String), a Sender IP (Finite Length String), a Timestamp, a Message ID (Finite Length Decimal), A Message in ASCII ( '1' actually means 0x31, not 0x01)  And for some ungodly reason... no delimiters.
    So I was HOPING %##s%##s%<%H:%M:%s>t%##d   (With leftover string to be my message)  would work, but if any white space is contained within there... it messes up. 

    I cannot provide exact strings because the string is actually ASCII characters, most of which aren't displayable. 
    I have a string where I have:
    24 ASCII Characters representing 6x U32 Header Data
    13 ASCII characters represening the sender IP (string)
    12 ASCII Characters representing the name of the message (String)
    12 ASCII Characters representing 3x U32 Data
    12 ASCII Characters represneting the name of packet (String)
    12 ASCII Characters representing 12x U8 Data
    256 ASCII Characters represening 256x U8 Data
    etc...
    It would be ideal to simply Scan from the string and output the data with the appropriate data types already assigned instead of splitting string and type casting each individualy.  But if, for example, my header starts with an ASCII representation of a U32 of 2560(decimal) it would look like this:  [00][00][0A][00].  ASCII 0A is considered white space.  So my header would only contain 2 ASCII characters instead of the desired 24.

  • Regular expression for Scan from String

    I am trying to pick out three numbers with pattern $number1:number2:number3# from a stream, for instance 8.559509#$-1.686432:-2.427051:-7.281153#$-6.160924​:-1.763356:
    So far, I use "Scan from String" with Format string "$%f:%f:%f #". However I don't know how to ignore/delete the items before $. Would you like to help me with that? Cheers

    You know that your sequence of numbers begins with the $ and ends with the #, so you can separate them into groups first, then separate each number out.
    Bill
    (Mid-Level minion.)
    My support system ensures that I don't look totally incompetent.
    Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.

  • SCAN FROM STRING IN LABVIEW 8.5

    Hi guys, i need help in this VI that i attached. I'm doing a project using serial connection between PIC18f4520 and Labview 8.5. I am monitoring the voltage and current. In the Read String box, (eg. when i run the VI, it will display 4.19v 4194uA.) How can i link this result to display on the graph simultaneously as the value of the voltage and current will vary when i adjust the value of the potentiometer.Can i use scan from string to linkup or ? i need help . thx alot people. 
    Attachments:
    fal Serial Write and Read with graph.vi ‏48 KB

    Hi, from the picture i have attached below, how can i link my output onto Voltage, Current and Temperature ? It seems that it can only display on the read buffer box. After which i need to gather the output Temperature to display onto the gragh as i need to monitor the temperature. Another problem i face is that how can i fix the byte read at 21bytes because if it is more than or less than 21 bytes, it will display funny characters(see 2nd attached pic below).
    Attachments:
    fal Serial Write and Read with graph 2.vi ‏48 KB

  • What is the Scan from string pattern for "match everything" ?

    Hello,
    Using Scan from string for a while, I know that %s only matches string up to a whitespace. And I also thought %[^] would match everything including whitespaces. But it turned out that it would stop at the closing square brace.
    So, what is the real scan pattern for match everything including whitespaces ?

    What do you want the Scan From String to end on?  Or are you just grabbing the rest of the string?  If that is your scenario, then just use the "remaining string" output.  It might help if you give a full example of a normal input string and EVERYTHING you want as an output.

  • What is the most efficient way to turn an array of 16 bit unsigned integers into an ASCII string such that...?

    What is the most efficient way to turn a one dimensional array of 16 bit unsigned integers into an ASCII string such that the low byte of the integer is first, then the high byte, then two bytes of hex "00" (that is to say, two null characters in a row)?
    My method seems somewhat ad hoc. I take the number, split it, then interleave it with 2 arrays of 4095 bytes. Easy enough, but it depends on all of these files being exactly 16380 bytes, which theoretically they should be.
    The size of the array is known. However, if it were not, what would be the best method?
    (And yes, I am trying to read in a file format from another program)

    My method:
    Attachments:
    word_array_to_weird_string.vi ‏18 KB

  • Wrong use of "Scan From String" function in a while loop?

    Hi,
    I've got a "Scan From String" function inside a while loop. On the first iteration it converts correctly the number passed by the input string (for example 4) But on the second one it has only spaces (one or more \s) as input string.
    I expected to obtain a zero as output (as it does always that it can not make any conversions, as I am supposed to) but indeed, i subtracts 1 from the previous number (according to the number indicated as example I would obtain a 3 as output)
    What's wrong with this?
    Does the function fails on this case?
    The rest of the diagram o the VI is expected to manage a 0 on that situation, like others in which the conversion is not made.
    Andres.

    I have simplified the VI evading calls to other VIs and trying to reproduce the mistake.
    The type of string I introduce to reproduce the mistake is:
    clock 3 (30) clock (40)
    Forgetting to introduce a number between the second "clock" and the following parenthesis, I would manage it programmatically with code that isn't included.
    Then "Scan From String" is supposed to do not make a conversion. But it leaves a 2 as output (in this example)
    I have realised, unbelievable but true, that it has matter with the number I substract to the output number (if it were 2, I would obtain 1 as output and so on)
    Excluding that, I got the conversion made before as output, 3, on the second time that "Scan From String" executes. But, how can this func
    tion as bad?
    I am using LV4 on an old PC. I have tried to reproduce it with LV6 and it works. But it isn't desirable for me, I would have to convert a lot of VIs and surely I will find a lot of errors due to the conversion (I have already tried)
    Attachments:
    EXTCLOCK.VI ‏26 KB

  • Scan from string error 85

    Hi Everybody,
    I'm trying to use LabView to
    process some data.  The data, although it was collected via labview,
    has been written out to csv file format.  I have been able to
    successfully open the file and use the search split string function to
    remove the "header" from the data stream.  Now I'm trying to parse the
    header to extract some pieces of the info that is there.  I'm trying to
    do this with the Scan from String VI.  
    So
    far I've been able to retrieve the Specimen ID from the first line of
    the header by setting the format string input of Scan from String as
    "Specimen ID ,%s", which works just fine.  Problem is, when I
    adjust
    the format string to include the next piece of data I want, I
    inevitably get an Error 85, which is a failed scan.  In fact, I
    get an err85 every time I try to extract something from after the
    second line.  I've attached a VI in which I cut and pasted an
    example header string in as a string constant and an example of how I'm
    trying to extract the values.  I've tried playing around with
    spaces and different formats, but get the err85 no matter what I do
    (unless I extract the first line).  I have a hunch that it has
    something to do with the EOL marker, but no idea how to work around it.
    A search of posts here show that a lot of people have issues with the
    scan from string vi, but nobody I could find had this exact
    problem.  I've also considered using the spreadsheet spring to
    array function, but because I have a mix of commas and EOLs it doesn't
    seem to work either. HELP! I really don't want to have to write this
    over in VBA/Excel.
    Thanks,
    Turk
    Message Edited by YoungTurk on 07-29-2005 10:36 AM
    Attachments:
    Scan.vi ‏12 KB

    You should probably parse it line by line (See attached, LabVIEW 7.1)..
    The attached example shows one possibility to get all the Items and values out. Not all values are strictly numeric so you would need to adapt the code a little bit. (This is just a very rough 1 minute draft).
    You might want to cosider to extract all values into a cluster for further processing, Have a look at the example  posted in this thread . It can be easily adapted to read the values in the proper format (DBL, I32, Date, String, etc.) depending on the item name.
    Good luck!
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    ScanMOD.vi ‏30 KB

  • Error 1 occurred at Scan From String (arg 1)

    I am communicating with the AT Trainer 5000 via serial port to USB converter.
    I installed all drivers of converter successfully and it is shown in MAX as com port. I also installed VISA software. 
    I am using labview 2013 version.
    When I connect the hardware to PC via usb to serial converter, try to run the program for seeing of real time graphs, I am receiving this error Error 1 occurred at Scan From String (arg 1) whereas there is no waveform shown in waveform chart. 
    Also read buffer didn't show an incoming data at read buffer.
    Other details for this error is
    Possible reason(s):
    LabVIEW: An input parameter is invalid. For example if the input is a path, the path might contain a character not allowed by the OS such as ? or @.
    Also pics of error is:
    Program is also attached. Please checked the also.
    Expert please help me how to get rid of this error.
    Attachments:
    Project.vi ‏23 KB

    Since you are using the termination character, you should not use the Bytes At Port property node.  Just set the number of bytes to read for the VISA Read to something really high (larger than what you expect in a single transmission).  The VISA Read will stop reading once the termination character is reached.
    Now, what is the format of the data coming from the instrument?  I see you are converting an ASCII Hex string into a number while trying to also turn it into a double.  That is likely why you are getting your error.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions

  • Scan from string and extract string between delimiter

    Hello,
    Basic questions.  Is it possible with the scan from string regular expression to extract the string that are within the specified delimiters.  Here is an example:
    \\Name of folder 1\Name of folder 2\Name of folder 3\File Name
    Can the scan from string output the following by specifying the right regular expression:
    Name of folder 1
    Name of folder 2
    Name of folder 3
    File Name
    I have tried \\\\%s\\%s\\%s\\%s but the %s stops at the first white space.
    Thanks,
    Michel
    Solved!
    Go to Solution.

    RavensFan suggested the appropriate function for your requirement, however you can also use an alternative, which is 'Spreadsheet String To Array'.
    I am not allergic to Kudos, in fact I love Kudos.
     Make your LabVIEW experience more CONVENIENT.

  • Scan from string to Bundle by name

    I would like to take the output of "Scan From String and feed it into a Bundle by Name. There is no pre-existing bundle so I wonder if I can use a Cluster constant for the Input cluster. If so how is the cluster constant defined.
    My goal is to read strings from ini file sections, split out names and limits and put them into a cluster or array of clusters that can be stored as TestStand Locals or FileGlobals.
    Thanx,
    jvh 
    Solved!
    Go to Solution.

    jvh75021 wrote:
    There is no pre-existing bundle so I wonder if I can use a Cluster constant for the Input cluster. If so how is the cluster constant defined.
    This is a very common thing to do upon initialization - bundle things up into a cluster and carry it around to use throughout the program, in sub-vi's, etc. I'm glad you're not just throwing them all into locals or globals!
    Yep, you'll just use a Cluster constant into the Bundle the first time it's bundled. To make that initial cluster constant, take your known output cluster just create > constant. So to answer your question, the cluster constant is defined by the known output.
    However, if this cluster ever changes during development, and it will , you'll be changing every single cluster inside sub-vi's and that initial constant... or.. you'll follow Ben's advise and make a TypeDef!
    Message Edited by Broken Arrow on 04-09-2010 03:22 PM
    Richard

Maybe you are looking for

  • When adding event in iCal, the event becomes full-day by default. How to change?

    Also, when de-clicking full-day the events becomes timed 10am-6pm. When changing start time, the end time follows with this 6 hr gap. Not the worst problem to deal with in this world, but...still.  Any way of changing this little detail? I.e. to be a

  • How do I get sound working again on macbook air?

    Hi all My sound has stopped working on my Macbook Air. I've tried restarting and visited System Preferences/Sound but to no avail. Can you help? Thanks Susie

  • Special TEXT doesn't appear as it should when published

    I used a spiffy font on my website, but after it's published, it doesn't show up on Mac or PC. It reverts to some arial-type font. I used to be able to keep the font by putting a shape over it and making it opaque, but I don't remember exactly how I

  • Javamail - no pop3 provider

    Hello, i have a problem with the javamail-1.3.1 API within the Oracle 9i (9.2.0.3) on Linux. I would like to retrieve a POP3 account and process the incoming mails within a Java Stored Procedure. I uploaded the javamail classes (imap.jar, mailapi.jar

  • Custom z-table

    Hi all, I am designing a custom z table. I need a comment field in that. so can any one suggest me anything which is already there in sap, so that i can use it for comment. PLEASE HELP, ITS URGENT.........