08-26-2025 01:36 AM
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
Solved! Go to Solution.
08-26-2025 02:05 AM - edited 08-26-2025 02:08 AM
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?
08-26-2025 08:43 PM
Don't use case structures (which are excessively deep).
Just make a lookup table that gets filled in with info from the datasheet.
08-27-2025 03:46 AM
@GerdW wrote:
Suggestions:
You can use Interpolate array on an array of clusters?
08-27-2025 03:57 AM
08-27-2025 09:44 AM - edited 08-27-2025 09:48 AM
@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.)
08-27-2025 10:09 AM
@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 😄
08-28-2025 06:48 PM
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.
08-29-2025 08:58 AM
@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.)
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 ...