2 # Tero Salminen 2013 for project Log-plotter
3 # Timo Kokkonen http://git.itanic.dy.fi/?p=log-plotter
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # Commandline usage with example values unless ran from log-plotter
20 # gnuplot -e "datafile='log.log' ; chg_name='iCharger 3010B' ; cell_cnt='6' ; sizex='800' ; sizey='480'" bal.plot
22 set output "cell_bal.png"
25 ttext1=" - Cell balance "
27 set title chg_name.ttext1.cell_cnt.ttext2
29 # Setting the graphics size from log-plotter variables
32 set term png size gsizex,gsizey
34 # Setting layout and label & legends etc
38 set datafile separator ";"
39 set key out bot hor center samplen 2
40 set timestamp "%d.%m.%Y - %H:%M" top offset -1,-1 font ",8"
41 set ylabel "Voltage [mV]"
42 set y2label "Voltage [mV]"
45 set xlabel "Time [minutes]"
48 # extract the 'time' cell for xtics
49 stats datafile nooutput
50 stats datafile u (lastdatapoint=$3) every ::STATS_records-1::STATS_records-1 nooutput
53 #set xtics based on elapsed time
55 if (time > 300) set xtics 1 nomirror;
56 if (time > 900) set xtics 2 nomirror;
57 if (time > 1800) set xtics 5 nomirror;
59 # Count average-value for balance sero-line
60 samples(x) = $0 > 4 ? 5 : ($0+1)
61 avg5(x) = (shift5(x), (back1 + back2 + back3 + back4 + back5) / samples($0))
62 shift5(x) = (back5 = back4, \
67 init(x) = (back1 = back2 = back3 = back4 = back5 = sum = 0)
69 # Draw the plot based on log-plotter's variable cell-count
70 if (cell_cnt==1) plot sum=init(0), \
71 datafile using ($3/60):(avg5($7 - ($7 + $8) / cell_cnt)*1000) with lines title "Cell 1";
73 if (cell_cnt==2) plot sum=init(0), \
74 datafile using ($3/60):(avg5($7 - ($7 + $8) / cell_cnt)*1000) with lines title "Cell 1", \
75 datafile using ($3/60):(avg5($8 - ($7 + $8) / cell_cnt)*1000) with lines title "Cell 2";
77 if (cell_cnt==3) plot sum=init(0), \
78 datafile using ($3/60):(avg5($7 - ($7 + $8 + $9) / cell_cnt)*1000) with lines title "Cell 1", \
79 datafile using ($3/60):(avg5($8 - ($7 + $8 + $9) / cell_cnt)*1000) with lines title "Cell 2", \
80 datafile using ($3/60):(avg5($9 - ($7 + $8 + $9) / cell_cnt)*1000) with lines title "Cell 3";
82 if (cell_cnt==4) plot sum=init(0), \
83 datafile using ($3/60):(avg5($7 - ($7 + $8 + $9 + $10) / cell_cnt)*1000) with lines title "Cell 1", \
84 datafile using ($3/60):(avg5($8 - ($7 + $8 + $9 + $10) / cell_cnt)*1000) with lines title "Cell 2", \
85 datafile using ($3/60):(avg5($9 - ($7 + $8 + $9 + $10) / cell_cnt)*1000) with lines title "Cell 3", \
86 datafile using ($3/60):(avg5($10 - ($7 + $8 + $9 + $10) / cell_cnt)*1000) with lines title "Cell 4";
88 if (cell_cnt==5) plot sum=init(0), \
89 datafile using ($3/60):(avg5($7 - ($7 + $8 + $9 + $10 + $11) / cell_cnt)*1000) with lines title "Cell 1", \
90 datafile using ($3/60):(avg5($8 - ($7 + $8 + $9 + $10 + $11) / cell_cnt)*1000) with lines title "Cell 2", \
91 datafile using ($3/60):(avg5($9 - ($7 + $8 + $9 + $10 + $11) / cell_cnt)*1000) with lines title "Cell 3", \
92 datafile using ($3/60):(avg5($10 - ($7 + $8 + $9 + $10 + $11) / cell_cnt)*1000) with lines title "Cell 4", \
93 datafile using ($3/60):(avg5($11 - ($7 + $8 + $9 + $10 + $11) / cell_cnt)*1000) with lines title "Cell 5";
95 if (cell_cnt==6) plot sum=init(0), \
96 datafile using ($3/60):(avg5($7 - ($7 + $8 + $9 + $10 + $11 + $12) / cell_cnt)*1000) with lines title "Cell 1", \
97 datafile using ($3/60):(avg5($8 - ($7 + $8 + $9 + $10 + $11 + $12) / cell_cnt)*1000) with lines title "Cell 2", \
98 datafile using ($3/60):(avg5($9 - ($7 + $8 + $9 + $10 + $11 + $12) / cell_cnt)*1000) with lines title "Cell 3", \
99 datafile using ($3/60):(avg5($10 - ($7 + $8 + $9 + $10 + $11 + $12) / cell_cnt)*1000) with lines title "Cell 4", \
100 datafile using ($3/60):(avg5($11 - ($7 + $8 + $9 + $10 + $11 + $12) / cell_cnt)*1000) with lines title "Cell 5", \
101 datafile using ($3/60):(avg5($12 - ($7 + $8 + $9 + $10 + $11 + $12) / cell_cnt)*1000) with lines title "Cell 6";
103 if (cell_cnt==7) plot sum=init(0), \
104 datafile using ($3/60):(avg5($7 - ($7 + $8 + $9 + $10 + $11 + $12 + $13) / cell_cnt)*1000) with lines title "Cell 1", \
105 datafile using ($3/60):(avg5($8 - ($7 + $8 + $9 + $10 + $11 + $12 + $13) / cell_cnt)*1000) with lines title "Cell 2", \
106 datafile using ($3/60):(avg5($9 - ($7 + $8 + $9 + $10 + $11 + $12 + $13) / cell_cnt)*1000) with lines title "Cell 3", \
107 datafile using ($3/60):(avg5($10 - ($7 + $8 + $9 + $10 + $11 + $12 + $13) / cell_cnt)*1000) with lines title "Cell 4", \
108 datafile using ($3/60):(avg5($11 - ($7 + $8 + $9 + $10 + $11 + $12 + $13) / cell_cnt)*1000) with lines title "Cell 5", \
109 datafile using ($3/60):(avg5($12 - ($7 + $8 + $9 + $10 + $11 + $12 + $13) / cell_cnt)*1000) with lines title "Cell 6", \
110 datafile using ($3/60):(avg5($13 - ($7 + $8 + $9 + $10 + $11 + $12 + $13) / cell_cnt)*1000) with lines title "Cell 7";
112 if (cell_cnt==8) plot sum=init(0), \
113 datafile using ($3/60):(avg5($7 - ($7 + $8 + $9 + $10 + $11 + $12 + $13 + $14) / cell_cnt)*1000) with lines title "Cell 1", \
114 datafile using ($3/60):(avg5($8 - ($7 + $8 + $9 + $10 + $11 + $12 + $13 + $14) / cell_cnt)*1000) with lines title "Cell 2", \
115 datafile using ($3/60):(avg5($9 - ($7 + $8 + $9 + $10 + $11 + $12 + $13 + $14) / cell_cnt)*1000) with lines title "Cell 3", \
116 datafile using ($3/60):(avg5($10 - ($7 + $8 + $9 + $10 + $11 + $12 + $13 + $14) / cell_cnt)*1000) with lines title "Cell 4", \
117 datafile using ($3/60):(avg5($11 - ($7 + $8 + $9 + $10 + $11 + $12 + $13 + $14) / cell_cnt)*1000) with lines title "Cell 5", \
118 datafile using ($3/60):(avg5($12 - ($7 + $8 + $9 + $10 + $11 + $12 + $13 + $14) / cell_cnt)*1000) with lines title "Cell 6", \
119 datafile using ($3/60):(avg5($13 - ($7 + $8 + $9 + $10 + $11 + $12 + $13 + $14) / cell_cnt)*1000) with lines title "Cell 7", \
120 datafile using ($3/60):(avg5($14 - ($7 + $8 + $9 + $10 + $11 + $12 + $13 + $14) / cell_cnt)*1000) with lines title "Cell 8";
122 if (cell_cnt==9) plot sum=init(0), \
123 datafile using ($3/60):(avg5($7 - ($7 + $8 + $9 + $10 + $11 + $12 + $13 + $14 + $15) / cell_cnt)*1000) with lines title "Cell 1", \
124 datafile using ($3/60):(avg5($8 - ($7 + $8 + $9 + $10 + $11 + $12 + $13 + $14 + $15) / cell_cnt)*1000) with lines title "Cell 2", \
125 datafile using ($3/60):(avg5($9 - ($7 + $8 + $9 + $10 + $11 + $12 + $13 + $14 + $15) / cell_cnt)*1000) with lines title "Cell 3", \
126 datafile using ($3/60):(avg5($10 - ($7 + $8 + $9 + $10 + $11 + $12 + $13 + $14 + $15) / cell_cnt)*1000) with lines title "Cell 4", \
127 datafile using ($3/60):(avg5($11 - ($7 + $8 + $9 + $10 + $11 + $12 + $13 + $14 + $15) / cell_cnt)*1000) with lines title "Cell 5", \
128 datafile using ($3/60):(avg5($12 - ($7 + $8 + $9 + $10 + $11 + $12 + $13 + $14 + $15) / cell_cnt)*1000) with lines title "Cell 6", \
129 datafile using ($3/60):(avg5($13 - ($7 + $8 + $9 + $10 + $11 + $12 + $13 + $14 + $15) / cell_cnt)*1000) with lines title "Cell 7", \
130 datafile using ($3/60):(avg5($14 - ($7 + $8 + $9 + $10 + $11 + $12 + $13 + $14 + $15) / cell_cnt)*1000) with lines title "Cell 8", \
131 datafile using ($3/60):(avg5($15 - ($7 + $8 + $9 + $10 + $11 + $12 + $13 + $14 + $15) / cell_cnt)*1000) with lines title "Cell 9";
133 if (cell_cnt==10) plot sum=init(0), \
134 datafile using ($3/60):(avg5($7 - ($7 + $8 + $9 + $10 + $11 + $12 + $13 + $14 + $15 + $16) / cell_cnt)*1000) with lines title "Cell 1", \
135 datafile using ($3/60):(avg5($8 - ($7 + $8 + $9 + $10 + $11 + $12 + $13 + $14 + $15 + $16) / cell_cnt)*1000) with lines title "Cell 2", \
136 datafile using ($3/60):(avg5($9 - ($7 + $8 + $9 + $10 + $11 + $12 + $13 + $14 + $15 + $16) / cell_cnt)*1000) with lines title "Cell 3", \
137 datafile using ($3/60):(avg5($10 - ($7 + $8 + $9 + $10 + $11 + $12 + $13 + $14 + $15 + $16) / cell_cnt)*1000) with lines title "Cell 4", \
138 datafile using ($3/60):(avg5($11 - ($7 + $8 + $9 + $10 + $11 + $12 + $13 + $14 + $15 + $16) / cell_cnt)*1000) with lines title "Cell 5", \
139 datafile using ($3/60):(avg5($12 - ($7 + $8 + $9 + $10 + $11 + $12 + $13 + $14 + $15 + $16) / cell_cnt)*1000) with lines title "Cell 6", \
140 datafile using ($3/60):(avg5($13 - ($7 + $8 + $9 + $10 + $11 + $12 + $13 + $14 + $15 + $16) / cell_cnt)*1000) with lines title "Cell 7", \
141 datafile using ($3/60):(avg5($14 - ($7 + $8 + $9 + $10 + $11 + $12 + $13 + $14 + $15 + $16) / cell_cnt)*1000) with lines title "Cell 8", \
142 datafile using ($3/60):(avg5($15 - ($7 + $8 + $9 + $10 + $11 + $12 + $13 + $14 + $15 + $16) / cell_cnt)*1000) with lines title "Cell 9", \
143 datafile using ($3/60):(avg5($16 - ($7 + $8 + $9 + $10 + $11 + $12 + $13 + $14 + $15 + $16) / cell_cnt)*1000) with lines title "Cell 10";