Case Structure timing/ writing data to a excel

Hi all,
I have written a program that has the main functions of allowing the user to generate a random number between either 0-10 or 5-15 by using the labelled switch. I also have a control which can switch this function on or off. When this switch is true it will display the random number and also write this number to an excel spreadsheet every 1 second (I hope). When false this will stop displaying the number and hence not write the number to a file.
However, I am having the following issues:
1. Excel file is corrupt once I begin to write the generated numbers to the spreadsheet. (I am trying to write to a .xlsx file)
2. Once I begin to try write the numbers to file, the elapsed timer only displays the time is 1second intervals rather than the full time.
I changed the .xlsx file to a .csv file and this solved issue 1. but it only recorded one random number rather than the numbers that were generated in that time since switched on/off.
Should I have the write to spreadsheet function in the timed case structure?
Should the file path control be outside this case structure?
Have I set up the write to spreadsheet VI correctly?
If anyone could help with these issues that would be a big help.
Thanks!
Attachments:
Random Number tester.vi ‏30 KB

lneill65 wrote:
There is still an issue with the elapsed time. Once I begin I turn the top boolean control to true, the elapsed time begins changing at the set time increment inside the case structure. Is there anyway to stop this from happening?
Your elapsed time display is independent of the boolean switches because it is on the toplevel loop diagram. I am not sure why you place a five second wait inside the case structure if you want to write once per second.
I am not sure why you have two sequential case structures since the calculations of the first structure is not needed unless the other case is also true. Why not place it inside the true case?
You should also adhere to some basic coding styles. Avoid overlapping and floating objects, hidden wires, right-to-left wiring.
If it is sufficient if the code reacts once per second, just run the loop with a 1 second wait. If you don't want to display a stale random number if the switch is off, place the indicator after the case structure.
Here's a quick draft. Modify as needed. I probably would use an event structure, but let's keep it simple at this stage. You should also modify it so it does not try to write with an illegal path and also retain the selected path once selected. I propably would use a file dialog instead of a FP Path control.
LabVIEW Champion . Do more with less code and in less time .
Attachments:
Random Number testerMOD.vi ‏9 KB

Similar Messages

  • Time Stamp problem while writing data into the excel file

    Hii, All
                  I am taking the data from the DAQ card of the TOPSCCC with the 8 ms of scanrate for each channel and there are total 16 no of Analog channels in the Card, now i am acquiring the data from the card, time stamping it and writing it into the excel file, which is tab delimited, now the problem is, the data which are in the excel file have the same timestamp for 4 to 5 continuous records, instead we want each data with the different and continuous time stamp with same difference of time stamp between two records, mean if it is difference of 8 ms then it should be the 8 ms for all, but here it is taking the differnce of 16 ms for two samples and giving same time stamp for four to five records and that shouldn't happen, here i am attaching my vi, drivers for the cards and Excel file with the data, can you please give me any suggestion how to do it?
           Please help me i require this suggestion as early as possible, i am requiring it urgently.
    Thanks in Advance,
    Nishant
    Attachments:
    2026vi.llb ‏319 KB
    2026_ScanMultAD_Demo_time.vi ‏80 KB
    Data.xls ‏357 KB

    Hello Nishant,
    that's what I meant:
    Message Edited by GerdW on 05-16-2006 10:32 AM
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome
    Attachments:
    timestamp-array.png ‏2 KB

  • Writing data on to excel sheet from java

    Hi,
    I have to write a java program which writes data on to Excel sheet column by column. How to do this ?

    Use Jakarta's POI API: http://jakarta.apache.org/poi/index.html

  • Case structure and dynamic data, maybe once again

    Hi there,
    I`m a beginner in Labview. I´d like to know, how to handle the attached case-structure so that the structure works with each point of the signal.
    Right know the signal is only analyzed one time.
    Thanks for your help
    Michael
    Attachments:
    prob.jpg ‏26 KB

    Thank you Lars!!
    Now it works
    Solution is given as attachment
    Attachments:
    lsg.jpg ‏46 KB

  • Writing a java program for generating .pdf file with the data of MS-Excel .

    Hi all,
    My object is write a java program so tht...it'll generate the .pdf file after retriving the data from MS-Excel file.
    I used POI HSSF to read the data from MS-Excel and used iText to generate .pdf file:
    My Program is:
    * Created on Apr 13, 2005
    * TODO To change the template for this generated file go to
    * Window - Preferences - Java - Code Style - Code Templates
    package forums;
    import java.io.*;
    import java.awt.Color;
    import com.lowagie.text.*;
    import com.lowagie.text.pdf.*;
    import com.lowagie.text.Font.*;
    import com.lowagie.text.pdf.MultiColumnText;
    import com.lowagie.text.Phrase.*;
    import net.sf.hibernate.mapping.Array;
    import org.apache.poi.hssf.*;
    import org.apache.poi.poifs.filesystem.*;
    import org.apache.poi.hssf.usermodel.*;
    import com.lowagie.text.Phrase.*;
    import java.util.Iterator;
    * Generates a simple 'Hello World' PDF file.
    * @author blowagie
    public class pdfgenerator {
         * Generates a PDF file with the text 'Hello World'
         * @param args no arguments needed here
         public static void main(String[] args) {
              System.out.println("Hello World");
              Rectangle pageSize = new Rectangle(916, 1592);
                        pageSize.setBackgroundColor(new java.awt.Color(0xFF, 0xFF, 0xDE));
              // step 1: creation of a document-object
              //Document document = new Document(pageSize);
              Document document = new Document(pageSize, 132, 164, 108, 108);
              try {
                   // step 2:
                   // we create a writer that listens to the document
                   // and directs a PDF-stream to a file
                   PdfWriter writer =PdfWriter.getInstance(document,new FileOutputStream("c:\\weeklystatus.pdf"));
                   writer.setEncryption(PdfWriter.STRENGTH128BITS, "Hello", "World", PdfWriter.AllowCopy | PdfWriter.AllowPrinting);
    //               step 3: we open the document
                             document.open();
                   Paragraph paragraph = new Paragraph("",new Font(Font.TIMES_ROMAN, 13, Font.BOLDITALIC, new Color(0, 0, 255)));
                   POIFSFileSystem pofilesystem=new POIFSFileSystem(new FileInputStream("D:\\ESM\\plans\\weekly report(31-01..04-02).xls"));
                   HSSFWorkbook hbook=new HSSFWorkbook(pofilesystem);
                   HSSFSheet hsheet=hbook.getSheetAt(0);//.createSheet();
                   Iterator rows = hsheet.rowIterator();
                                  while( rows.hasNext() ) {
                                       Phrase phrase=new Phrase();
                                       HSSFRow row = (HSSFRow) rows.next();
                                       //System.out.println( "Row #" + row.getRowNum());
                                       // Iterate over each cell in the row and print out the cell's content
                                       Iterator cells = row.cellIterator();
                                       while( cells.hasNext() ) {
                                            HSSFCell cell = (HSSFCell) cells.next();
                                            //System.out.println( "Cell #" + cell.getCellNum() );
                                            switch ( cell.getCellType() ) {
                                                 case HSSFCell.CELL_TYPE_STRING:
                                                 String stringcell=cell.getStringCellValue ()+" ";
                                                 writer.setSpaceCharRatio(PdfWriter.NO_SPACE_CHAR_RATIO);
                                                 phrase.add(stringcell);
                                            // document.add(new Phrase(string));
                                                      System.out.print( cell.getStringCellValue () );
                                                      break;
                                                 case HSSFCell.CELL_TYPE_FORMULA:
                                                           String stringdate=cell.getCellFormula()+" ";
                                                           writer.setSpaceCharRatio(PdfWriter.NO_SPACE_CHAR_RATIO);
                                                           phrase.add(stringdate);
                                                 System.out.print( cell.getCellFormula() );
                                                           break;
                                                 case HSSFCell.CELL_TYPE_NUMERIC:
                                                 String string=String.valueOf(cell.getNumericCellValue())+" ";
                                                      writer.setSpaceCharRatio(PdfWriter.NO_SPACE_CHAR_RATIO);
                                                      phrase.add(string);
                                                      System.out.print( cell.getNumericCellValue() );
                                                      break;
                                                 default:
                                                      //System.out.println( "unsuported sell type" );
                                                      break;
                                       document.add(new Paragraph(phrase));
                                       document.add(new Paragraph("\n \n \n"));
                   // step 4: we add a paragraph to the document
              } catch (DocumentException de) {
                   System.err.println(de.getMessage());
              } catch (IOException ioe) {
                   System.err.println(ioe.getMessage());
              // step 5: we close the document
              document.close();
    My Input from MS-Excel file is:
         Planning and Tracking Template for Interns                                                                 
         Name of the Intern     N.Kesavulu Reddy                                                            
         Project Name     Enterprise Sales and Marketing                                                            
         Description     Estimated Effort in Hrs     Planned/Replanned          Actual          Actual Effort in Hrs     Complexity     Priority     LOC written new & modified     % work completion     Status     Rework     Remarks
    S.No               Start Date     End Date     Start Date     End Date                                        
    1     setup the configuration          31/01/2005     1/2/2005     31/01/2005     1/2/2005                                        
    2     Deploying an application through Tapestry, Spring, Hibernate          2/2/2005     2/2/2005     2/2/2005     2/2/2005                                        
    3     Gone through Componentization and Cxprice application          3/2/2005     3/2/2005     3/2/2005     3/2/2005                                        
    4     Attend the sessions(tapestry,spring, hibernate), QBA          4/2/2005     4/2/2005     4/2/2005     4/2/2005                                        
         The o/p I'm gettint in .pdf file is:
    Planning and Tracking Template for Interns
    N.Kesavulu Reddy Name of the Intern
    Enterprise Sales and Marketing Project Name
    Remarks Rework Status % work completion LOC written new & modified Priority
    Complexity Actual Effort in Hrs Actual Planned/Replanned Estimated Effort in Hrs Description
    End Date Start Date End Date Start Date S.No
    38354.0 31/01/2005 38354.0 31/01/2005 setup the configuration 1.0
    38385.0 38385.0 38385.0 38385.0 Deploying an application through Tapestry, Spring, Hibernate
    2.0
    38413.0 38413.0 38413.0 38413.0 Gone through Componentization and Cxprice application
    3.0
    38444.0 38444.0 38444.0 38444.0 Attend the sessions(tapestry,spring, hibernate), QBA 4.0
                                       The issues i'm facing are:
    When it is reading a row from MS-Excel it is writing to the .pdf file from last cell to first cell.( 2 cell in 1 place, 1 cell in 2 place like if the row has two cells with data as : Name of the Intern: Kesavulu Reddy then it is writing to the .pdf file as Kesavulu Reddy Name of Intern)
    and the second issue is:
    It is not recognizing the date format..it is recognizing the date in first row only......
    Plz Tell me wht is the solution for this...
    Regards
    [email protected]

    Don't double post your question:
    http://forum.java.sun.com/thread.jspa?threadID=617605&messageID=3450899#3450899
    /Kaj

  • How can I pass data generated in a SubVI inside a Case Structure out of the Case Structure?

    Hello,
    I am using a USB 2701 to control a heater.  I have three SubVIs that are all working properly on their own.  I'd like to use an Enum to select which of the SubVIs is running at a given time.  The problem is that no data is passing out of the case structure.  How can I pass the temperatures and heater outputs acquired by the SubVIs to the main VI?  I've attached my some of my code below.  I can't attach more than 3 files, but you can see how the main VI is configured.  Like I said, the SubVIs are working individually, so you shouldn't really need to look at them.
    Thank you,
    CJones581
    Attachments:
    RampHeater6-21-07.vi ‏305 KB
    69_Heater_Case.vi ‏23 KB
    HeaterTCD6-21-07.vi ‏210 KB

    CJones,
    You might check a couple of things.
    Your HeaterTCD... VI has a While loop with a stop button condition.  HeaterTCD pass out values only when it finishes running.  If it doesn't pop open the front panel (which usually doesn't happen when running a SubVI) you could run into a stuck loop because you don't have access to the Stop button.  This could appear in the form of no data being passed out (because the SubVI never stops running).  The primary VI opens the HeaterTCD VI, starts it, and waits for the VI to finish and pass final values .
    Secondary note: Unless you want your SubVI panel (which probably isn't open when running the main VI) to update continuously, consider moving your Temperature Graph and Temperature oC indicators outside the while loop.  Pass final values to them via a tunnel, since the main VI will only read their values after the loop finishes running, anyway.
    It might help to add error management to HeaterTCD like you have for RampHeater.  If you connect error lines with Error Outs to your main VI, that will help tell if there is an error somewhere that is preventing info output.
    RampHeater SubVI has the same issue with the stop button.  It is also probably getting stuck in the While loop waiting for a manual push of that SubVI's Stop button.
    An easy way to test this would be to set up a logic circuit so that when the While loop iteration counter reaches a certain number, it registers True and sends it to the conditional.  I know this isn't what you want to do long-term, but if that lets your SubVI return outputs it means that the SubVI was just never stopping.
    Hope that helps.
    David C, Applications Engineering
    David C
    Applications Engineering

  • In the attached VI I dont understand why data from the inner case structures are not being transmitted to the array.

    In the attached VI I don't understand why data from the inner case structures are not being transmitted to the array.
    Thank you.
    Solved!
    Go to Solution.
    Attachments:
    TEMP.vi ‏25 KB

    It took me some time to figure what you are trying to do but I think I have it now.
    The SR is still required.
    What is happening is your "Bundle By Name" is replacing all of the fields of the cluster, not just the value coming out of the case structure. So to maintain the cluster stuff you do in earlier iterations you can either...
    1) Put the "Index array, Bundle by name, and Replace array" inside the case structure and ONLY bundle the value you are setting in that iteration. (as you will see Tim post shortly)
    OR
    2) Move the Index array before the Case, unbundle all of the fields and feed teh case structure and run them across the case so that ALL of your output tunnels come from the coresponding input tunnel EXCEPT for the filed you are trying to set.
    Ben
    Message Edited by Ben on 05-05-2010 01:31 PM
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • How can I append some data to an array via a case structure?

    Basically i want to do the following thing:
    do
    if control=0
    else
    Data=Data append data1
    end if
    }while(run=1)
    We try to avoid local variable since the size of Data is pretty big. I am pretty sure i can add a shift register in a loop structure.But is it possible to add a shift register in a case structure?
    Thank you!

    The best you will be able to do is going to be a variation on what CC suggested regarding replacing array sub-sets.
    If you do not know how big it will end up then over-allocate but still use the replace array subset.
    The delays you are seeing are due to the memory buffers groing and additional memory need allocated as the array grows. The Replace array subset function operates inplace and re-uses the buffer it is passed. There is no clear KB regarding which array operations operate inplace and which do not.
    http://forums.ni.com/ni/board/message?board.id=170&message.id=74847&requireLogin=False
    Under Tools >>> Advanced >>> Show buffer allocations will show you where buffers are being allocated (LV 7.1).
    If you post a zip or llb of you code I am sure someone will have more to add.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Problem in writing data to excel spread sheet using jdbc

    Hi Friend,
    I have written a jdbc application ,that retrives data from oracle8i database and writes to excel spread sheet.
    Here I am facing a problem while writing date vales to the spread sheet.
    It is just writing 00.00.0 , instead of a date like 21/10/2005, where I am going wrong , can any one guide me.
    Thanks in advance.

    Don't cross-post!
    http://forum.java.sun.com/thread.jspa?threadID=643815&tstart=0
    Especially when you already got your answer in the other post jackass. If you don't understand the answer then say so there.

  • Facing problem in writing data to excel sheet using ActiveX

    Hi.
    I want to write data from a one dimesional array to a particular excel sheet in a particular row.Please see the attached vi for explantion.
    It is giving error.But If I give a new file name when the appliation is getting closed it is writing data to the new excel file.
    Please help.
    Thanks in advance
    Attachments:
    Excel sheetWrite.vi ‏90 KB

    Thanks Jhoskin and Rudi .......
    I am able to write data to excel sheet now. I am attaching one"test.zip" file that contains a VI named "Squence.vi "that contains another subVI named "Write U94006 Table To XL.vi"which does the functionality of counting the number of rows in the excel sheet and writing data in the next blank row. I am using the same subVI in the VI named "Sequence.vi"two times so it is taking a lot of time in opening and closing the excel sheet. Will you please suggest some way of calling the subVI only one time.
    Rikki
    Attachments:
    Test.zip ‏105 KB

  • How extract data from case structure

    Hi all, I would like to extract the data from case structure, it's circled in red in the attached file. How should I do it? Thanks for taking your time to look at my post. Your help is greatly appreciated.
    Attachments:
    bp.jpg ‏161 KB

    Thank you guys for your prompt reply.
    As u can see from the vi, there's an error, I need the values in the circled area to be passed on to the block ( Bundled by name)
    Thanks !
    Attachments:
    fyp_bp_only.vi ‏90 KB
    fyp_bp_only.vi ‏90 KB

  • Data stopping at case structure

    When the block diagram operates, the only data saved to the spreadsheet file are sets of 0.00000.  I assume this means that my data is not getting into the case structure, and that the array is adding data of 0 each iteration.  What problems am I having with data-flow? Here is the attached file, the structure I am inquiring about is on the right side.
    Thanks
    Attachments:
    Ben_Diamond_iteration.vi ‏402 KB

    Are you sure you are getting any data out of your scope functions?
    Try putting probes on all the wires that make up your data and see what they are showing while your VI is executing.

  • Writing to 6 variables consecutively in 3 steps (Case Structure?)

    I have two inputs which, on three different occasions, have different values. So my data input can be split up into three sets of two inputs.
            When the first set of data is sent, the two inputs are processed and stored in indicator 1 and 2.
            When the second set of data is sent, the two inputs are processed and stored in indicator 3 and 4.
            When the third set of data is sent, the two inputs are processed and stored in indicator 5 and 6.
    Unfortunately I can't go around this by using 6 different inputs. I need to have two inputs only in the beginning.
    I've attached a file where I tried to do this with a case structure. However, the output tunnels are unwired in some of the cases, and I'm afraid that they'll assume new values and won't retain the values that the inputs sent to them.
    Any help is helpful... naturally.
    -Alex
    Attachments:
    problem.vi ‏16 KB

    You could do something like below.  Use a Ring to choose which case (adds a bit of error checking for you), Case 1 = 0, Case 2 = 1 Case 3 = 2 etc.  Wire the output of the Ring through the case structure as well as your mathematical operation, then build an array out of your 2 indicator outputs and insert them into a 2 day array.  This way the output for Case one is stored at index zero of your Value Holder Array, output for Case two is stored at index 1...
    Dont know if this is what you were looking for, it is just one way to keep track of all your outputs.
    Message Edited by jmcbee on 07-11-2008 10:40 AM
    CLA, CLED, CTD,CPI, LabVIEW Champion
    Platinum Alliance Partner
    Senior Engineer
    Using LV 2013, 2012
    Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.
    Attachments:
    Problem.png ‏11 KB

  • Timed sequence with individual​ity for case structures

    Hello All
    The attached vi is one that I found by trolling on the forum, and made some slight modifications to it.
    If you look at the BD, you can see that the timing between the action of each case structure is the same.
    I would like to modify it even further and have each case structure have its' own individual time control.
    I can do this by using a sequence and place a wait in each frame.
    Would this method be both suitable and the simplest ( I have been giving some thought to using one case structure, but this solution eludes me at the moment)
    Regards
    Ray
    Attachments:
    TabAutoScroll.vi ‏16 KB

    Single case, single property node, single wait.
    Attachments:
    TabAutoScroll_mod.vi ‏9 KB

  • Passing data in case structures Labview 6.1

    I have a simple case structure consisting of 4 frames inside a while loop. I want to pass data from the 3 cases thru the while loop and display on indicators.
    After running the vi only data from the last case is displayed on the indicator.
    How do I pass data from each case to the indicators?
    Attache dis the simple vi to show the problem.

    Using Local Variables is almost never the way to go. Sometimes they can't be avoided, but most of the time there's another way.
    I've modified your example a bit. The new loop below your original one will do the same thing, but without using variables. The For loop automatically indexes through the array and will process each element. The Shift Registers pass data from iteration of the loop of the next, so the values from the first iterations will stay around so they can passed out of the loop.
    Ed
    Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
    Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
    Attachments:
    LoopTest1_using_For_Loop.vi ‏58 KB

Maybe you are looking for

  • Labview with Vista 64 bit native support

    I'm waiting day after day to see a new Labview release supporting Vista 64 bit (I mean running at 64bit natively and not in a 32bit emulation layer). I expected it last year... then I waited believing that of course... it'll come soon... but now I'm

  • Final Cut Pro HD wont output to an external monitor?

    I,m trying to monitor my work on the projector it will be presented on. My camera wont recognize the outputted PAL signal although I can import material from the camera. It worked very briefly then stopped so I've bought a Pyro A/V Link to stand in f

  • Clearing buffer on HP4 LaserJet

    I am having issues with my HP4 laserjet.  It will not stop printing junk and using lots of paper.  I do not know how to set the printer back to factory settings.  Is there anyone out there that knows how?

  • IMovie '11 will not display edited versions of photos from iphoto

    After editing some photos in iPhoto, iMovie displays in the preview window the edited photo, but once placed on the timeline, it reverts back to the unedited original version. Any ideas what's going on? Ultimately, after creating a slideshow of photo

  • No updates for N82 after 35.0.002

    Did Nokia stopped its support for N82 after 35.0.002 ?