04-14-2012 01:06 AM
I’m having trouble with signal incompatibilities from the output of a “Collector” within a ‘Control & Simulation’ structure. I have tried various ways however I’m unable to build an array with the data that I need. Attached is the program that I’ve built so far with the problem.
What I’m trying to achieve is as follows,
Append the outputs from the ‘Discrete State-Space’ function to the input data (Q1, Q2, Input uk) to build an array and output this to a spreadsheet file. I believe that the outputs from the ‘Discrete State-Space’ function (namely Output, yk and States, xk) each contain 3 values for each step simulation computation. The ideal target array and spreadsheet file needs to be formatted as follows (columns):
States, xk Inputs, uk (q1, Q2) Outputs, yk
x1 x2 x3 u1 u2 y1 y2 y3
Containing the set of 1000 values for x1, x2, x3, u1, u2, y1, y2, y3.
Any help or assistance would be greatly appreciated.
Solved! Go to Solution.
04-16-2012 11:55 PM
Hi Bunnykins,
I haven't been able to run your VI, as I do not have the simulation data file you are using, but I think the easiest way to go about this would actually be to enable the "append" control on the write to spreadsheet file.vi, move it into the main loop, and use it to append a new row to the text file during every iteration of the loop. You'll have to combine your u, x, and y vectors into one vector before writing to the file, but that's relatively straightforward and can be done with the insert into array function. I've attached an example VI that I built that should combine multiple user-specified vectors into one vector and append it to a designated text file every time the vi is run, which you might find useful. If you're using vectors of different lengths, you'll need to alter the insert into array index.
Disclaimer
The attached Code is provided As Is. It has not been tested or validated as a product, for use in a deployed application or system, or for use in hazardous environments. You assume all risks for use of the Code and use of
the Code is subject to the Sample Code License Terms which can be found at:
http://ni.com/samplecodelicense
04-22-2012 01:20 AM
Unfortunately the proposal that you suggested doesn't work either, unless I'm doing something wrong?
I've attached an implementation that you suggested however this just gives the following results to the spreadsheet file:
0.0000.0000.2390.1480.170
0.0000.0000.2390.1480.170
0.0000.0000.0000.0000.000
0.0000.0000.0000.0000.000
etc. (all zeros)
I do not appear to be able to create the array of values, they just appear to over-write each other. I've tried various methods and ways all without success. I've tried indexing on the Simulation Time function since this appears to increment in seconds and I though that this may be a good way of indexing the array however it doesn't work.
I also tried using a "Collector" however when the output of the collector is connected to array functions it just comes back with signal incompatibilities (I guess because the data value of the collector also has time value bound to it?).
Any further suggestions would be helpful. I find it extremely frustrating that a relatively simple procedure cannot be 'easily' implemented in LabVIEW, I know what I what to achieve however getting there appears to be a mammoth task.
Regards,
04-22-2012 10:47 PM
Since the last post I have now managed to figure out how to configure the "Write to Spreadsheet" vi function and have obtain some reasonable results although I was puzzled why I have a repeated data set right at the end and cannot sort this one out.
The next problem that I have concerns using a 'Case Structure' within a Control and Simulation structure, is this permitted ? With reference to the attached vi I have managed to place a 'Case Structure' within the Control and Simulation structure however when I then configure what I want it to do the following error message is displayed:
* Block Diagram Errors
Case Structure : Block diagram terminals are not allowed inside Case structures on simulation diagrams.
What I am trying to achieve is to manipulate the incoming data vector value at simulation time 327 seconds to simulate a fault in the data. My idea was to use a 'Case Structure' triggered on Simulation time value 327 seconds to adjust this single vector value. If a 'Case Structure' is not permitted is there any other way that I can achieve my requirement within the Control and Simulation structure ?
Regards,
04-23-2012 08:55 AM
Hello Bunnykins,
Glad to hear that you were able to figure out the array manipulation! If you could post the results you are currently seeing (the output array), I may be able to point out why there are duplicate columns at the end.
You should be able to use a case structure within a simulation loop; however you cannot include front panel controls or indicators (a.k.a. terminals) within the case itself. You should be fine if you move your "Fault Q1&Q2" indicator outside of the case.
04-24-2012 05:48 AM
Many thanks Tom,
I've now sorted out the Case structure within the Control and Simulation Structure and this appears to work ok now.
The repeated data items were in the last Row (not repeated Columns), it seems to add one extra row at the end with identical values. I tried adjusting the Simulation Time however it always adds a repeated data row at the end regardless.
Thanks for your help, I appreciate it.
Regards,
04-25-2012 01:14 PM
Based on what you've described, it's almost certain that the loop is executing an extra time at the final state; you may be able to use a Halt Simulation VI to stop it at the time specified.