stuartpittaway / diyBMSv4ESP32

diyBMS v4 code for the ESP32 and new controller hardware
Other
179 stars 80 forks source link

controlling with RE1 and RE2 a remote battery switch (controlled by momentary SPDT switch) #121

Open virtuvas opened 2 years ago

virtuvas commented 2 years ago

@stuartpittaway

we've (vaguely) discussed that before in another thread on the forum without a final conclusion (I think!). Anyway, I'm now trying to finish off the installation by connecting the BlueSea Remote Battery Switch/Solenoid Switch to the system: image

Problems is that it is designed to be controlled by a momentary SPDT switch, or two momentary push button switches. Trying to simulate that using the diyBMS controller means that I have to use both RE1 and RE2 on the NO side, one for connecting and one for disconnecting the bank to the system.

The reason for NOT using only one relay is that I'd then have to have power to the one contactor coil constantly. Which is stated as a no go by the factory! So, have to have both brown (closed circuit) and orange (open circuit) not powered when system is running.

So with the existing rule setup, I can wire say orange (get bank offline) to NO of the one of the two relays. Means that system runs normally, when one of the rule conditions is met a pulse to the NO output means bank is disconnect.

OK, all that is quite obvious, what is NOT (at least to me!) is that when ALL rules come back to reset values (so no trigger is active!), system must get online again. Now, that I cannot do as there's no way to program that in the existing rule setup.

to summarise: ANY trigger, RE1 goes ON (pulse) -> BlueSea gets bank offline -OK, we got that! NO trigger (or if you wish ALL reset values TRUE), RE2 goes ON (pulse) -> BlueSea gets bank back online -How can we do that?

Am I missing something, or the only way to do it is by employing an external device and some coding? Not keen on having more h/w to do something obvious,

cheers V

stuartpittaway commented 2 years ago

The relays were designed to trigger under fault conditions, so the original idea was that the controller rules would disconnect the power, but that would then need to be manually switched back on, once the problem/fault was repaired.

virtuvas commented 2 years ago

well, surely makes sense, was thinking how to disable and re-enable the bank according to needs/consumption/weather in an automated fashion. Actually main task of the relays would be to get lifepo4 bank offline when engine is running and alternator starts pumping loads of amps that I don't want on a full bank (from solar) - sterling advanced alternator regulator precedes lifepo4 tech and charge profiles and not too keen to spent money on something used rarely.

Guess I could have a custom routine running and checking if there's a flag up (from any rule) and if so do nothing, but if no flag is up, run a pulse on another relay or something...

cheers V.

stuartpittaway commented 2 years ago

Ah, I've also got a sterling advanced regulator, or did have, I removed it from my boat.

Have you checked out the canal world discussion forum? They go through a lot of experiments and solutions to work with existing alternators and lithium banks. Especially as alternators can be easily destroyed when the battery is disconnected

virtuvas commented 2 years ago

yep, hence me keeping in parallel the Trojan T105RE bank already onboard so when I disconnect, I wont burn the diodes as the other bank is always there to take the load πŸ˜€ thing is my charging is done 95% from solar and another 4-5 shared between engine and generator, Generator is through a Victron Multiplus, so managed from the CANBUS and safe, only "loose" charging is from the alternator. Can go to B2B chargers but cost money not really worth it (for my useage at least)

cheers V.

stuartpittaway commented 2 years ago

Ok. So I can add rules into the system, I just need to know how to drive them.

There is also the 4 input/output pins on the controller which don't currently get used. These could also be used to trigger a relay or similar.

virtuvas commented 2 years ago

two issues (I can roughly think of atm but it's a hard and long day...)

A. the 4 in/out pins could be used to "monitor" contactor condition (yellow wire on the BlueSea one) or other state of machinery related. Catch is that in my case that's outputting 24V when contactor (and bank!) in online. B. obvs once disconnected in the conditions I've described in my previous post, voltage/current to the shunt will be back to normal. Which means system rules will be back to normal and controller would like to re-engage the bank - which will end up in a nice pointless loop (would timer1 and 2 help here?)

I recon it would make more sense to have a "sense" wire from the alternator so when engine is running AND V or A goes in rule triggering values, system will be taken offline and WONT reset before sense wire from alternator goes off (engine stopped)

let me think about it because for sure there are quite a few BlueSea contactors on boats around, but the above described approach is not generic at all to be worth spending time on this. I'll come back over the w/e

For sure the ONE rule that could be added is NO RULE TRIGGERED sort of thing. If it could have a delay up to 20mins it could do a crude job for contactors.

cheers V.

stuartpittaway commented 2 years ago

The no rule triggered already exists as the default rule set!

virtuvas commented 2 years ago

not quite though, cannot assign RE2 activated when no rule triggered is true! And on a pulse, once. How? So, bank V over triggered, have RE1 activated (orange cable on BlueSea) so a pulse turns contactor off. Then V over goes under reset value, what now? don't want RE1 deactivated sending 24V constantly to the contactor to turn it on, just a pulse is all I need. So I have to use another relay, say RE2 and on what condition I have to activate RE2 again with a pulse to turn contactor on? that's the missing rule (imho)

stuartpittaway commented 2 years ago

Yeah, you are correct not with pulse outputs

virtuvas commented 2 years ago

thought about it, unless I understand the code and do a mix match of reading an input for current state of contactor + checking rules and pulsing ONCE either RE1 or RE2 for say connect and disconnect it doesn't look like I can use current setup. For starters tried pulse and the thing is pulsing ALL the time (every few secs!) is that something that can be configured to be done once only? if I have time of the w/e I'll try to understand the coding around the relay operation and see what I can come up with a working solution: Input0 would be wired to one of the four inputs. Catch is that in the BlueSea it's open when disconnected, and GND when contactor is on (guess to avoid issues with high voltages going to control systems and causing havoc), Rules set on RE1.

IF Input0 is open circuit AND RE1 is in NC position (not activated) THEN pulse RE2 once to activate contactor IF Input0 is GND and RE1 is in NC do nothing (contactor is activated) IF Input0 is GND and RE1 is in NO means a rule is set THEN Pulse RE1 ONCE to turn off contactor. Too easy? 😁

The other option of using an external board with say RE1 NO and NC wired to it is also looking rather difficult as you'll end up replicating the logic within the controller...

of course in the meantime if you create an NO RULES SET rule that I can wire to RE1 fe, and if pulse can be configured to only pulse once, I could get away with editing code 😁

cheers

V. PS. about to upload the new merged code to the boat system which is running without a problem for over a week, with CAN and influx all running nicely

virtuvas commented 2 years ago

good morning @stuartpittaway ,

thought a bit more and realised that what I typed above is simply unachievable as when disconnecting the contactor, diyBMS wont know what the voltage/current floating from the uncontrolled power source (in my case the alternator) is! So need a second independent current monitor/controller/instruction outside the diyBMS scope - I have my Victron BMV700 and I could use its relay fe.

So, a viable solution seem to me to use diyBMS as is (with pulse working properly to disconnect the BlueSea contactor, the way it has been designed by you.

Then source and process info on the VenusOS raspberry pi (V and A coming in), victron current monitor, or other controller and based on that send a signal to diyBMS (guess one of the four unused inputs) which will then energise in pulse mode another relay (say RE2 as a decent contactor needs up to 10A for a few msecs to do it's thing!) to connect the BlueSea contactor again.

So, how about having Rules for the four inputs like:

InputA [trigger value HIGH], [reset value LOW] (with a simple pull down to swap high and low maybe?) guess hi would mean 3.3V and low GND with the danger of dumping higher voltages and destroying the controller 😨 Personally would be happy to only allow pulling low (as in GND connections to the relevant Input!)

Then any external input be it in my case the VenusOS calculations and raspberry IO pins, or the Victron current monitor relay, or a NodeRed instruction given remotely or whatever could get the bank online again.

what do you think?

cheers V.