ElectricMotorcycleForum.com

Makes And Models => Zero Motorcycles Forum | 2013+ => Topic started by: Keith on July 16, 2017, 08:55:43 PM

Title: How to stop charging below 100%
Post by: Keith on July 16, 2017, 08:55:43 PM
How to stop charging below 100%?

Assuming you don't want to top up your bike and would rather charge it to some lower SOC, what can you do?

There are some manual methods. You can watch the dash SOC indicator during charging and disconnect anytime. You can ride until you reach some desired charge level and then don't charge. You can calculate the time it will take to reach a desired charge level, go away and come back to disconnect when the time is up. There are obvious problems with all of these choices.

How can this be done automatically? I will attempt to explore all of the possibilities and maybe I'll do something myself. Others are welcome to use my ideas. Here goes:

First there are a many ways to charge so that creates multiple solutions. In any case charging can be stopped either by disconnecting the AC to the charger or by controlling the charge enable logic. Deciding when to stop charging can be based on time, battery voltage, or some other SOC reading if available.

The simplest solution appears to be a settable timer on the AC to the charger. A calculation based on the current SOC, charging rate, and desired SOC is needed. That's a fairly easy web page to create, maybe I'll do that. Given the time it will take to reach the desired SoC, you set the timer and done. Complications include what type of AC connection is being used, and the accuracy of the charge prediction given variables like temperature, line voltage, pack condition etc. Huge advantage of this approach is it uses off the shelf components, no design needed, no warranty worries.

An existing, smart external charger with user input to select a desired stopping point would be great, but this choice doesn't seem to be available. Adding or modifying charger firmware requires proprietary knowledge so it probably isn't feasible. So it seems that some custom design may be required if the timer method isn't attractive.

Next up the ladder of complexity and design effort would be a pack voltage sensing AC power control device. This could be set to stop charging at some desired level by switching off the AC to the charger at a desired cutoff voltage. There are a few drawbacks to this approach. First it requires an AC power switching device rather than using existing contactors. Next it depends on a voltage reading that is going to be different than the final SOC voltage after the charging current stops. Some higher charge levels may not be settable because the cutoff voltage will be higher than the fully charged voltage. However this approach could be adapted to any bike and charger configuration. Voltage for sensing is available at the external charge connection and AC control is external to the bike. User input is simply what voltage to stop charging and that could include don't stop until the bike stops at 100% SOC.

It is possible to control the pack contactor using the enable line. Again pack voltage sensing could be used, or possibly some other SOC value obtained from the bike. In the case of external chargers the enable line is accessible and used in the connection to the bike. This approach looks pretty simple once the hurdle of an arduino type project is undertaken. The processor would have three inputs, user setting for the desired charge, voltage of the pack, and the enable line from the charger. The only required output is the enable signal to the bike.  A pair of Anderson SBS 75X connectors puts the charge control device in series between the external charger and the bike. Power for the arduino could be from a battery so connection is simple. This idea might be a winner except for the programming piece.

Controlling the on board charger enable logic gets into some trouble with hardware, by modifying the bike wiring, or software, since communication with the MBB, BMS, CAN bus and charger gets complicated, bike model specific and is probably not feasible for development except by Zero. So the only practical way for riders to control on board charging seems to be AC power switching as already discussed.

That's it as far as I can come up with on a Sunday morning. Did I miss anything? Is this worth pursuing?
Title: Re: How to stop charging below 100%
Post by: MostlyBonkers on July 16, 2017, 09:57:46 PM
Hi Keith, I think there is only one reason to stop charging below 100% and that's before storing the bike for a long time.  It's probably not worth it even if you're going on holiday for a couple of weeks.

I'm pretty sure the battery is going to be good for at least 10-15 years before it drops its health by any significant amount.

For that very rare occasion that you won't be riding for more than a month, I think there's very little effort to take it for a ride down to 60%. Or set a timer on your phone to remind yourself to switch it off after a couple of hours.

I'm more interested in why you think it's  worth the bother to find a solution to a problem that doesn't exist. I don't want that to sound facetious, I just feel that people spend far too much time worrying about charging when they don't need to.
Title: Re: How to stop charging below 100%
Post by: Fred on July 16, 2017, 10:00:18 PM
I agree. You'll spend more time solving the problem automatically than you would doing it manually. Unless you're just up for the challenge for the fun of it of course.
Title: Re: How to stop charging below 100%
Post by: Keith on July 16, 2017, 10:15:27 PM
My situation is unique since I have four packs for my FX. That means some packs are always not in use, who knows for how long. And I don't commute, I ride off road whenever, no schedule. So while you are probably right, charge to 100% and ride is no problem, it might be for me. And while I have faith in the warranty and Farasis, I'd like to make my packs last forever. They may get repurposed long after my FX is scrap metal.

Anyway, it is a fun problem. If it isn't too difficult, I'd like to change my ways and not keep all four packs at 100% all the time. The benefit of doing that by any method may be small or even insignificant, but I don't think anyone really knows that with certainty. I'm not worried, just want to do the best for my investment. If they lose 5% in ten years instead of 10%, that's a win.
Title: Re: How to stop charging below 100%
Post by: Doug S on July 16, 2017, 11:03:09 PM
I'd agree with others that this is probably not worth doing for most people, but it might be for some, as Keith points out. And it is an interesting thought exercise.

As I understand it, most if not all of the chargers for our bikes are CC/CV chargers, meaning they maintain constant current for the bulk of the cycle, switching over to constant voltage near the end, when the battery can't handle as much charging current. I'm also thinking most of them have some means of adjusting the ultimate voltage, for setting at the factory if nothing else. I'd think it would be as simple as adjusting the charger to put out a bit lower final voltage.
Title: Re: How to stop charging below 100%
Post by: MostlyBonkers on July 16, 2017, 11:07:20 PM
Ahh, that's a bit different. I presume the FX tells you the state of charge of each pack, so you know where they're at when you take them out. It should be simple to work out how long each one needs on a charger to get to 50%, so you just need to find a timer that will cut the power after a set time. Something with an analogue knob that you twist for however many hours it needs would be convenient. I've never seen one though. Like an egg timer but with longer time periods.
Title: Re: How to stop charging below 100%
Post by: Keith on July 16, 2017, 11:53:31 PM
Actually there is no separate charge indication for the two packs but I believe they are kept equal by the bike when possible, which is usually. A twistable mechanical timer would work but I've only seen the ones with little flags designed for daily cycles, that would not be easy to set. A reminder timer would work but might not be convenient if you leave the bike. And I will do something to get the time calculation simply.
Title: Re: How to stop charging below 100%
Post by: Lenny on July 17, 2017, 02:05:43 AM
Keith I want to do the same thing for the exact same reasons. Why charging my pack to 100% and potentially harming it, when 85 or 90% is more than enough for my weekly ride needs?

I already have some stuff laying around, i.e. a wemos board, a raspberry, arduinos, a sms module and can module for arduino and a ELM237 Bluetooth ODB connector. I think I will solve it with a relay on the ac side, which is switched by one of those components. I will try to read out voltage/soc/range out of the CAN while charging (someone in another thread deciphered some CAN already) with the ELM327, connect to it with the raspberry, which at the same time is in the wifi and might be controlled by an app or something. But an arduino with an sms module placed onboard the bike might also do the job, it could even measure voltage and be powered by some 12v supply. I'll keep you updated, but it will still take a while until I find time to realize this project.
Title: Re: How to stop charging below 100%
Post by: togo on July 17, 2017, 02:38:48 AM
We know SoC can be wildly inaccurate for these batteries, so let's target a voltage rather than a percentage.
Title: Re: How to stop charging below 100%
Post by: Keith on July 17, 2017, 02:42:29 AM
Voltage is my thought too, simple to measure, just set a target range for storage. Maybe 105-110V is good. Easy to check, easy to control.
Title: Re: How to stop charging below 100%
Post by: Fred on July 17, 2017, 03:39:39 AM
Will cell balancing be affected as this seems to happen at the end of the charging cycle?
Title: Re: How to stop charging below 100%
Post by: Erasmo on July 17, 2017, 03:40:44 AM
Cell balancing happens all the time.
Title: Re: How to stop charging below 100%
Post by: Electric Terry on July 17, 2017, 01:42:50 PM
I believe sometime in the next year, perhaps much sooner (just don't want to rush those working on the project) that the Diginow will have target voltage to be controlled and settable by the phone app.  You just punch in 110 volts and it charges to 80%.  Also if you are on a weak or shared outlet (garage door or fridge) you can set the amperage to charge at less than 1600 watts like 1200 watts, 800 watts or even 100 watts if you like or anything in between.
Title: Re: How to stop charging below 100%
Post by: Keith on July 17, 2017, 05:44:01 PM
That sounds really great, I'm glad to know that this flexibility in charging has been recognized as a desirable feature set. But I'd rather have controls right on the charger than use a phone. I guess it is cheaper to use another device with a wireless connection than local hardware for the UI. I carry a burner on the trail so my "smart phone" is packed away, not convenient. But I'm not typical, never was, never will be!  8)
Title: Re: How to stop charging below 100%
Post by: Keith on July 17, 2017, 08:04:13 PM
The simple timer method has some drawbacks. Digital timers may have a countdown function but it could take a lot of button pushing to set. There are simple push button timers but they have limited precision, 1, 2, 4, 6 hours. Mechanical 12 hour timers are available and cheap, might be ok. But almost everything is 15 amps, not enough for many of us. And even within rated current, sometimes they fry. Getting higher current AC power switching seems to require electrician level components. Not so cheap and still needs a control timer. Using the DC contactors to control charge stopping seems like a better idea right now. Is it? Can the contactor be damaged by opening under charging current load? Welding due to arcing on closing can happen but that seems like a different condition. Anyone know?
Title: Re: How to stop charging below 100%
Post by: togo on July 17, 2017, 09:46:09 PM
I believe sometime in the next year, perhaps much sooner (just don't want to rush those working on the project) that the Diginow will have target voltage to be controlled and settable by the phone app.  You just punch in 110 volts and it charges to 80%.  Also if you are on a weak or shared outlet (garage door or fridge) you can set the amperage to charge at less than 1600 watts like 1200 watts, 800 watts or even 100 watts if you like or anything in between.

I don't believe the existing diginow SCv2 controllers currently being supplied have the hardware to support wireless phone connections.  But I imagine the controller module could be swapped out.
Title: Re: How to stop charging below 100%
Post by: grmarks on July 18, 2017, 04:22:16 AM
Cell balancing happens all the time.
There is definately some balancing done at the end. You have cell balancing in each module and then balancing between modules. From my experience with BMS's I would guess the modules are balanced all the time and the cells within modules are balanced at the end. Lithium batteries have a very flat voltage curve except at the bottom and top of charge.  So BMS's use the top balance method as it is easier and happens every charge (unless you stop at 80%).  The only bottom balancing I have heard of is done manually.

The voltage of a lithium cell at 50% soc and 70% is almost identical and given difference between cells you could have 2 cells at the same voltage but one is 50% soc and the other 70%. If your cell voltage is normally around 3.2V, at  say, 3.7 volts you know the cell is almost full because the voltage only rises like this when the cell is almost full. If every cell is 3.7 V then you know every cell is almost 100%.   

But with monitoring the pack voltage it will be far less accurate, but if every cell goes up by 0.01 V then across, say, 30 cells, then thats a rise of  .3 volts that you could measure. These are just random figures to explain the idea.

I have only done one conversion of a bike to electric, but when looking at BMS systems, this is the way they all seemed to work and the explanation given. I don't see how you can cell balance at every step of charging. I am no expert but if someone wants to dispute this then please do (with the evidence and explanation to prove your case). 

So if you charge to only 80% then every few charges you would want to charge to 100%, but that could be programmed into the Arduino program. How do you tell if you are at 80%? It is usually done by an algorithm that measures the amount of power you use ( it knows the total power of the pack) and calculates a % SOC. The reverse is done when charging, e.g. if you have a 10 Kw/h pack and you monitor 5kw/h going out then you are at 50% SOC. If you monitor 3 kw/h going in, you are back up at 80%. The algorithm also takes into account pack age, number of time charged, to what depth of discharge etc, etc.

This is why 2014 bikes would say you had 10% SOC and then cut out 1% later with on charge left -  the calac was out of whack with reality. By making the algorithm smarter the accuracy increases.

So if you measure the pack voltage and lets say each cell rises by 0.01 V then if you have, say, 30 cells thats .3 V that you can measure and have the charger disconnect.
These figures are just random numbers to explain the idea. It is certainly doable.     

Title: Re: How to stop charging below 100%
Post by: Keith on July 19, 2017, 05:51:58 PM
Here's my arduino based design to stop charging at a settable voltage, parts are on the way. I think this is the simplest way to charge externally to less than 100% without any inconvenience. The design is minimal, self powered, and can be incorporated into the existing Y cable so no connectors are added. Or it could be built with its own connectors. It is used inline with the bike external charge connector or the battery pack adapter.

Writing the code and debugging remains to be done before this approach is proven but I'm confident it will work. The processor will need to measure the set point input and compare to the measured pack voltage. When the scaled voltage is above the set point, the enable line is turned off and charging stops. No time calculation is needed, no relays or AC switching, simple. And it's easily bypassed if it fails or if 100% charging is desired. About $50 parts cost without connectors.

Title: Re: How to stop charging below 100%
Post by: ESokoloff on July 21, 2017, 08:25:52 AM
I believe sometime in the next year, perhaps much sooner (just don't want to rush those working on the project) ...............

Also if you are on a weak or shared outlet (garage door or fridge) you can set the amperage to charge at less than 1600 watts like 1200 watts, 800 watts or even 100 watts if you like or anything in between.

Very cool :)

I've shared my EV expereance on a ICE motorcycle forum board and someone responded that having only an outlet on 10 amp circuit at his apartment would prevent him from owning a zero unless there was a workaround. 

Sounds like this feature will allow more individuals to get into the EV game.   
Title: Re: How to stop charging below 100%
Post by: ESokoloff on July 21, 2017, 08:31:38 AM
Hi Keith, I think there is only one reason to stop charging below 100% and that's before storing the bike for a long time.  ............

.........

I'm more interested in why you think it's  worth the bother to find a solution to a problem that doesn't exist. I don't want that to sound facetious, I just feel that people spend far too much time worrying about charging when they don't need to.

I for one I'm looking for a way to AUTOMATICLY limit charge level.
My employer provides EV power for electric vehicals so as long as I keep the battery level above 60-65% I wait until I'm at work to fully charge. 
Title: Re: How to stop charging below 100%
Post by: remmie on July 21, 2017, 12:06:55 PM
On my 2014 SR (and I assume all Zero's with the Calex 1200 W onboard charger) the powerdraw rises from around 1200 Watts at 10% SOC to almost 1400 Watts at 98% SOC. So from the powerdraw of the charger you can guestimate the SOC of the Zero. It may not be very exact but it could offer a good way to switch off the power to the onboard charger at a desired level.

Maybe a smart power meter (Wemo switch / elgato eve energy / similar) could cut the power to the charger when it draws more than 1350 Watts. This would stop the charge at around 80% SOC. I know that with homekit (apple) and other home automation programs you can use the value of a sensor (in this case the energy meter to where the Zero is connected) to switch appliances (in this case the same energy meter with switch switch) or lights.

Haha would be cool. When the zero is charged to the desired level, cut the power to the charger and switch on (or off or flash :) ) your home lights.

Title: Re: How to stop charging below 100%
Post by: Scope on July 21, 2017, 10:48:22 PM
I use a WeMo Insight switch with an IFFF rule to shut off power once consumption drops below threshold.


Sent from my iPhone using Tapatalk
Title: Why (and how to) stop charging below 100%
Post by: togo on July 22, 2017, 12:26:45 AM
Hi Keith, I think there is only one reason to stop charging below 100% and that's before storing the bike for a long time.  ...

Well, the second reason is battery life, which, yes, is not much of a reason for the general public, more of a reason for electronics tinkerers and the truly frugal.  It'll probably make about 1-5% difference in the life of the battery

But I actually have a third reason.

I live at the top of a hill.

I'd like my "normal" charge level to be one that doesn't disable regenerative braking. (Is that 98% on the latest firmware?)

Well, again, a reason for the tinkerer.  It's technical.  And for the frugal.  Cuz... brake pad wear.


Title: Re: How to stop charging below 100%
Post by: remmie on July 22, 2017, 12:33:59 AM
Here's some data on a charge from 26% to 100%
I've combined data from the log of the powerdraw from my home automation system and the corresponding MBB log.

Time is in minutes from the start of charging.

In the data you can see that the power starts out at 1212 Watts at 26% and tops out at 1380 Watt at 93%. After that the power tapers off as the max voltage is reached and the current tapers down.
Another weird thing is the jump from 71% to 81% within 10 minutes. But hey, it a 2014 so SOC is unpredictable (have to get the new firmware update soon).
So if you would want to charge to 85% you would set the cutoff point at 1340 Watts

Time   SOC   Packtemp   Amb temp   Power
0   26%   38.0   21.0   1212
10   28%   37.0   22.0   1218
20   29%   37.0   23.0   1221
30   31%   36.0   24.0   1225
40   33%   36.0   24.0   1227
50   35%   35.0   24.0   1229
60   36%   35.0   25.0   1232
70   38%   35.0   25.0   1235
80   40%   34.0   25.0   1237
90   41%   34.0   25.0   1240
100   43%   34.0   25.0   1242
110   45%   34.0   25.0   1244
120   47%   34.0   25.0   1247
130   48%   34.0   25.0   1249
140   50%   34.0   25.0   1252
150   52%   35.0   25.0   1255
160   53%   35.0   25.0   1259
170   55%   35.0   25.0   1262
180   57%   35.0   25.0   1267
190   59%   35.0   25.0   1272
200   60%   35.0   25.0   1277
210   62%   36.0   25.0   1282
220   64%   36.0   25.0   1288
230   65%   36.0   25.0   1294
240   67%   36.0   25.0   1300
250   69%   36.0   25.0   1306
260   71%   36.0   25.0   1314
270   81%   37.0   25.0   1321
280   82%   37.0   25.0   1330
290   84%   37.0   25.0   1338
300   86%   37.0   25.0   1346
310   88%   37.0   25.0   1354
320   89%   37.0   25.0   1363
330   91%   37.0   25.0   1370
340   93%   37.0   25.0   1379
350   94%   37.0   25.0   1176
360   96%   37.0   25.0   539
370   96%   37.0   25.0   455
380   97%   37.0   25.0   383
Title: Re: How to stop charging below 100%
Post by: togo on July 22, 2017, 01:10:21 AM
Awesome table, thanks!

So it looks like a microcontroller measuring current with a relay could do an approximate job of it in a little self-contained box.

For onboard Calex, connectors could be C14 in, C13 out.

For SCv2, connectors would be anderson SBS50 brown (everybody have the same ones?).

"Normal mode" charging, you use the box, "range mode" you omit it.  Way cool, way KISS.  LEDs or a display if you want to verify mode, but the Zero app or the Diginow Dongle can be used to verify voltage and current from the Zero's point of view.

So, any open source current-measurement arduino code out there?  I see there's a shield; that seems overkill.


Title: Re: How to stop charging below 100%
Post by: Keith on July 22, 2017, 01:19:01 AM
That approach does look promising for on board charger control. I'm soldering wires to my arduino enable controller for external chargers right now, may have results today. A little box in series with the Y cable enable will do it. Sensing pack voltage directly and switching a logic line is simpler than AC power circuitry but requires an external charger. Measuring the power draw of the charger is equivalent to measuring pack voltage because the charger is constant current. Since W=E*I the watts increase directly with voltage.
Title: Re: How to stop charging below 100%
Post by: remmie on July 22, 2017, 01:52:18 AM
I think this project (not mine  8) ) should give you some ideas

https://openhomeautomation.net/arduino-wifi-switch/ (https://openhomeautomation.net/arduino-wifi-switch/)
Title: Re: How to stop charging below 100%
Post by: Keith on July 22, 2017, 04:10:38 AM
I have a prototype of the arduino charge control idea assembled and I'm in the early testing phase. I've learned that the enable line from the DeltaQ is not just a simple logic line, it has at least a couple of modes rather than just on/off. So I'll need to regroup a little and figure out how to handle that properly. It appears that some voltage on the enable line signals the charger that the bike is nearly charged so it turns on the 80% charge indicator and reduces current (I think or maybe it goes into CV?). So this is not quite as simple as I thought, more testing needed.
Title: Re: How to stop charging below 100%
Post by: togo on July 22, 2017, 11:40:13 AM
I think this project (not mine  8) ) should give you some ideas

https://openhomeautomation.net/arduino-wifi-switch/ (https://openhomeautomation.net/arduino-wifi-switch/)

That is awesome. It measures current, and it switches 10A. 117vac people will want more, but that's probably just a part swap. It has all the hardware we want and wifi comm on top of that. Awesome.
Title: Re: How to stop charging below 100%
Post by: Keith on July 23, 2017, 09:04:40 AM
Success! I have short charged under arduino control with good results.  8) I have some more work to do, need to handle two chargers with separate enables, put it in an enclosure, and publish the design and code, open source of course. I had a few setbacks along the way. I solved the enable line handling issue I mentioned previously by changing to an open collector style connection where the enable line is unaltered except when the desired voltage is reached and the processor pulls it to V-.

The other problem was more difficult. I really wanted it to be self powered and that almost worked. A simple zener diode and resistor from the pack voltage will power the board, but not without some trouble. Because power is lost when the charging stops, the processor can no longer control the enable signal. On the bike, that causes the dash charging light to flicker red after charging stops. That's probably OK, but it shouldn't do that. The same thing happens if you connect and power an external charger before turning the key on. Worse than that is what happens when charging packs off the bike. When charging stops, the contactor opens but the charger keeps the enable line active. So the contactor closes again, opens again, etc. Again, probably OK but annoying and would wear out the contactor. So I tried many circuit and software ideas to fix it but none of them worked in all cases.  :(

The simple answer is to just power the arduino with a usb charger. That works perfectly, but it is one more thing to connect and I really wanted to avoid that. Anyway, it works flawlessly now, charging stops predictably, the QuiQ turns off current, shows green for charge complete and then flashes red as it does when disconnected. All good. Both bike and pack are now happy with the charge termination method. I'll post more details when I wrap this project up.

By the way, this device can be built for around $20 using the arduino mini and existing connectors, pretty sweet. I'm sure it can be adapted to control an AC contactor for on board charging control too. But I'm not inclined to mess with wifi, I like simplicity. I do have a few ideas for other features though. For example, it would be nice to have a delayed charging start to give the packs and air temperature time to cool down first.
Title: Re: How to stop charging below 100%
Post by: MostlyBonkers on July 24, 2017, 02:51:01 PM
Hi Keith, I think there is only one reason to stop charging below 100% and that's before storing the bike for a long time.  ............

.........

I'm more interested in why you think it's  worth the bother to find a solution to a problem that doesn't exist. I don't want that to sound facetious, I just feel that people spend far too much time worrying about charging when they don't need to.

I for one I'm looking for a way to AUTOMATICLY limit charge level.
My employer provides EV power for electric vehicals so as long as I keep the battery level above 60-65% I wait until I'm at work to fully charge.

Thanks ESokolof.  I've managed to persuade our facilities manager at work to install some power in the loading bay where I park my bike. I was going to fully charge at home and then top up at work. I don't feel comfortable only charging at work just in case I have to leave work early for some reason (kids usually).  However, charging to  80% at home would mean I'd still have about 40% when I get to work. I'd only need to be plugged in for an hour or so to have enough juice to get home.

So, by charging to 100% at work and then from 60-80% at  home, I'll save another 2kWh of electricity each day at home compared to the method of just charging to full at home. That's about 35p a day or getting on for £50 a year with my current commute. Worthwhile and it means the bike spends most of the time standing with an 80% SoC. Better for the battery in the long term.

I also like togo's reasoning because he lives at the top of a hill! It just goes to show how many different use cases there can be that are difficult to think of unless you are in someone else's shoes.  I stand corrected! :-)



Title: Re: How to stop charging below 100%
Post by: togo on July 27, 2017, 02:03:22 AM
Remmie> https://openhomeautomation.net/arduino-wifi-switch/ (https://openhomeautomation.net/arduino-wifi-switch/)

Oh, that is awesome.  30A measurement capability, https://www.amazon.com/DAOKI-Current-Sensor-Module-Arduino/dp/B00XT0PL20/ (https://www.amazon.com/DAOKI-Current-Sensor-Module-Arduino/dp/B00XT0PL20/) , relay would have to be upgraded for NA people (10A@110v isn't enough), and the optional wifi could be used to talk to a cell phone or a Raspberry Pi or even text you.

Thanks, remmie!

Keith> Success! ...

Awesome!

> publish the design and code, open source of course. ...

Can't wait to see it.

> ... A simple zener diode and resistor from the pack voltage will power the board, but not without some trouble....

I bet it gets hot.

> The simple answer is to just power the arduino with a usb charger. That works perfectly, but it is one more thing to connect and I really wanted to avoid that. Anyway, it works flawlessly now, charging stops predictably, the QuiQ turns off current, shows green for charge complete and then flashes red as it does when disconnected. All good. Both bike and pack are now happy with the charge termination method. I'll post more details when I wrap this project up.

A neat and tidy package for this would be a USB power outlet pass-through box, this kind,
https://www.amazon.com/Bestten-Outlet-Plugs-Universal-Charger/dp/B017KOZUUS/ (https://www.amazon.com/Bestten-Outlet-Plugs-Universal-Charger/dp/B017KOZUUS/)

> By the way, this device can be built for around $20 using the arduino mini and existing connectors, pretty sweet...

Yeah, that is sweet.  I'm thinking Adafruit Feather or an Adafruit Trinket.

> But I'm not inclined to mess with wifi, I like simplicity.

I'm skipping wifi too, for now, get something simple working first.  If a hard-coded value does the job, I'm done.

Thanks, Keith!
Title: Re: How to stop charging below 100%
Post by: Doug S on July 27, 2017, 04:00:51 AM
30A measurement capability, https://www.amazon.com/DAOKI-Current-Sensor-Module-Arduino/dp/B00XT0PL20/ (https://www.amazon.com/DAOKI-Current-Sensor-Module-Arduino/dp/B00XT0PL20/) , relay would have to be upgraded for NA people (10A@110v isn't enough)...

The chip on that module is an Allegro ACS712; I have a lot of experience where I work with a related ACS722 family. They're great chips; we use them at 220VAC, up to 30A, and we've never had one fail yet. They're certified for up to 297Vrms so I doubt we ever will. One of the functions of our product is to perform a true average power measurement on power delivered to the load, with typical line voltage ugliness, and we're able to do it better than the commercial power meters we've compared it to. I love those Allegro hall effect devices.
Title: Re: How to stop charging below 100%
Post by: togo on July 27, 2017, 04:56:15 AM
http://www.allegromicro.com/en/Products/Current-Sensor-ICs/Zero-To-Fifty-Amp-Integrated-Conductor-Sensor-ICs/ACS712.aspx (http://www.allegromicro.com/en/Products/Current-Sensor-ICs/Zero-To-Fifty-Amp-Integrated-Conductor-Sensor-ICs/ACS712.aspx)

... says ACS72x are recommended for new designs.

But the ones available on amazon and ebay in convenient carriers are ACS712

I ordered the 30A version, since 110 volt times 10 amps is only 1100 watt.
Title: Re: How to stop charging below 100%
Post by: Doug S on July 27, 2017, 07:32:40 AM
... says ACS72x are recommended for new designs.

I saw that, but I didn't see significant if any differences in the data sheets. I'm guessing it's just standard part rotation as a newer, cheaper part becomes available.

We aren't actually using either of those where I work -- we use a 3.3V (non-obsolete) version rather than the 5V-only flavor. The exact part number escapes me at the moment.
Title: Re: How to stop charging below 100%
Post by: togo on July 27, 2017, 11:06:59 AM
At 1A, the 5v power supply on this unit is too anemic to run a raspberry pi, but good enough to power an arduino.  And it has room for the smaller ones.

Title: Re: How to stop charging below 100%
Post by: Keith on July 30, 2017, 06:40:24 PM
My arduino design is still evolving, but it is now close enough for a detailed preview. I keep thinking of new features as usually happens when a computer is included. Here are pictures, schematic and preliminary code. It works but it isn't finished. I'm going to add a solid state relay for ac control. That will need a heatsink. I'm not sure yet whether I'll just control the on board charger or switch the QuiQs too. And it can now enable packs for discharge so it may become my Tesla Wall if I can find an inverter. It works very well right now and can communicate with a laptop or run independently.

Code: [Select]
/* Y Cable Controller for Zero Motorcycle use 7/28/2017 Keith Thomas Version 1.0
  Arduino Nano program to control the enable lines between external chargers and the bike or power pack(s).
  Purpose is to end the charging cycle at less than full charge or 100% SOC, can also enable packs for discharge
  Method is to measure the pack voltage while charging and turn the enable signal off when a desired setting is reached.
  Pack voltage is reduced by a 10/304 resistive divider, ADC 0-1023, 4.096v full scale reference
  Design adjustment range for at least 50% to 100% SOC, with +/- 2.4% accuracy, 0.12v resolution
  Dial nominal reading is 102 to 120, 18 volt range, 0-100 dial
*/
// I/O constants
const int acRelay = 2; // D2 is control for AC relay
const int packEnable1 = 3; // D3 pull up to close pack contactor
const int packEnable2 = 4; // D4 second pack
const int enableOut1 = 7; // Charger 1 enable
const int enableOut2 = 8; // Charger 2 enable
const int ledPin = 13; // LED connected to digital pin 13
// A0 is set potentiometer wiper
// A1 is pack voltage divider
// A2 is charger 1 enable

// voltage constants
const int packMin = 842; //105V max, 102.5 nominal, min < 50% SOC
const int packMax = 986; //117.2V min, 120.0 nominal, max > 100% SOC
const float packMinF = 102.49;
const float packMaxF = 120.01;

// variables
boolean disabled = false; //use to latch enable at stop
int packV; //voltage of battery pack
int setV;  //setting potentiometer 0-1023
int packMap; //pack voltage typical range mapped to 0-1023
int enableV; //analog enable measure 0-1023
float setMap; //set voltage mapped to pack range for serial out
float readMap; //pack voltage adc mapped to real voltage for serial out

void setup() {
  digitalWrite (acRelay, HIGH) ; //AC on initially
  digitalWrite (enableOut1, LOW) ; //pull low to disable charging
  digitalWrite (enableOut2, LOW) ; //second charger disable
  digitalWrite (packEnable1, HIGH) ; //pull up pack enable
  digitalWrite (packEnable2, HIGH) ; //pull up second enable
  pinMode(acRelay, OUTPUT);  // drive ssr control
  pinMode(enableOut1, INPUT);  // Hi-Z to allow enable pass through
  pinMode(enableOut2, INPUT);  // Hi-Z to allow enable pass through
  pinMode(packEnable1, INPUT);  // Hi-Z unless pack enable
  pinMode(packEnable2, INPUT);  // Hi-Z unless pack enable
  pinMode(ledPin, OUTPUT); // use built in LED as charging indicator
  digitalWrite(ledPin, LOW); // charging LED off
  Serial.begin(9600); // report activity if usb has serial terminal
  Serial.println();
  Serial.println("Y Cable Controller");
  delay(1000); // wait for things to settle before measuring
  digitalWrite(ledPin, HIGH); // LED on to indicate measuring and enabled
}

void loop() {
  setV = analogRead(A0); // read knob setting
  digitalWrite(ledPin, HIGH); // charging
  setMap = mapf(setV, 0, 1023, packMinF, packMaxF);
  Serial.print("set ");
  Serial.print(setMap);
  packV = analogRead(A1);
  readMap = mapf(packV, packMin, packMax, packMinF, packMaxF);
  if (packV == 0) {
    readMap = 0; // not connected to pack
  }
  Serial.print("  pack ");
  Serial.print(readMap);
  Serial.print(" ");
  Serial.println(disabled);
  delay(500);
  packMap = map(packV, packMin, packMax, 0, 1023); // map(value, fromLow, fromHigh, toLow, toHigh)
  if (not disabled) {
    if (packMap > setV) { // voltage exceeds setting, disable
      pinMode(enableOut1, OUTPUT);
      pinMode(enableOut2, OUTPUT);
      digitalWrite(ledPin, LOW); // LED off to indicate charging stopped
      disabled = true;
      Serial.println("Set voltage reached, charging disabled.");
    }
  }
  digitalWrite(ledPin, LOW); // LED off
  delay(100);
}

float mapf(float x, float in_min, float in_max, float out_min, float out_max)
{
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
Title: Re: How to stop charging below 100%
Post by: togo on July 30, 2017, 10:47:38 PM
Awesome.

This is the solid state relay I bought, comes with heatsink, kind of large and bulky:

https://smile.amazon.com/gp/product/B0087ZTN08/

at 25A it's suitable for onboard charger but not for SCv2 above 3.3kw

In my application, I'm only planning to do onboard-charger, when I do rapid-charge I'm on the road, in a hurry, and usually monitoring with chargepoint app (or zero voltage app if i stay in bluetooth range).

Title: Re: How to stop charging below 100%
Post by: togo on July 30, 2017, 10:53:20 PM
I use a WeMo Insight switch with an IFFF rule to shut off power once consumption drops below threshold.

Nice.  More details, please?  Screenshots or something?
Title: Re: How to stop charging below 100%
Post by: Scope on July 30, 2017, 10:57:08 PM
I use a WeMo Insight switch with an IFFF rule to shut off power once consumption drops below threshold.

Nice.  More details, please?  Screenshots or something?
(https://uploads.tapatalk-cdn.com/20170730/b984cf603c25c7866af471cff77967b2.jpg)(https://uploads.tapatalk-cdn.com/20170730/ee4fdd0d8cc7c9d336caae8ea2bb8c4a.jpg)(https://uploads.tapatalk-cdn.com/20170730/b5c233a1b1acc4988eeb766d3fee4b62.jpg)(https://uploads.tapatalk-cdn.com/20170730/36b5084f1b4314495c1b4f3c39576795.jpg)



Sent from my iPhone using Tapatalk
Title: Re: How to stop charging below 100%
Post by: Keith on July 31, 2017, 02:31:09 AM
That WeMo configuration won't do partial charging. The consumption rises during charging so a cutoff at a higher consumption than the initial rate would do it if it can be programmed for that. The WeMo is just saving the "vampire power" by turning off power after the charging stops at 100%.
Title: Re: How to stop charging below 100%
Post by: togo on August 01, 2017, 04:18:59 AM
A quick google search finds discussions of setting the threshold, Keith:

'Select "Edit" from the main Devices screen in the App. You can then change the standby threshold to your requirements.'

Scope, what value were you able to set?  Can it be in the hundreds of watts?
Title: Re: How to stop charging below 100%
Post by: Keith on August 03, 2017, 06:23:41 AM
I installed the WeMo app but I can't get to the settings without a device. My google results found that maybe IFTTT could be used to detect a threshold and react to stop charging, but the direction, from low watts to high, and the required very high wattage threshold value make WeMo unlikely to be a real possibility for this purpose.  But I'm prepared to be wrong if it can be made to work.
Title: Re: How to stop charging below 100%
Post by: togo on August 05, 2017, 04:49:36 AM
here's an example of turning off a battery charger that normally uses 100w and goes down to 12w and then 2w when done.

http://cooltechtrends.com/tips-and-tricks-of-wemo-insight-smart-plug (http://cooltechtrends.com/tips-and-tricks-of-wemo-insight-smart-plug)

of course we need at least 10x that

i do like the ifttt recipe concept from the perspective of

- notification

- no soldering, so scales to more people

i don't like it from the perspective of

- it doesn't work without internet

- it doesn't work without companies running servers, and eventually they may change policies

- it doesn't work with rapid-chargers

- no one who has one has told us what the upper range of the "standby" detection setting is, and the dumbed-down manufacturer site and forums are devoid of specs.

Title: Re: How to stop charging below 100%
Post by: Keith on August 05, 2017, 06:10:36 AM
I'm convinced that WeMo could easily be used to stop charging after a set time, and then notify that it has done so. Useful, but it would require both calculating a time interval and being online. So far WeMo doesn't look promising for using charger power consumption with a threshold to stop at a desired state of charge, but that might be possible and would be all off the shelf components.

The design that I am currently refining could be mass produced commercially at a reasonable cost and imho it does the job nicely with none of the disadvantages you have listed. But production probably won't happen, I am no entrepreneur, maybe someone will adopt the idea. My concept leads to an integrated package with simplified connections compared to my present Zero provided setup with on board plus two Quiq chargers and a Y cable. I'm going to add switches to control which chargers get power so 15, 20, or 50 amp service can be used, ssr control to sequence turn on and shut off when the desired charge is reached, and a delay option to allow unattended charging to start later if desired. The same design could handle the fast chargers used by those bikes with more kwh than my FX.

My goal is to make it just as convenient to do partial charging as it is to just plug in and get 100%. Maybe even more convenient, with fewer power cords and dc connectors to juggle than I use now.
Title: Re: How to stop charging below 100%
Post by: togo on August 05, 2017, 09:44:25 AM
I like it.
Title: Re: How to stop charging below 100%
Post by: remmie on August 06, 2017, 01:17:54 AM
maybe the Elgato EVE energy is a better choice as it uses Bluetooth

https://www.elgato.com/en/eve/eve-energy (https://www.elgato.com/en/eve/eve-energy)

only on iOS though
Title: Re: How to stop charging below 100%
Post by: Keith on August 06, 2017, 09:15:04 PM
Design evolution continues. I'm adding AC control with two solid state relays. These will sequence the charging start and stop so that key on/off is not required to begin charging. AC input current can be 6, 8, 14, 16, or 22 amps when different combinations of FX onboard and two external QuiQ chargers are used.
Title: Re: How to stop charging below 100%
Post by: togo on August 08, 2017, 02:14:21 AM
Nice.
Title: Re: How to stop charging below 100%
Post by: Keith on August 08, 2017, 03:12:22 AM
It will be nice. Lots of metal work, required for AC wiring. I'll have a nice package when finished, power control box on top of stacked QuiQs. An improvement over my previous setup even without the Arduino. Pictures someday soon, waiting for parts...
Title: Re: How to stop charging below 100%
Post by: togo on August 13, 2017, 12:29:56 PM
I installed the WeMo app but I can't get to the settings without a device. ...

I got one. Max standby watts is 99.  So WEMO auto-standby isn't useful.


Title: Re: How to stop charging below 100%
Post by: Keith on August 18, 2017, 06:57:11 PM
Finally got my parts and finished wiring the package. Still need to finalize the code and documents but the hardware is complete and functioning. A lot of time and effort to design and build but it makes a much neater and more convenient package for my charging needs.  Features are full or partial charging at four rates; charge packs on bike or off bike; simplified AC hookup; keyless delayed charging start; optional laptop connection to change program or monitor; charge two packs simultaneous off bike at low rate; control pack discharge to inverter, heat, and lights; connect to 15amp, 20amp, 15+20amp, 30amp, 50 amp, and J1772 AC service. Design is specialized for my four pack FX off road rural useage, but is easily adapted to any charger and bike combination.
Title: Re: How to stop charging below 100%
Post by: togo on August 19, 2017, 01:36:09 AM
Awesome, really professional.

What box did you use for the arduino and dial?
Title: Re: How to stop charging below 100%
Post by: togo on August 19, 2017, 02:01:04 AM
I installed the WeMo app but I can't get to the settings without a device. ...

I got one. Max standby watts is 99.  So WEMO auto-standby isn't useful.

Back to the Wemo concept, there is a Python api available:

http://ouimeaux.readthedocs.io/en/latest/api.html#switches (http://ouimeaux.readthedocs.io/en/latest/api.html#switches)

And yes, it looks like you can read the current load and set the switch, so it should be doable if someone who knows Python has a computer on the same wifi network.

Title: Re: How to stop charging below 100%
Post by: Keith on August 19, 2017, 02:17:40 AM
The enclosure is a Hammond 1590FFL, fits on the Quiq's pretty well, had to add a 1" plate on one side to get the length for mounting.

Python is pretty easy, but needs a computer, interpreter install, wifi, and it is a command line interface. Also WeMo is only 15amps. It would probably work for onboard charger control but would not be very convenient to use. Start charging manually, then run the python on the wifi networked computer. The python code itself would be extremely simple, just shut off when a current threshold is reached. Enter a stopping current value on the command line when running.
Title: Re: How to stop charging below 100%
Post by: Keith on August 19, 2017, 02:36:47 AM
This looks interesting, javascript would be easier to use than python. https://github.com/timonreinhard/wemo-client/blob/master/examples/insight.js
Title: Re: How to stop charging below 100%
Post by: Keith on August 19, 2017, 08:35:59 AM
Updated schematic to match hardware.
Title: Re: How to stop charging below 100%
Post by: Scope on August 21, 2017, 12:08:27 AM
A quick google search finds discussions of setting the threshold, Keith:

'Select "Edit" from the main Devices screen in the App. You can then change the standby threshold to your requirements.'

Scope, what value were you able to set?  Can it be in the hundreds of watts?
I let it auto detect and it came up with 2W. I use it because Zero recommended not leaving it plugged in after a complete charge.


Sent from my iPhone using Tapatalk
Title: Re: How to stop charging below 100%
Post by: togo on August 23, 2017, 11:14:31 PM
Doesn't help with the issue: How to stop charging below 100%

Title: Re: How to stop charging below 100%
Post by: Keith on August 24, 2017, 05:14:17 AM
I'm sure the link I posted above to a javascript WeMo client will allow partial charging control with a really simple web page. I've never use Node before but I just installed it. It's easy and free and all that is needed to support a localhost server for a WeMo Insight switched outlet. The code would simply get the wattage drawn by the charger in a loop and turn the outlet off when it gets above a set wattage level that occurs at the desired charge.

I might write this js code someday when the weather is not so good for riding but I have no good reason to buy a WeMo since my partial charger is working great and handles more amps than the WeMo. From the README file here https://github.com/timonreinhard/wemo-client/blob/master/README.md

getInsightParams(cb)

Get power consumption data for a Wemo Insight Switch

Callback cb cb(err, binaryState, instantPower, data)

This took about 5 minutes to get installed and working https://nodejs.org/en/docs/guides/getting-started-guide/
Title: WeMo insight Python solution [Re: How to stop charging below 100%]
Post by: togo on September 27, 2017, 01:21:59 AM
> Back to the Wemo concept, ... it should be doable if someone who knows Python has a computer on the same wifi network.

OK, finally did it.  This is a ElementaryOS linux box (debian/ubuntu flavor, the best distro I've found to date with 4K display), a test with a chest freezer.  (I no longer can conveniently slow-charge my Zero, since somebody decided to give me a parking ticket for parking on the sidewalk overnight to charge, I pretty much only do the attended rapid-charge.)

Should also work with Raspberry Pi if you get it on the same Wifi network as the WeMo Insight

Here's how I installed:

$ sudo apt-get install python-setuptools python-dev virtualenvwrapper python-pip
$ virtualenv ouimeaux
$ cd ouimeaux/
$ pip install ouimeaux

Obviously, if you use Windows or Mac, you'll need to install it the way your OS requires.  Also, you'll need to be sure any firewall rules allow WeMo packets through.

Here's a program that measures power up to a peak value, and then stops charging when power is reduced by a particular percentage.

$ cat read_wemo_insight_power_and_turn_off.py
#!/usr/bin/python2.7

import ouimeaux.environment
import time
import os

INTERVAL_SEC=3
MIN_REDUCTION_PCT_TURN_OFF= 50


def on_switch(switch):
    print "Switch found!", switch.name

def on_motion(motion):
    print "Motion found!", motion.name

env = ouimeaux.environment.Environment(on_switch, on_motion)

env.start()
env.discover(seconds=3)

switches_name_power= dict()

for name in env.list_switches():
    s= env.get_switch(name)
    print name, s.current_power, "milliwatts"
    switches_name_power[name]= s.current_power

if len(switches_name_power) == 0:
    print "no switches detected"
    os.exit(1)

time.sleep(INTERVAL_SEC)

am_done= 0

while not am_done:
    for name in env.list_switches():
        s= env.get_switch(name)
        print name, s.current_power, "milliwatts"
        prior_power_mw= switches_name_power[name]
        if s.current_power < prior_power_mw:
            reduction_mw= prior_power_mw-s.current_power
            reduction_pct=(reduction_mw*100/prior_power_mw)
            print "%s: reduction=%d mw %d pct" % (name,reduction_mw,reduction_pct)
            if reduction_pct < MIN_REDUCTION_PCT_TURN_OFF:
                print "%s: reduction too small" % name
            else:
                print "%s: turn off" % name
                s.off()
                am_done=1
        else:
            print "%s: %dmw no reduction" % (name,s.current_power)
            # no reduction
            switches_name_power[name]= s.current_power
    if am_done: break
    time.sleep(INTERVAL_SEC)

Here's the output of a run of that program.  First there's no load I plug in a chest freezer and turn the switch on by hand:

$ python read_wemo_insight_power_and_turn_off.py
Switch found! WeMo Insight
WeMo Insight 0 milliwatts
WeMo Insight 0 milliwatts
WeMo Insight: 0mw no reduction
WeMo Insight 0 milliwatts
WeMo Insight: 0mw no reduction
WeMo Insight 0 milliwatts
WeMo Insight: 0mw no reduction
WeMo Insight 212785 milliwatts
WeMo Insight: 212785mw no reduction
WeMo Insight 158665 milliwatts
WeMo Insight: reduction=54120 mw 25 pct
WeMo Insight: reduction too small
WeMo Insight 74445 milliwatts
WeMo Insight: reduction=138340 mw 65 pct
WeMo Insight: turn off
$

Obviously, if you have more than one Wemo Insight, you'd have to identify the one in question, match it up, trivial exercises left to the reader : - )
Title: Re: How to stop charging below 100%
Post by: Keith on September 27, 2017, 05:25:48 AM
Interesting progress on the Wemo. I'd like to see if it is actually convenient with the bike. Do you have to turn it on manually? That would be back and forth from bike to computer to bike to begin charging.

I fried my Arduino! I failed to find and read a warning about using an external reference voltage. It worked for several weeks but I am pretty sure this is why it failed. Replacement nano is on the way. Here's what not to do. I've never seen a case where a missing line of code would kill a processor.

Quote
If you're using an external reference on the AREF pin, you must set the analog reference to EXTERNAL before calling analogRead().Otherwise, you will short together the active reference voltage (internally generated) and the AREF pin, possibly damaging the microcontroller on your Arduino board.

https://www.arduino.cc/en/Reference/AnalogReference
Title: Re: How to stop charging below 100%
Post by: Keith on October 18, 2017, 06:57:54 AM
I replaced the fried Nano and added a PZEM-004T energy meter to my Arduino charger controller. Now I can see the AC conditions as well as use a serial interface to monitor and log what the charger current is doing. Now back to the code, it will be final someday. Any reason to stop charging after adding a settable kWH? It could, that might be useful for testing purposes. Also could change the charge rate at some point by switching off external and topping off with onboard.
Title: Re: How to stop charging below 100%
Post by: togo on October 18, 2017, 08:25:55 AM
Interesting progress on the Wemo. I'd like to see if it is actually convenient with the bike. Do you have to turn it on manually? That would be back and forth from bike to computer to bike to begin charging....

No, you don't have to start it manually, adding the code to start the switch is very simple, and then I'd just add an extra sleep after that to give it time to come up to speed.  The sample code doesn't differentiate switches either, if you have more than one.  it was just meant to demonstrate that it could be done, to be used as fodder for someone to adapt to their own needs.

PS: be sure to call it the Wemo *Insight*, there are many Wemo devices and most of them *don't* measure energy use.
Title: Re: How to stop charging below 100%
Post by: togo on October 18, 2017, 11:27:56 PM
> I replaced the fried Nano and added a PZEM-004T energy meter to my Arduino ...

that PZEM-004T is pretty cool, it uses a coil over one of the ac lines to measure the power use, so it's nicely isolated

> Any reason to stop charging after adding a settable kWH? It could, that might be useful for testing purposes.

I imagine if you wanted to do repeated tests of some kind.

> Also could change the charge rate at some point by switching off external and topping off with onboard.

Not sure what benefit that is.
Title: Re: How to stop charging below 100%
Post by: Keith on October 19, 2017, 01:46:27 AM
According to this the PZEM is not so nicely isolated from the serial port, but what me worry? http://forum.arduino.cc/index.php?topic=435594.0 I did find a very nice arduino library that makes it easy to communicate with https://github.com/olehs/PZEM004T Too bad I wasted a lot of time trying to make the serial connection work without documentation first. 9600 baud, connect vcc to 5v, rx tx are null modem connect to tx rx.

I've seen some express concern that using the Quiq's is not as good for cell balancing as the onboard. I will now be able to measure and log the charger current and battery voltage under a variety of conditions, maybe I will learn something, or maybe not, but I'll have data!
Title: Re: How to stop charging below 100%
Post by: Keith on November 07, 2017, 08:18:02 PM
After bricking two Arduino Nano's in my charger controller, I've decided to make major hardware changes for better reliability. Connecting Arduino ground to bike pack negative is convenient, but probably not good considering paths to AC ground through USB and transients through other power connections. Isolating the pack negative from circuit ground isn't  simple but here is my plan in case anyone is interested. Parts on the way. I'm going to a Ruggeduino to get added protection against transients.
Title: Re: How to stop charging below 100%
Post by: togo on November 08, 2017, 12:23:20 AM
How about powering the Arduino from USB, AC brick?
Title: Re: How to stop charging below 100%
Post by: Keith on November 08, 2017, 02:59:39 AM
I'm not sure where the lethal spikes are coming from, but the Arduino power source is not a likely culprit. Ground current through USB is a suspect, as well as coupling through the bike, SSR's and the AC power meter. All are isolated in theory but parasitics and leakage are there combined with high currents. In any case the Ruggeduino has PTC resettable fuses on all pins, that will help. And isolating from the DC negative is going to stop anything on the enable line from finding a weak input circuit. This will probably be overkill, but after two Nano fatalities, something had to be done, this is something. This is my Tesla Wall controller as well as my charge controller as well as my data acquisition system. I want to use it, not fix it again.
Title: Re: How to stop charging below 100%
Post by: Keith on November 09, 2017, 09:02:35 PM
Here's the complete schematic for the latest "rugged" version. Processor circuit ground is DC isolated from AC line ground and resistively isolated from the bike battery negative. Maintaining DC isolation in some cases may require lifting AC ground to bike and/or the USB connection. If DC ground isolation is not achieved, the battery voltage measurement will be affected by any lack of isolation on the bike; this is only important for the partial charging set point accuracy or measurement precision.
Title: Re: How to stop charging below 100%
Post by: wijnand71 on February 04, 2018, 03:36:16 AM
Great schematic! I try to read and understand all Opto’s and transistors you’re using..  For the keyless charge start, which I want to incorporate in my eltek charger, what code do I need in my arduino? Also the batt - and arduino gnd connections are interesting. Should be connected via a resistor?
Title: Re: How to stop charging below 100%
Post by: Keith on February 04, 2018, 08:10:41 PM
I'm still working on this project, it functions but isn't quite there yet. The isolation is done for reliability, power transients killed two of my Arduinos. The resistors keep the grounds separate and attempt to convert the battery voltage into a current that can then be measured as voltage by the Arduino without a ground connection. It works but gets inaccurate in measuring the DC battery voltage due to AC ground currents when a laptop, charger and bike are all connected. I think that can be cured but I haven't done so yet. The optos allow control of the charger enable line without a ground connection, but are really not needed for most applications since AC power switching is probably the best way to control the chargers, rather than using the enable signal.

The code for a keyless charge start would simply switch on AC power to the onboard charger to get the bike into charge mode with the contactor closed. And then turn on the external charger AC and continue to charge with both or just external as desired.

For stopping the charging below 100%, I have a new approach that I will post here soon, using a DC meter to provide accurate measurement and a with a user interface to show and set the charge level desired. It will tell the Arduino when to turn off the charger AC. See this post http://electricmotorcycleforum.com/boards/index.php?topic=7592.msg63907#msg63907 It took almost 2 months to get the back ordered DC converter to power the meter. I have it working now but not yet connected to the Arduino.
Title: Re: WeMo insight Python solution [Re: How to stop charging below 100%]
Post by: togo on February 15, 2019, 07:05:55 AM
> Back to the Wemo concept, ... it should be doable if someone who knows Python has a computer on the same wifi network.
...

After spending some time looking for 240VAC Wemo Insights from European marketplaces, I came across this, which indicates Wemo Insights are voltage-flexible. 

https://community.wemo.com/t5/WEMO-Hardware/Wemo-Insight-and-Light-Switch-are-auto-voltage/td-p/24641

No guarantees, but I'm carefully testing my North America WeMo Insight with the 240VAC circuit, and if all goes well, I'll be using this method to charge to less than 100% by detecting the end of constant-current mode.

Title: Re: How to stop charging below 100%
Post by: togo on June 20, 2019, 04:19:35 AM
And, so far, the F7C029, intended for north america has not exhibited any issues on 240VAC.

I am *not* recommending anyone else take this risk, but it hasn't burned my house down, eaten my cat, or abducted my wife.