How this is done? Is there some kind of relay?
Lot of good information on your post! Thank you!
Thanks. If I got you to sign up for an account just to post a question I must be doing something right.
So, good question. I didn't really explain that. I was just trying to give a picture of the current flow in an optimal scenario. In my case, the key is using
Grin Tech LiGo batteries which have a single pair of positive/negative wires designed for both charging and discharging the battery through the same connection. Strictly speaking, it's only doing one or the other at any moment because the current either flows one way or the other, not both. The BMS automatically handles critical things like limiting maximum charge and discharge current, low voltage cutoff (discharging), high voltage cutoff (charging), battery temperature high/low limits, etc.
On a more traditional ebike battery, you're more likely to find separate charge and discharge connectors/ports which may limit your options. For example, a solar ebike builder from Germany who is currently touring in Sweden bought a battery pack for his cargo ebike which came with a 2A AC charger. His 160 watt solar panel could deliver up to 5A of charge current under ideal (but rare) conditions. The 18650 lithium ion cells in his pack could easily handle this much charge current but the BMS would only allow 2A on the battery pack's charge port. If it got more than 2A, it would shut off charging entirely. He could try charging the battery through the discharge port but this may bypass some BMS protection like high voltage cutoff which would be a problem if his charge controller ever delivered more than 4.2V/cell.
With some proprietary batteries, you may only have a single port for both charging and discharging and it may not be possible to do both at the same time so you may be stuck with having to carry two batteries and swapping them out. It's a bigger hassle than it sounds because you have to constantly keep an eye on both batteries' state of charge. Having done it in the past, I love not having to think about it and just focus on the ride.
Back to my case with the LiGos. The output of the solar charge controller is directly connected to both the battery and the motor controller. No relays required. The solar charge controller is always delivering the maximum power the current solar conditions and temperature will allow and trying to get the battery to 4.2 volts per cell. Let's say that I'm currently getting 250 watts from solar and the motor is only using 200 watts because I'm cruising on level ground. In that case, the extra 50 watts is going into the battery.
A moment later, I pass under some trees and solar output drops to 10 watts. The motor controller still draws the same 200 watts so the battery instantly goes from charging at 50 watts to discharging at 190 watts. As soon as I'm back out in the sun, it goes back to charging at 50 watts.
A few minutes later, I encounter a hill. I'm still getting 250 watts from solar but now the motor controller needs 500 watts to maintain speed. The battery supplies the additional 250 watts.
So, the battery is frequently switching from charging to discharging as available solar power production and motor controller power draw varies throughout the day. It makes more sense to think of the solar panel as the power source and the battery as a buffer between supply and demand. At the end of the day, the total number of amp-hours of energy into/out of the battery is much lower than if I had two batteries and swapped them out because most of the solar energy produced and consumed bypassed the battery. Fewer battery cycles means longer battery life.
Keep in mind that this level of optimization makes sense for someone like me who has custom-built a solar touring bike for an ultra long distance trip. If you're just looking to experiment with solar for fun to get some range extension and you're working with a bike and components that were not selected for solar touring then some minor efficiency losses may not be as important to you.