From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Structure of spreadsheet problem

Solved!
Go to solution

Hello all and many thanks for helping me get as far as I am, on my first LV project. I have attached my project below. My program is running good however, when it writes to my spreadsheet, it is giving undesirable affects. I open the spreadsheet with MS Excel. What I am trying to do is get all of my readings (1-5V inputs) in the same column, one-by-one under each other, beginning of course with the 1 volt. I put the transpose to "T" and it at least put them in order however, not in the same column. I have been reading the help file on it and tried a couple different things but it is having no affect. Any help would be greatly appreciated. Thank you

0 Kudos
Message 1 of 7
(2,947 Views)

The reason this is a big deal to me is because I have 3 more inputs that I need to occupy the next two columns. I just wanted to figure out how to do this for one before complicating it with more. Thanks again.

0 Kudos
Message 2 of 7
(2,938 Views)

Sorry but I found out how to fix most of it. I now have them all going in order on the spreadsheet but have one last problem. It is putting a "0" in the first cell and the last cell. What I mean is, I should have 5-cells (in Excel) with data from 5 input voltages. I have those 5 (yeahhhhh) but the first cell has a "0", as does the last one. Thank you

0 Kudos
Message 3 of 7
(2,931 Views)

The first 0 is from when you do the write from your Initialize State.

The last 0 is coming from your Re-Run State. You should also see a zero in the End state which you've commented correctly.

 

I suspect you want to move your spreadsheet writes to the inside of you state cases instead of the outside.

Message 4 of 7
(2,912 Views)
Solution
Accepted by ceilingwalker

I "simulated" your code, taking out all of the DAQ stuff, just to test Write to Spreadsheet.  The code below gave the results shown as Test Text.  In addition to the extra lines of zeros, it seems curious to me that you would want to write out the data in this manner (but there may be a very good reason for doing so).

 

I made a fairly trivial change to the code (I believe Taki made a similar suggestion) and got the output shown in Test1 Text.  If this is, in fact, what you hope to get, then you are close ...

 

CeilingWalker Demo.png

Ceiling Demo Output.png

Bob Schor

Message 5 of 7
(2,894 Views)

Thank you for all that info. Could you tell me please, when and why, would we want to use the DAQ functions? It appeared to be the easiest and most organized way of doing it. I am as "new" as new can get, with LV, so I will take any and all suggestions given. When my overall project is done, I am mearsuring the displacement of a sensor in the microns, with Voltage in and out of LV, and an LCR meter reading capacitance and resistance (impedance). In the end they must all end up on a nice excel spreadsheet. I didn't want to describe my project to much as I was afraid someone would design the entire thing for me, and I wouldn't really learn. Hope that doesn't sound arrogant. But please, any advice or info you would like to pass along, I would love it. Thanks

0 Kudos
Message 6 of 7
(2,882 Views)

The question you asked was about the Spreadsheet.  You have your Spreadsheet code "embedded" in other code that, to a first approximation, generates the numbers that are to go into the Spreadsheet.

 

The point I was trying to make (and I apologize for any lack of clarity in my exposition) was that it is sometimes easier to debug (say) a Spreadsheet question when that is all that you need to consider.  I basically took your existing code, removed the DAQ portions, made a few simplifications (like generating the arrays your code creates using the numbers 1, 2, 3, 4, 5) and seeing the result.  It was only a tool to isolate the Spreadsheet part of your code, which I thought was the topic of your post.

 

You specifically asked about the rows of zeros at the beginning and end of your Spreadsheet file.  I assume that based on what Taki said, you dragged my Snippet onto a blank LabVIEW 2014 Block Diagram, tried the modifications he suggested, and got a "more satisfactory" result (it is much quicker to test code ideas on a tiny Demo VI, especially one that doesn't need to be connected to hardware).  Now take the changes you made to make the Demo produce the Spreadsheet you like and do the same thing to your My Project 3 code.

 

Once you've got the Spreadsheet working to your satisfaction and have ported it back to your Project, you can use the Spreadsheet output to check that the DAQ code is producing the kind and type of data you expect.

 

It is often simpler to debug little pieces of code in isolation than to try to test a huge project all at once.  I say this from several years of experience, which I'm happy to pass on to you in the hopes that you will have an easier time of it.

 

Bob Schor 

Message 7 of 7
(2,869 Views)