Elmo
Member
- Joined
- Feb 19, 2017
- Messages
- 189
No, it's not something out of Fifty Shades of Ghastly, a long time ago when I learned to code I was taught to write pseudocode first. I'll refer to Wiki..
https://en.wikipedia.org/wiki/Pseudocode
I'm interested in what the or perhaps a pseudocode for a BMS would look like, it's been my experience that once once you have the pseudocode for an operation nailed down nicely writing the actual code usually is fairly straightforward. If you know where you are going when you start it's a lot easier to get there.
I've been doing some experiments with flying capacitor balancing and have come to realize that, logically enough (insert smack head smiley here) the charge and discharge times can be different depending on the internal resistance of the cells or parallel packs you are trying to discharge or charge. I think that with a proper capacitor a nice balancing system can be set up that is almost 100% energy efficient. My next step is to eliminate as much stray resistance from the circuit as I can, I may parallel the relays to lessen resistance, we shall see.
My pseudocode extremely rough outline for balancing with a flying capacitor is.. Every so often turn off all the balancing and after a pause for things to settle check the actual voltages across the cells, take the highest cell, siphon energy from it into a capacitor until the voltage curve starts to peak, turn off both legs of that cell, then turn on both legs of the lowest cell and discharge the capacitor into it until the voltage curve starts to bottom out, then it's turn off the lowest cell and back to the charge cell again, turn on both legs until capacitor voltage nearly peaks then turn them off and turn on both legs of the low cell until near bottom. Do this until you have a new low or high cell in the periodic scan and then do it to those cells and so on..
You can and indeed have to expand and add all kinds of other things, actually reading the cell voltages, sophisticated noise filtering, making absolutely positively darn sure that the wrong relays don't get turned on at the wrong time, talking to the overall charge controller overlord part of the program which of course needs its own pseudocode that would necessarily interface the PC of the balancing function as they are known in the Arduino world. Read the system timer and call subs you need for measurement and actions as the situation requires. BMS is actually a pretty easy microcontroller chore compared to say MPPT which turns into quite the juggling act quickly. At least you don't have to write your own ADC code in assembler, taking care to add nops so that all decision trees come out the same number of cycles so the speed is always the same. It was a day of wooden computers and iron men.
What would you like to see in a pseudocode outline for a BMS?
https://en.wikipedia.org/wiki/Pseudocode
Pseudocode[1] is an informal high-level description of the operating principle of a computer program or other algorithm.
It uses the structural conventions of a normal programming language, but is intended for human reading rather than machine reading. Pseudocode typically omits details that are essential for machine understanding of the algorithm, such as variable declarations, system-specific code and some subroutines. The programming language is augmented with natural language description details, where convenient, or with compact mathematical notation. The purpose of using pseudocode is that it is easier for people to understand than conventional programming language code, and that it is an efficient and environment-independent description of the key principles of an algorithm. It is commonly used in textbooks and scientific publications that are documenting various algorithms, and also in planning of computer program development, for sketching out the structure of the program before the actual coding takes place.
No standard for pseudocode syntax exists, as a program in pseudocode is not an executable program. Pseudocode resembles, but should not be confused with skeleton programs which can be compiled without errors. Flowcharts, drakon-charts and Unified Modeling Language (UML) charts can be thought of as a graphical alternative to pseudocode, but are more spacious on paper. Languages such as HAGGIS bridge the gap between pseudocode and code written on programming languages. Its main use is to introduce students to high level languages through use of this hybrid language.
I'm interested in what the or perhaps a pseudocode for a BMS would look like, it's been my experience that once once you have the pseudocode for an operation nailed down nicely writing the actual code usually is fairly straightforward. If you know where you are going when you start it's a lot easier to get there.
I've been doing some experiments with flying capacitor balancing and have come to realize that, logically enough (insert smack head smiley here) the charge and discharge times can be different depending on the internal resistance of the cells or parallel packs you are trying to discharge or charge. I think that with a proper capacitor a nice balancing system can be set up that is almost 100% energy efficient. My next step is to eliminate as much stray resistance from the circuit as I can, I may parallel the relays to lessen resistance, we shall see.
My pseudocode extremely rough outline for balancing with a flying capacitor is.. Every so often turn off all the balancing and after a pause for things to settle check the actual voltages across the cells, take the highest cell, siphon energy from it into a capacitor until the voltage curve starts to peak, turn off both legs of that cell, then turn on both legs of the lowest cell and discharge the capacitor into it until the voltage curve starts to bottom out, then it's turn off the lowest cell and back to the charge cell again, turn on both legs until capacitor voltage nearly peaks then turn them off and turn on both legs of the low cell until near bottom. Do this until you have a new low or high cell in the periodic scan and then do it to those cells and so on..
You can and indeed have to expand and add all kinds of other things, actually reading the cell voltages, sophisticated noise filtering, making absolutely positively darn sure that the wrong relays don't get turned on at the wrong time, talking to the overall charge controller overlord part of the program which of course needs its own pseudocode that would necessarily interface the PC of the balancing function as they are known in the Arduino world. Read the system timer and call subs you need for measurement and actions as the situation requires. BMS is actually a pretty easy microcontroller chore compared to say MPPT which turns into quite the juggling act quickly. At least you don't have to write your own ADC code in assembler, taking care to add nops so that all decision trees come out the same number of cycles so the speed is always the same. It was a day of wooden computers and iron men.
What would you like to see in a pseudocode outline for a BMS?