Friday, 24 May 2013

Out of Memory :(

I went out the the van last night and connected up the Arduino to the current shunt and battery and left it recording to the SD card. Alas, when I went out, the SD card had nothing on it.

After a long time messing about with it, and fearing I may have accidentally fried the SD Card, I worked out that the Arduino was out of memory. The Arduino One clone that I am using only has 2KB of SRAM to use. So all the variables that you define, strings you assign, etc. all have to fit in that 2KB. Which is really not a lot of room. Especially when you consider I don't actually have the State of Charge code written yet! So I'm out of memory and I haven't even calculated anything useful yet! I managed to pare it down enough for the Arduino to have enough memory to open the file on the SD card to write to it. Over this weekend I am going to go through and refactor my code some more.

I'm hoping this weekend, whilst we are away camping for the weekend, to try and capture a full 3 days worth of battery data. That is likely to be about the full runtime of my batteries, depending on the amount of sun and solar panel output. Once I get that data, I have a cunning plan. I'm going to try and write a simulator for the state of charge in Python on my laptop. I will be able to feed the raw data from the Arduino into it to run through a full 3 days in a number of milliseconds. This will allow me to tweak the algorithm and re-run it multiple times in order to try and get something that best matches the real world results as best I can. Alas this won't include any heavy charging from the engine, but should be a good start. The real goal for this is to have something that can keep track of my battery state over the space of a number of weeks involving multiple charge / discharge cycles and partial cycles.

No comments:

Post a Comment