diy solar

diy solar

Interfacing with Valence built in monitoring

You could of course not use a BMS at all, as long as the chargers cut of at safe voltage. I would set that below the maximum om 14,6v, to not harm any cells if they end up unbalanced, especially if you have a number of batteries in series.

The following is excerpted from https://marinehowto.com/lifepo4-batteries-on-boats/

When reading info on the net that suggest such things such as “13.8V is only 80% SoC for 12V nominal LFP battery“, please do yourself a favor and take this hog wash with a grain of salt. Alternatively, do what we do here in the CMI lab and test these nonsensical claims. An LFP cell will attain 100% SoC at voltages well below 3.6V, if the voltage duration is held long enough, as many lead acid charger do!


Most lead acid designed charge sources can hold the absorption voltage stage more than long enough to cause long term damage or eat into some cycle life capacity of your expensive LFP cells. Some LFP manufacturers are now starting to understand this point, when selling into a lead-acid charger environment, and have reduced recommended max charging voltages accordingly. Of course, some others have not. The quality of the cells used inside the battery also play a major role as to how well they deal with constant voltage being held longer than is necessary.


I recently had four prismatic cells in the shop, sent to me by a gentleman who assumed a GEL setting on his charger was safe. He decided this based on Winston’s voltage specifications. He assumed, seeing as it was only 14.2V or 3.55VPC, and well within the spec, that 14.2V was safe for a nominal 12V bank. However, as I mentioned earlier, voltage is not the only factor to consider. You have voltage, duration at target voltage, and charge rate to also consider.
 
I'm starting to mess around with the python utility script that just reports batt v and temp from battery 1. I have tried to change the ID on my battery with no luck. My battery ID is 12. I've been trying to change payloadW = [0x00,0x00,0x01,0x01,0xc0,0x74,0x0d,0x0a,0x00,0x00] and payloadV = [0x01,0x03,0x00,0x45,0x00,0x09,0x94,0x19,0x0d,0x0a] to see if I can get any results, but no luck so far. Is payloadW id sensitive or is it just a general "everybody up" sort of message? For payloadV, I was thinking change the first part from 0c01to 0x0c, but I just get back "b", not a string of values. Any ideas on how to crack this? Also investigating ways to verify the script is actually talking to the com port. I see the lights flutter for a second, when I run the script, but it seems to do that no matter what com port I select, so I'm not sure that's even working.

I found that the request packet appears to have a checksum so just changing the ID didn't work.
I sniffed the RS-485 bus while the Valence SW was talking and found the proper packet formats for my other 3 battery IDs.
Attached is my python script I hacked up for checking and displaying all 4 of my battery IDs.

For reference, here are the payload packets for IDs 2-4;
payloadV2 = [0x02,0x03,0x00,0x45,0x00,0x09,0x94,0x2a,0x0d,0x0a]
payloadT2 = [0x02,0x03,0x00,0x50,0x00,0x07,0x04,0x2a,0x0d,0x0a]
payloadV3 = [0x03,0x03,0x00,0x45,0x00,0x09,0x95,0xfb,0x0d,0x0a]
payloadT3 = [0x03,0x03,0x00,0x50,0x00,0x07,0x05,0xfb,0x0d,0x0a]
payloadV4 = [0x04,0x03,0x00,0x45,0x00,0x09,0x94,0x4c,0x0d,0x0a]
payloadT4 = [0x04,0x03,0x00,0x50,0x00,0x07,0x04,0x4c,0x0d,0x0a]

Richard
 

Attachments

  • Valence_2.py.txt
    7.2 KB · Views: 44
Last edited:
I found that the request packet appears to have a checksum so just changing the ID didn't work.
I sniffed the RS-485 bus while the Valence SW was talking and found the proper packet formats for my other 3 battery IDs.
Attached is my python script I hacked up for checking and displaying all 4 of my battery IDs.

For reference, here are the payload packets for IDs 2-4;
payloadV2 = [0x02,0x03,0x00,0x45,0x00,0x09,0x94,0x2a,0x0d,0x0a]
payloadT2 = [0x02,0x03,0x00,0x50,0x00,0x07,0x04,0x2a,0x0d,0x0a]
payloadV3 = [0x03,0x03,0x00,0x45,0x00,0x09,0x95,0xfb,0x0d,0x0a]
payloadT3 = [0x03,0x03,0x00,0x50,0x00,0x07,0x05,0xfb,0x0d,0x0a]
payloadV4 = [0x04,0x03,0x00,0x45,0x00,0x09,0x94,0x4c,0x0d,0x0a]
payloadT4 = [0x04,0x03,0x00,0x50,0x00,0x07,0x04,0x4c,0x0d,0x0a]

Richard
Is this with arduino uno? Was any 4 module relays attached? Any voltage divider? Thanks
 
I found that the request packet appears to have a checksum so just changing the ID didn't work.
I sniffed the RS-485 bus while the Valence SW was talking and found the proper packet formats for my other 3 battery IDs.
Attached is my python script I hacked up for checking and displaying all 4 of my battery IDs.

For reference, here are the payload packets for IDs 2-4;
payloadV2 = [0x02,0x03,0x00,0x45,0x00,0x09,0x94,0x2a,0x0d,0x0a]
payloadT2 = [0x02,0x03,0x00,0x50,0x00,0x07,0x04,0x2a,0x0d,0x0a]
payloadV3 = [0x03,0x03,0x00,0x45,0x00,0x09,0x95,0xfb,0x0d,0x0a]
payloadT3 = [0x03,0x03,0x00,0x50,0x00,0x07,0x05,0xfb,0x0d,0x0a]
payloadV4 = [0x04,0x03,0x00,0x45,0x00,0x09,0x94,0x4c,0x0d,0x0a]
payloadT4 = [0x04,0x03,0x00,0x50,0x00,0x07,0x04,0x4c,0x0d,0x0a]

Richard
Sorry, didn't see the reply sooner. So it looks like it's time to get sniffing on my battery then. Or figure out the checksum... So to set up the sniffer, just need another USB/RS-485 adapter (without the power line connected) and connector for the other plug on the battery side. Fire up the Valance software and capture what happens. For the capture side, is there a popular program for that? I know of wireshark. It's been years since I've messed with that. Any pointers would be appreciated.
Thanks,
Mike
 
Hey All,

I'm just getting back to working on this project again; All of the work you've all been doing looks fantastic!

If any of you are working on more complex projects for other platforms such as RPi and want specifics on how to obtain certain data from the Valence system, please reach out to me via PM. I don't include it in the repository because I don't want any issues to arise by publicly disclosing the information.
 
Hi All,

I have a pretty big update: CRC has been implemented and has been pushed to the master branch. OpenXPBMS now supports reading from multiple batteries without having to specify modbus messages for each battery! All you need to do is add the HEX value of each battery ID in your battery network to the batteries array before uploading the sketch to your board. Please test it out and provide feedback!
 
Hi @t3chN0Mad
Looks great what you've done so far. I'm excited to try it out, and hope you can give me a couple of pointers to get started. I have a bit of experience with electronics and programming PICs, but haven't used these tech-skills in a while so kind of rusty :)

My setup is 2 parallel U27-12XP in a campervan, charged by a Votronic Solar/DC-DC/Mains charge controller, with a Victron BatteryProtect for low voltage protection and as a manual disconnect relay.

What I would like to achieve is to
(a) Keep the Valence internal BMS awake so the intra-module balancing is active.
(b) Provide a signal to the charge controller to disable charging in case of individual cell over-voltage or over-temperature.
(c) Provide a signal to the BatteryProtect to disconnect load in case of individual cell under-voltage.

I saw in your repository that you are using an Adafruit Grand Central M4 Express and have designed an auxiliary PCB for the application. But I'm hoping that for my simple requirements I can use a cheaper/smaller/lower power board without an extra PCB.

I wonder if you can help me choose a suitable Arduino board which will be:
- Compact
- Low power
- Runs from 12V
- Capable of direct RS485 communication and providing 5V for the Valence internal BMS
- Capable of outputting (low current) signals to the charge controller and BatteryProtect *
- Native USB to program it

* I'm aware I might need to add a MOSFET and couple of resistors to get a 12V signal.

I don't have much experience with Arduino, but from a quick browse of the Arduino website, it seems like even a Nano should be able to do this?
I guess I will have to rewrite some of your board-specific code, but before I dive in to learning how to do this, do you think something like a Nano will be suitable?

Thank you,
Seb
 
A nano will be more than enough to do that ;)
A nano is definitely capable, but it's not going to have all of those features built in; additional hardware is needed, just like pretty much any other Arduino type board someone would choose including the Grand Central. Just don't expect that you can run the nano and that's it.

Also, the sketch assumes it's running on some sort of board with a SAMD51 processor; if you're running on something else then you'll need to modify some of the code in order to get serial working, etc.

I originally started with the Grand Central because it was more than enough powerful to implement features I might consider adding in the future and it was only $10 more than the regular Metro. I didn't want to have to rebuy a board in the future if the project outgrew the smaller ones.
 
A nano is definitely capable, but it's not going to have all of those features built in; additional hardware is needed, just like pretty much any other Arduino type board someone would choose including the Grand Central. Just don't expect that you can run the nano and that's it.

I have limited experience with Arduino, so maybe I'm missing something. But so far I believe that I will be able to implement a basic BMS *almost* completely on a Nano.

For my application I need it to send (low current) 12V signals to the charge controller and load relay controller, so I'll need something to convert from 5V to 12V (e.g. a MOSFET and couple of resistors). Then I will add a few LEDs for status display. Hopefully it will be minimal enough that it can either hang off the Nano board itself, or fit onto a small piece of stripboard.

Also, the sketch assumes it's running on some sort of board with a SAMD51 processor; if you're running on something else then you'll need to modify some of the code in order to get serial working, etc.

The Nano only has 1 serial port / UART, which is needed to output debug information to the computer during development. But I found the SoftwareSerial Library which allows to use other I/O pins. I haven't figured out if this will support half duplex RS485 yet though...
 
I'm coming to the conclusion that I'm going to need some external components for the RS485 interface. Although I believe the batteries use 5V levels, I don't think it will be reliable to implement a differential communication signal in software alone.

So the hardware footprint is increasing slightly.
 
I have limited experience with Arduino, so maybe I'm missing something. But so far I believe that I will be able to implement a basic BMS *almost* completely on a Nano.

For my application I need it to send (low current) 12V signals to the charge controller and load relay controller, so I'll need something to convert from 5V to 12V (e.g. a MOSFET and couple of resistors). Then I will add a few LEDs for status display. Hopefully it will be minimal enough that it can either hang off the Nano board itself, or fit onto a small piece of stripboard.

Well, I'm doing an advanced one with a Nano so a basic one is totally possible ?

Yep, I don't see much components needed beside the 5 to 12 V level shifting.

With some creative soldering you can mount everything on the arduino itself but I would recommend using a bit of perf/strip board to make things cleaner ;)

The Nano only has 1 serial port / UART, which is needed to output debug information to the computer during development. But I found the SoftwareSerial Library which allows to use other I/O pins. I haven't figured out if this will support half duplex RS485 yet though...

You can always bit bang any protocol on any I/Os if you don't need super high speed, it's all software. Also the serial port is used for the USB com but if you don't use the USB port in normal operation (but just for programming) you can use the serial port for whatever you want. Just be careful about the fact it'll output random stuff while you're connected by USB so it's best to unplug anything else connected to it during that time.
 
Also, based on my experience the RS485 boards commonly sold which have the auto-TX/RX will not work in this application because the battery responds before it switches back to RX and misses part of the message. I went to a board with a TX/RX switching pin and it works fine.
 
Hmmm, interesting. I guess if you have 2 I/Os to spare you can dedicate the original 2 for TX and add the other 2 for RX (ideally ones supporting interrupts) so you don't miss anything.
 
Also, based on my experience the RS485 boards commonly sold which have the auto-TX/RX will not work in this application because the battery responds before it switches back to RX and misses part of the message. I went to a board with a TX/RX switching pin and it works fine.

Ah, that's a shame. I was looking at this inexpensive RS485 board:

It's based on the MAX13487E which looks like a good chip, but unfortunately the above board doesn't expose the Read Enable input, so it's locked in AutoDirection mode. It looks possible to hack the board to connect to this pin, but messy :(

Arduino do a more flexible board:
But it's designed to fit to their MKR boards which all need 5V, meaning extra components to run from 12V.

So still looking for a neat solution using off the shelf boards ...
 
You can always bit bang any protocol on any I/Os if you don't need super high speed, it's all software.

I'm not sure this is true for differential signals like RS485. Vehicles are electrically noisy places. I think a proper differential transceiver would be better.
 
Back
Top