04-09-2017 12:06 PM
Hello,
I am working on a project to estimate the state of charge of the batteries using the coulomb counting algorithm.
I want to acquire the input and the output currents of the batteries and then calculate the mean of this current continuously during 60 seconds using the circular buffer.
I tried first to write and read data from the buffer but I get an error "Error -5011 occurred at Circular Buffer.lvlib:Circular Buffer(2D DBL).vi … Possible reason(s): Attempted to write data to buffer outside of configured bounds."
For now, the mean is done using a shift register as shown in the attached file.
Would you have any idea how should I proceed?
Thank you.
PS. I am using LabView 2014
Solved! Go to Solution.
04-09-2017 12:11 PM - edited 04-09-2017 12:15 PM
You did not attach the subVI. Is that from a toolkit?
Why not just use "mean ptbypt"?
Your array building is also faulty.
04-09-2017 12:42 PM - edited 04-09-2017 12:47 PM
Thank you for your quick reply and for your remarks.
Actually, it is part of a real time application which will be implemented on a compact RIO. I had an exchange with an NI Engineer who advised me to use this circular buffer instead.
I have no idea if “mean ptbypt” is sufficient for real time application.
Indeed, the local variables are inefficient and will be replaced by shared variables.
The subVI can be downloaded from http://www.ni.com/example/30883/en/ (once it is installed, you can find in user libraries)
Thank you.
04-09-2017 05:55 PM
There are several very important points that you don't seem to have grasped about this library.
The buffer itself is functionally a pre-designed AE (Action Engine), So that you don't have to run anything between the different instances of the buffer functionality.
See the snippet I have included below for functionality, if you need more information have a look at the examples that are included with the library, although they are all DAQ it should be pretty easy to convert across to a user array.
04-10-2017 10:50 AM
@lucdu39 wrote:
Actually, it is part of a real time application which will be implemented on a compact RIO. I had an exchange with an NI Engineer who advised me to use this circular buffer instead.
I have no idea if “mean ptbypt” is sufficient for real time application.
To average the last N points, you don't need a "circular buffer" because the order of elements does not matter. Also an AE implementation is a bit limiting, because you can only have one such circular buffer per project. Sometimes you need more. I am not going to install that thing just to look at the code. Is the VI available standalone somewhere?
Mean ptbypt is quite efficient and I would think it should run on RT. Are you planning to do the averaging on FPGA?
Are you planning to change the history size during the run? How big is the history size? From your initial question, there is only one channel (Current, singular), but then you also say input and output currents (plural). Are these two channels, both to be averaged?
A comparison of several ways to do such averaging are discussed in our NI-Week talk of 2016. These methods can easily be expanded for multiple channels (example).
04-15-2017 11:18 AM
Thanks for the clarification.
I have not yet created the standalone code.
For my application, I will just use the LabView scan engine.
I want to average 60 samples (fixed size) after one minute, the input and the output battery current are one channel. I think now, I have an idea how I should proceed.
I will try the averaging on RT using the ptbypt.
Thank you
03-26-2018 09:06 AM
Hi, Can you post the final solution. I am working on solar project. I am new to labview. I am taking temperature readings every 1 second. I want to average out every 60 samples and store only this average number so that I will have one average reading every one minute. You question seams to be similar.
It will be very helpful if you could post the final code you used.
Thank you.
03-26-2018 09:34 AM
03-26-2018 11:06 AM
Hi Sir,
Thank you for prompt reply.
I made the following code based on your suggestion. Correct me if I am wrong.
Also, I would Like to ask one more question. How to store the time (real clock time) along with the stored average value.? Since I am working in solar project, I want to show the time (like 9 am to 4 pm) on x axis and the averaged values minute by minute on y axis.
Thank you
03-26-2018 11:22 AM
Use Get Date/Time In Seconds to get a timestamp and then Build Waveform to put your timestamp and data together. You might want to have a quick look at this nugget: Sporadic Waveform Chart