Dinosaur
 Guru
 Joined: 12/08/2011 Location: AustraliaPosts: 357 |
| Posted: 01:34am 11 May 2026 |
|
|
|
Hi All
The software in the Rpi is written in FreeBasic and uses an external Library for pwm & i2c called Periphery. The only downside of the library, is that you can't adjust by .1% increments, only 1%.
As usual for me the most difficult is the conversion of the .h to .bi include files. However, AI has done a great job of that. If anyone is interested I can post those. Other than that most time was taken in the charging logic. When to just thump the current in and when to start controlling it. Stopping the hunting when you think you have achieved a Target Voltage. I do a full scan of all I/O every 15 sec's update the screen and then nothing in between, which keeps the Rpi cool as well. The charging method is then re-evaluated and changes made. No GUI, only a Terminal screen with all the description & info I am interested in. Will try to post that pic. Changing text colour to a bright magenta (color 11) for the info that changes every cycle. In the software I record why changes were made and where, then translate that into a single number on the screen. A single Keystroke will save 100 samples of a2d for each of the 6 channels into .csv files.
The Rpi drives BC107 transistors that drive: 1: JayCar 60A SSR with 5vdc pwm.(Chinese brands failed on Current capacity) I put a homemade L channel heatsink under the SSR.It hasn't got warm yet.
2: Small CPU Fan Relay with 12vdc which only comes on when it is hot as all of this is deep inside the Ute with a Canopy on top and other camping stuff blocking air flow. On the pic you can just see it removed but on the left.
3: Blue Xeon Alarm Light so I can be alerted when driving that something has gone wrong. Happened once with my LiPo4 Cells when I left the Inverter on to long.
4: Each O/P is connected back to an I/P and is used to confirm the status of each O/P.
I2C: 2 x ADS1115 a2d converters on i2c.Precision resistor dividers, however I calibrate the conversion to an accuracy of about 3mV for the Cells. SolarV is less demanding and it has an accuracy of about 40mV. Current shunt is good for 34mA All of these are of course calibrated with charging Off. I actually bought a Voltage standard to confirm which of my Multimeters was accurate. It is worth noting that I have had a number of board failures when using the miniature version of this board, but the larger board (Gravity) has had none. On each channel you need to throw away the first 10 readings to allow settling and prevent cross contamination from other channels. The channels are multiplexed. When you then graph the .csv files in Excel the values are remarke-ably stable. The counts sit within 1 count and slowly goes down over many minutes as the Rpi etc consumes power. 1 x 12v to 5vdc converter, it has a switch in the Canopy for easy night time shutdown. 1 x Modified shunt. I only measure Solar Current as total load of lights and Fridge are known. The Inverter bypasses the shunt as it sometimes takes 180A. Simply cutting bars out of a 250A Shunt made it a 50A accurate shunt.
pwm: The Current measured and SolarV are used to calculate Wattage pumped into the battery. Depending on the SOC of the battery I pre-assign allowed Currents and thus pwm %. Below a snippet of code that achieves that.
''========Block of code to decide direction========= when Battery is NOT full yet. If .Direction < 0 Then '' Last Direction was DOWN If .Delta_Watts < 0 Then '' AND the Watts went DOWN If A2D.Err_I < 0 Then '' AND NOT @ Max current yet .Action = 16 '' then allow a direction change. .Direction = +1 Else '' otherwise if OVER Max Current .Action = 17 '' Keep going DOWN .Direction = -1 EndIf Else '' IF the Watts went UP whilst adj DOWN .Action = 18 '' keep going DOWN .Direction = -1 '' untill within Current Range. EndIf Else ''-----------------------------------------'' IF Last Direction was UP If .Delta_Watts < 0 Then '' AND the Watts went DOWN .Action = 19 '' then change direction. .Direction = -1 '' regardless of Err_I Else '' IF the watts went UP If A2D.Err_I < 0 Then '' AND under Max current .Action = 20 '' then keep going UP. .Direction = +1 Else .Action = 21 '' otherwise if OVER Max Current .Direction = -1 '' go DOWN EndIf EndIf EndIf ''====================================================== Hope you get a better picture from this. |