LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Script for creating cases for Case Structure

Solved!
Go to solution

Hello,

I need some help. I am creating a battery emulator that consists of 3 power supplies controlled through LabVIEW. Each supply represents one cell, and its output voltage is set according to the emulated battery capacity. The capacity is calculated in LabVIEW from current and simulation time.

The capacity–voltage data are taken from the datasheet. I export them with a web tool into a text file, which contains pairs of capacity and corresponding voltage values (see Picture 3). At the moment, I manually rewrite these values into a Case Structure, as shown in Picture 1 and Picture 2.

My question is: Is there an easier way to create this case structure than rewriting all cases by hand? For example, can the Case Structure be generated automatically from a file, or is there a better LabVIEW approach for this task? Just to keep 2-digit precision, I need to write around 120 separate cases (4.20 V - 3.00 V).I would also like to emulate curves for different discharge currents, which would multiply the number of cases even more.

 

Thanks a lot in advance for any advice.

 

Picture 1 and 2: Case structure with capacity ranges and corresponding voltages

Picture 3: Example of exported text file with capacity–voltage pairs

Picture 4: VI graphical interface

 

Best regards AlgrunNos

Download All
0 Kudos
Message 1 of 9
(398 Views)
Solution
Accepted by topic author AlgrunNos

Hi Algrun,

 


@AlgrunNos wrote:

My question is: Is there an easier way to create this case structure than rewriting all cases by hand?


Sure!!!

Why do you insist on using a case structure at all?

Why not use the Interpolate1DArray function on an array of points???

 

Suggestions:

You can implement either interpolating or "stepped" output behaviour!

(You need to implement some more error checking, like using InRangeAndCoerce to handle invalid inputs…)

 

Why don't you attach real data? Do you know we cannot debug/edit/run images with LabVIEW?

Why do you make it so hard to help you by attaching just some images?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 9
(386 Views)

Don't use case structures (which are excessively deep).

Just make a lookup table that gets filled in with info from the datasheet.

0 Kudos
Message 3 of 9
(291 Views)
Solution
Accepted by topic author AlgrunNos

@GerdW wrote:

 


Suggestions:

 


You can use Interpolate array on an array of clusters? 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 9
(274 Views)

Hi Yamaeda,

 


@Yamaeda wrote:

@GerdW wrote:

 


You can use Interpolate array on an array of clusters? 


It is an array of points!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 9
(269 Views)

@Yamaeda wrote:
You can use Interpolate array on an array of clusters? 

Yes, "index&bundle" creates an array of points. Very useful! Without that, we need quite a bit more code for the same functionality.

(Of course the points need to be sorted in X.)

 

altenbach_0-1756305805214.png

 

0 Kudos
Message 6 of 9
(233 Views)

@altenbach wrote:
Without that, we need quite a bit more code for the same functionality.

Well, it is just a little bit more code and I am never quite sure what's more efficient 😄

 

altenbach_0-1756307352554.png

 

Message 7 of 9
(228 Views)

Thank you very much for your help. I’m sorry, I didn’t mean to make it difficult to read. The original VI is quite complicated, and I just wanted to extract the part with the problem. Next time, I’ll try to make a separate VI focusing only on the issue. That would probably be better.

0 Kudos
Message 8 of 9
(144 Views)

@altenbach wrote:

@Yamaeda wrote:
You can use Interpolate array on an array of clusters? 

Yes, "index&bundle" creates an array of points. Very useful! Without that, we need quite a bit more code for the same functionality.

(Of course the points need to be sorted in X.)

 

altenbach_0-1756305805214.png

 


I read the sentence but somehow didn't realize it. It would be nice if they showed it in the picture and/or had a linked example ...

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 9 of 9
(88 Views)