Writing binary to file with 24 or 32-bit numbers

I am using an NI4472 DAQ to sample some analog data at 24-bits and I want to write the data to disk. However LabView only has a VI to write 16-bit data to disk. Is there a way to write 24 or 32 bit binary numbers to a file?

The VI you are looking at is probably one of the "Easy VIs" that is setup for a specific application. You can create more general programs to write a binary file with any data type you desire. I would recommend taking a look at the Write Binary File example that ships with LabVIEW. It shows a more general approach to writing data to a binary file. In this example they write double precision numbers but you could easily replace the data with I32s.

Similar Messages

  • Writing binary .raw file

    Hi 
    I am facing problem with writing binary file as .raw file. I have attached my VI please let me know whether I am mistaking with creating and writing files. I will appreciate your help. 
    Thanks 
    Attachments:
    writing_binary file.vi ‏67 KB

    Your actual writing of the file looks fine to me.  If you wanted to make it a little simpler, you could actually not use the File Open and the File Close functions.  You can wire the path straight into the Write Binary File and if you don't wire the file reference out, it will close the file.  Were you having problems with something?
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Writing a report file with specific information

    Hi, all:
    I need to write a text file with specific information in it. I'm going to copy it into Excel, so the easier the format, the better (perhaps CSV format?). I've never done this before, so here's the method I need to capture the information from:
         public void step() {
              greenColorStorage = new ArrayList();
              magentaColorStorage = new ArrayList();
              System.out.println( "==> Model step " + getTickCount() );// Checking step #
              for (int i = 0; i < soldierList.size (); i++) {
                   Soldier s = (Soldier) soldierList.get (i);
                   s.step();
              Collections.shuffle(soldierList);
              System.out.println("Shuffling collection now.");
              dsurf.updateDisplay ();
              System.out.println("Model.step() finished.");
              for (int i = 0; i < soldierList.size (); i++) {
                   Soldier s = (Soldier) soldierList.get (i);
                   if (s.getMyColor() == Color.green ) {
                        greenColorStorage.add(s);
                   if (s.getMyColor() == Color.magenta ) {
                        magentaColorStorage.add(s);
              if (magentaColorStorage.size() == 0 || greenColorStorage.size() == 0 ) {
                   stop();
         }In this method, I need to capture this information: There are soldiers on the Green team and on the Magenta team. I need to know how many there are originally, how many in this time step, at what time step the model stops, and how many of the winning color team are left when the model stops. How do I do this? If you can point me to a specific thread that shows how to write a report file like this, I'd be grateful, since I couldn't find one when I searched. Otherwise, I'd be grateful for examples. I'm in the middle of doing some research, and I have the feeling that I'll need to write report files in the future, so if you'd explain any code you provide, I would be quite grateful--I need to understand what I'm doing as well as simply using your code so that I can really learn what I'm doing when I do this again. Thanks very much!

    FileOutputStream
    public FileOutputStream(File file,
                            boolean append)
                     throws FileNotFoundException
    Creates a file output stream to write to the file represented by the specified File object.
    If the second argument is true, then bytes will be written to the end of the file
    rather than the beginning.
    */

  • Opening a binary data file with a local java application from a weblink...

    I don't know if this is the right forum for my query, but I would like to be able to click on a data file from a download link on a webpage and be able to have the file "open" into the java application that processes the particular file (as opposed to selecting the "save to disk" option or having the browser display a bunch of funky characters). If the application is not already running, have an instance start up and process the data file and display the information. What steps would I need to take to get this to happen? The application is executed in a windows environment through executing a .bat file and not an executable .jar file. Any thoughts? TIA!

    This is entirely a matter of configuring the Windows file associations so that files with that extension are started using your designated process. Depending on the particulars you may be able to establish the association from the context (right-click) menu, or you may need to use Folder Options rom the Control Panel.
    In any case, this is a not a Java question, but Windows; if further help is needed you should go to a Windows help site.

  • Help in writing to a file with newline facility

    I am using the RandomAccessFile class to write to a file.
    The content i am writing to the file is of the form
    KEY=VALUE.
    I am writing several key value pairs like this.
    Everytime I write a KEY=VALUE it should be in a new line.
    So, what should i do to write in a new line everytime.
    Please help.
    Thanks in advance.

    Well the square most likely is just a non-printable character. If you are on windows the line.separator is \r\n (0x13 and 0x10) some file editors show the \n as a "square" as the only expect a \r its just how you interpret the file.. you can't atually do anythign about it as it isn't "wrong" if you skip the \n some programs might not see it as a newline. If you add it some may display a square.. Its the great gift of different OS's using different line separators..
    HTH
    Lima

  • How do I import binary data files (with header info) into DIAdem?

    We have lots of data acquired by nCode datagate. Files are binary data with header info. How do I import this into DIAdem? Typical (short) file attached. Also of interest, can I stream data from Sony PC208/SIR1000 recorders?
    Attachments:
    Propshft.dac ‏4 KB

    I have successfully imported your file into DIAdem using the nCode file filter included with DIAdem. You might have to make that file filter known to DIAdem by following these steps (this assumes you have version 8 of DIAdem):
    1. Go to the 'Window' menu in DIAdem and select 'Close all'
    2. Go to the 'Settings' menu and select 'GPI-DLL Registration'
    3. Click the 'Add' button in the window and select the 'GfSnCode' DLL in the 'DIAdem/AddInfo' directory
    4. The program will prompt you to restart.
    5. After you have restarted DIAdem, go to the DATA icon, select 'File - Open' from the DATA menu and in the dialog that appears, choose 'nSoft Data File Format' in the 'Files of type:' field.
    6. Select your data file and load
    That's it.
    With regards to your Sony reco
    rder data, I would need to get my hands on an actual data file to try it out. In general, DIAdem can import ANY binary file format by creating a header in the 'File - Import via header' section in DATA. If you have lots of data files from the SONY recorder, a DLL can be created for that specific file format with the free DLL toolkit included with DIAdem.
    Leave me a message here if you have any additional questions.
    Otmar
    Otmar D. Foehner
    Business Development Manager
    DIAdem and Test Data Management
    National Instruments
    Austin, TX - USA
    "For an optimist the glass is half full, for a pessimist it's half empty, and for an engineer is twice bigger than necessary."

  • Writing in existing file with applet

    hi,
    i tried the following code after reading one of sun's tutorials:
    public void fWriteFile(){
              File f = new File(fileName);
              DataOutputStream dos;
              try{
                   dos = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(fileName)));
                   dos.writeChars(Lang1+";"+Lang2+";"+Lang3+";"+Lang4+";"+Lang5);
                   for(int i=0;i<wbVec.size();i++){
                        StringTokenizer lastTok = new StringTokenizer((String)wbVec.elementAt(i),";");
                        lastTok.nextToken();
                        lastTok.nextToken();
                        String deu = lastTok.nextToken();
                        String eng = lastTok.nextToken();
                        dos.writeChars(deu + ";" + eng + "\n");
                   dos.close();
              }catch(SecurityException se){
              }catch(IOException ioe){
    and now i am confused since the apllet just doesnt write anything in the ... file

    it's a dictionary, i read the entries from and in case
    some changes were made they need to be saved... as far
    as i knew the applet had rights on a local system but
    not over the web...Nope. Think about it... What if someone wrote a malicious applet, and put it on the web. Then you go to their site, and they trash your file system.
    You'd have to make the applet a "trusted" one to do that, though I'm not here to answer questions about how that's done. Search the forum or other sites.

  • Selective combining between files with odd and even numbers of pages

    Hi all! First of all, i hope this is the right forum for my question. It has been asked before, but not fully answered. My problem is combining multiple pdfs with adding a blank page only to the ones that contain odd numbers of pages, the ones with even numbers should be left alone. I need a fast and automatic way of doing this so i can save huge amounts of time when faced with massive numbers of files. If this simply cannot be done, is there a way of sorting all the files so that, from the whole group, only the ones with odd numbers of pages go to a specified folder? Like this isnt enough i have the same problem when converting, lest say, multiple word files into 1 pdf file using pdf factory.
    Thanx in advance! also, any other way to go arround this problem is most welcome!
    Cheers!

    It would require knowledge of some JavaScript to determine if a particular page was landscape and if so, to rotate it. You could try asking in the JavaScript forum.

  • Writing 16bit bibary stream to file with 12bit steam

    I need to write binary to file with 12bit stream.
    What do I need to do?
    Thanks in advance

    Hi park,
    you have to do some bit operations with your words and splitting words into bytes.
    Assuming you want the low 12 bit of your 16 bit word (U16) you have to do the following:
    With odd words AND it with 0x0FFF. Then use Split number in the Advaced>>Data Manipulation palette to get the low and high byte.
    With even words AND with 0x0FFF. Shift the word 4 bits to the left. Then use split number to get the low and high byte. OR the low byte to the high byte of the odd word.
    Concatenate the three bytes (low byte of odd word, the ORed byte and the high byte of even word) to an array of U8.
    Waldemar
    Waldemar
    Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
    Don't forget to give Kudos to good answers and/or questions

  • Recover files with no Time Machine Backup and disk 'can't be repaired'

    My Macbook Air (Mac OS X 10.7.4) was acting funny for a few days (crashing Safari, crashing Mozilla, crashing other third party software, requiring reboot, etc.). When I tried to reboot it, a loading bar and a rotating wheel came, but got switched off. It happened every time I tried. I got into Recovery mode (by pressing Command + R) to fix the disk. The disk could not be fixed. I tried reinstalling MacOSX, but it is not showing any disk to reinstall the OS in. I do not have Time Machine On.
    I have some really important pictures and documents in the Mac. I want to save these files before I erase the whole disk. Any advice?
    Thank you!
    TL;DR
    Mac dies while booting
    Disk can not be fixed
    Shows no disk to reinstall the MacOSX in
    Never switched on the Time Machine
    Want to save important files before deleting whole disk

    One of the data recovery apps needs to be run on the disk.  You have some options, none good:
    • Take your Mac to an AppleStore (make a reservation at: http://www.apple.com/retail/geniusbar/), or an Apple Authorized Service Provider (start here to find one: https://locate.apple.com/country).  They won't run the recovery, but can tell if the drive is physically damaged.  If so, and your Mac is under a year old, or covered by AppleCare, you won't have to pay for the replacement, but be sure to get the old drive back.  It can then be put into an enclosure, making it an external HD for use with one of the other options:
    • Take your Mac (or the drive) to a recovery service.  They'll charge a large fee, and return an external HD with whavever data they can recover.  You'd then need to erase the internal HD, install OSX, and try to reassembe your data from the external.
    • Do it yourself. Buy an external HD (better, get two: one 3-4 times the size of the data on your Mac) and do it yourself.  You'll install OSX on it and run from it to recover whatever data you can to the other external:
    Start from the Recovery HD and format them both for a Mac (even if they say Mac Ready).  See #1 in Using Disk Utility if you're not sure how to do that.
    Then install OSX on one of them.  When your Mac restarts, it will start from the external, and you'll set up a user account, etc, just as with a new Mac.  When it starts again, you'll be running from a "bare-bones" system on the external HD. 
    Get one of the data recovery apps, install it on the external, and follow it's instructions to try to recover your stuff to the other external.  As noted in the yellow box in the link above, you may get a lot of the orginal folder structure back, so you can just drag things to the proper location on the external you're running from.  But you may find some or many files with partial names, perhaps numbers, etc.  Some may have extensions you can identify (such as .png or .jpg), some may not.  Try to open them and see what they are.
    If you don't recover a lot, and are willing to spend yet more $$, you might try a different recovery app -- often one will recover things a different one can't. 
    When you've gotten everything you can off the internal HD, reformat it, then "clone" the external OSX drive to it and restart from the internal.  
    Then start making regular backups. If you want to use Time Machine, erase and use the one thats 3-4 times the size of the data it's backing up.
    Also make periodic "secondary" backups to the other drive.  See Time Machine - Frequently Asked Question
    #27 for an explanation and some suggestions.

  • Binary file with header

    hi,
    i want to read a binary file in Diadem, which i saved it with Labview. But i didnot get it.
    Could you please help me?
    my header files looks like:
    1 bit double,
    128 bit U8,
    1 bit unsigned word,
    1 bit dbl
    16 bit U8
    64 bit U8
    1 bit u32
    1 bit i32
    and 100 bit Data.(i16)
    Thanks.
    Attachments:
    CH1_07_09_2007_13-31-14.csv ‏1 KB

    Hi Hakan,
    There were several issues with your VI, and the VI bore very little resemblance to the list of binary header items you included in your first post.  I decided to follow the VI instead of the earlier binary header property list.  In the VI, I changed the data type of your channel name property zero-padding from I32 to U8.  I changed the byte order of your binary header to match the byte order of the bulk data (Big Endian).  I also changed the file creation function to "create or replace" so that I culd run the VI multiple times and overwrite the same data file.  The DBL that you are writing from the LabVIEW date/time wire is a geography-specific number of seconds since January 1st 1904 (in Greenwich England).  I added a routine to the DataPlugin to decode this into a DIAdem geography-independent date/time property based on my current location in the Central time zone.  You could instead save a geography-independent DBL in the VI, which would probably be a more robust approach.
    I assigned all the header properties to the Channel level, though you probably want to copy them to the Group and/or the File level as well.  I suspect that the 3 DBL properties have something to do with the I16 channel vertical scaling or else the time scaling (aquisition rate).  We could add that to the DataPlugin as well.
    Brad Turpin
    DIAdem Product Support Engineer
    National Instruments
    Attachments:
    Hakan_S.zip ‏19 KB

  • Writing binary data to a file without carriage returns every 512 bytes

    Is there a VI for writing binary data to a file without carriage returns being inserted every 512 bytes?
    Thanks

    Hi Momolxg,
    I could be way off on this. I tried to simulate what you've done by
    making a for loop that would run a set number of times. For my example I
    used 1025. I wired the iteration terminal to a 'Write to SGL File.vi'
    outside the loop with indexing enabled. It wrote the SGL data from 0 to
    1024 to the file. I then read the file with a 'Read Characters from
    File.vi' and searched the output for a carriage return (0D hex). It was
    found five times. The reason why was the SGL number it was reading had a
    13 (0D hex) in it. Perhaps you're running into a similar problem?
    I tried it again, this time using the 'Write to I16 File.vi'. The
    carriage return was found five times: the 28th character the first time
    then on the 512th character four consecutive time
    s after that. I suppose
    that makes sense that you'd find a 0D in the numbers at equal spacings if
    they're incrementing this way... In this case the carriage returns you're
    seeing are actually numbers from your data.
    One big difference is that I'm using a set pattern of numbers. This
    doesn't appear to be your case. Is there a better way we can duplicate
    your problem? It sounds interesting. Again my simulation could be way
    off. (I'm also running this on LV60 for Linux so my results could be
    different)
    - Kevin
    In article <[email protected]>,
    "momolxg" wrote:
    > Is there a VI for writing binary data to a file without carriage returns
    > being inserted every 512 bytes? Thanks

  • Can't decrypt binary file with PBE

    Hi,
    I'm writing an simple file transfer application using UDP that encrypts the data
    before sending it with PBEWithMD5AndDES. Text files are encrypted and
    decrypted fine, but binary files such as a JPG/EXE/DOC... are messed up
    and an application can't open them on the other side. Has anyone experienced
    such a problem?
    Thanks

    Below are my encrypt and decrypt functions.
    Thanks in advance.
            public  byte[] encrypt(byte[] data)
                 PBEKeySpec pbeKeySpec;
                 PBEParameterSpec pbeParamSpec;
                 SecretKeyFactory keyFac;
                 ByteArrayOutputStream b=null;
                 DataOutputStream d =null;
                 //      Salt
                 byte[] salt = {
                           (byte)0xc7, (byte)0x73, (byte)0x21, (byte)0x8c,
                        (byte)0x7e, (byte)0xc8, (byte)0xee, (byte)0x99
                 //      Iteration count
                 int count = 1000;
                 // Create PBE parameter set
                 pbeParamSpec = new PBEParameterSpec(salt, count);
                 try{
                      pbeKeySpec = new PBEKeySpec(sessionPassword.toCharArray());
                      keyFac = SecretKeyFactory.getInstance("PBEWithMD5AndDES","SunJCE");
                      SecretKey pbeKey = keyFac.generateSecret(pbeKeySpec);
                      // Create PBE Cipher
                      Cipher pbeCipher = Cipher.getInstance("PBEWithMD5AndDES","SunJCE");
                      // Initialize PBE Cipher with key and parameters
                      pbeCipher.init(Cipher.ENCRYPT_MODE, pbeKey, pbeParamSpec);
                      b = new ByteArrayOutputStream();
                      d = new DataOutputStream(b);
                      // create CipherOutputStream
                      CipherOutputStream out = new CipherOutputStream( b, pbeCipher );
                      // write contents to file and close
                      try {
                           for ( int i = 0; i < data.length; i++ )
                                out.write(data);
                             out.flush();
                        out.close();
                   // handle IOException
                   catch ( IOException exception ) {
                        exception.printStackTrace();
              catch(Exception e){}
              return(b.toByteArray());
         public byte[] decrypt(byte[] data)
              PBEKeySpec pbeKeySpec;
              PBEParameterSpec pbeParamSpec;
              SecretKeyFactory keyFac;
              byte[] decryptedData=null;
              //      Salt
              byte[] salt = {
                        (byte)0xc7, (byte)0x73, (byte)0x21, (byte)0x8c,
                        (byte)0x7e, (byte)0xc8, (byte)0xee, (byte)0x99
              //      Iteration count
              int count = 1000;
              // Create PBE parameter set
              pbeParamSpec = new PBEParameterSpec(salt, count);
              try{
                   pbeKeySpec = new PBEKeySpec(sessionPassword.toCharArray());
                   keyFac = SecretKeyFactory.getInstance("PBEWithMD5AndDES","SunJCE");
                   SecretKey pbeKey = keyFac.generateSecret(pbeKeySpec);
                   // Create PBE Cipher
                   Cipher pbeCipher = Cipher.getInstance("PBEWithMD5AndDES","SunJCE");
                   // Initialize PBE Cipher with key and parameters
                   pbeCipher.init(Cipher.DECRYPT_MODE, pbeKey, pbeParamSpec);
                   Vector fileBytes = new Vector();
                   ByteArrayInputStream b = new ByteArrayInputStream(data);
                   CipherInputStream in = new CipherInputStream( b, pbeCipher );
                   byte contents = ( byte ) in.read();
                   while ( contents != -1 )
                        fileBytes.add( new Byte( contents ) );
                        contents = ( byte ) in.read();
                   in.close();
                   decryptedData = new byte[ fileBytes.size() ];
                   for ( int i = 0; i < fileBytes.size(); i++ )
                        decryptedData[ i ] = (( Byte )fileBytes.elementAt( i )).byteValue();
              catch(Exception e){Gui.chatArea.append("exception:"+e+"\n");}
              return(decryptedData);

  • IO error writing block to file  (Apex 4.01, 11gR2, RH 64 bit & Using Gatew

    I have Apex 4.01 running on a Linux Red Hat 64 bit server and the database is 11gR2. I'm using the gateway and receiving numerous io errors on files that do not exist in the database. Has any one else experienced this? Should I scrape the gateway and load https ?
    File 201 does not exists in the database (error below). I have verified this the files do not exists using ( dba_data_files or dba_temp_files) . Is this a Gateway issue?
    I have run dbverify and there are not corruptions within in the database. We have run a disk check on the SAN and there are not issues either.
    Example of Error:
    ===========
    </msg>
    <msg time='2010-11-09T16:18:25.446-06:00' org_id='oracle' comp_id='rdbms'
    client_id='ADMIN:1753485708135952' type='UNKNOWN' level='16'
    host_id='houlnxora01d.nblenergy.com' host_addr='10.10.200.26' module='APEX:APPLICATION 4500'
    pid='26431'>
    <txt>Errors in file /u01/app/oracle/diag/rdbms/bdapx01d/bdapx01d/trace/bdapx01d_s000_26431.trc:
    ORA-01114: IO error writing block to file 201 (block # 36609)
    ORA-27072: File I/O error
    Linux-x86_64 Error: 9: Bad file descriptor
    Additional information: 4
    Additional information: 36609
    Additional information: -1
    </txt>
    </msg>

    Hello,
    I think this is a database-related problem which also occurs when using APEX, but I don't think it's caused by APEX.
    The error basically says that something is wrong with your filesystem.
    I suggest you post this error description to the forum where the experienced dbas could help you more: {forum:id=61}
    From what I know, these errors may occur when your filesystem is full or the file was deleted/moved or set offline for some other reason.
    You could get a hint for troubleshooting by locating the file on your filesystem:
    select file_name
    from dba_data_files
    where file_id=201;If it actually doesn't exist, something has messed up your data dictionary. You could then try to find out which tablespace and object/s have a hold on that file:
    select
       owner,
       tablespace_name,
       segment_type,
       segment_name
    from
       dba_extents
    where
       file_id = 201
    and
       block_id = 36609;I hope it's just the "disk full"-case.
    -Udo

  • Writing Datalog Files with record length

    How do I write a Datalog File with a record length of 128 int16s?

    Each I16 number in LabVIEW that you write uses 2 bytes because 8 bits equals 1 byte. If you write 128 numbers, the file will be 256 bytes long. You can modify the VI to write I32 (4 bytes) or I8 (1 byte) just by changing the representation of the number. You also need to change the subVI that does the actual writing (Write File+ [I16].vi). Be sure to rename the VIs that you change. I would think that your Fortran program would work as long as the data types match.

Maybe you are looking for

  • Connect older Mac monitor to new imac

    I have a 23" Apple Cinema HD Display monitor (like the image below) and I want to know what I need to purchase to connect it my my new 27" iMac.

  • I got this morning the common issue "Restore your BBM informatio​n"

    Dear BB Staff, Today this morning while I'm chatting suddenly my BBM shut-off and goes to the loading process with message "Restoring your BBM information" now it's been more than 1 hour on this status, what should I do to fix this issue? Is there di

  • Oracle Spool Fixed Width

    Hi All, I'm trying to spool records from my Oracle table into a fixed width text file. As you'll see below, I'm using the RPAD function to set the maximum width for my columns but for some reason the spool doesn't recognize the RPAD function and just

  • KEC3 - New currency translation type

    Hi, I am trying to create a Currency translation type in KEC3 with time dimension 5 'For exact date' and field name BUDAT "Posting date" . But when I save the new entry the system displays error KH297 - Field  is not a characteristic. Which could be

  • Specific CD not playing in Tiger ONLY

    My band's cd that we recently released is being spit back out in Macs that are running Tiger. I am running Panther on my Powerbook, and the cd plays fine. I am being told that once the cd is inserted a "weird noise" is heard from the drive and afterw