Energy Controller including CCS interface
- johu
- Site Admin
- Posts: 6975
- Joined: Thu Nov 08, 2018 10:52 pm
- Location: Kassel/Germany
- Has thanked: 457 times
- Been thanked: 1774 times
- Contact:
Energy Controller including CCS interface
As mentioned here I've always wanted to create an all-in-one energy controller to clean up the mess in my basement. It is based on the popular BeagleBone Black or Green, so it's called a "cape".
Hardware-wise it is mainly communication stuff. The task of the thing is to control various energy conversion equipment such as
- PV inverters
- Batteries (or BMSes to be precise)
- CCS
- Relays
It also talks to web services such as spot market price providers, data loggers and of course has infinite connectivity over Wifi or Ethernet.
I pretty much copied the hardware that I currently use so the interfaces are
- 2x CAN
- 1x PLC for CCS charging, including CP signalling
- 2 relay drivers
- Input for push button with LED (button just shorts out LED current
I might add RS485 as well as I have only used up 10 of 12 screw terminals.
So far this is how it looks PLC part still to be done.
Hardware-wise it is mainly communication stuff. The task of the thing is to control various energy conversion equipment such as
- PV inverters
- Batteries (or BMSes to be precise)
- CCS
- Relays
It also talks to web services such as spot market price providers, data loggers and of course has infinite connectivity over Wifi or Ethernet.
I pretty much copied the hardware that I currently use so the interfaces are
- 2x CAN
- 1x PLC for CCS charging, including CP signalling
- 2 relay drivers
- Input for push button with LED (button just shorts out LED current
I might add RS485 as well as I have only used up 10 of 12 screw terminals.
So far this is how it looks PLC part still to be done.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
- tom91
- Posts: 2754
- Joined: Fri Mar 01, 2019 9:15 pm
- Location: Bristol
- Has thanked: 264 times
- Been thanked: 717 times
Re: Energy Controller including CCS interface
RS485 is a good idea for an industrial AC energy meter, or do you have a plan to route those over something like Home Assistant?
- johu
- Site Admin
- Posts: 6975
- Joined: Thu Nov 08, 2018 10:52 pm
- Location: Kassel/Germany
- Has thanked: 457 times
- Been thanked: 1774 times
- Contact:
Re: Energy Controller including CCS interface
Yes and also for simulating an energy meter e.g. for Huawei inverters that have no other means of controlling their feed-in power.
First cut done, only RS485 missing SPI flash can be connected to the SPI bus for initial programming by the BeagleBone itself
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
- johu
- Site Admin
- Posts: 6975
- Joined: Thu Nov 08, 2018 10:52 pm
- Location: Kassel/Germany
- Has thanked: 457 times
- Been thanked: 1774 times
- Contact:
Re: Energy Controller including CCS interface
Before ordering I wanted to make sure that I can talk to the QCA with the linux kernel.
It is a bit of a palaver.
Here's the howto running QCA7000 on BeagleBone via SPI
Find out which kernel your BeagleBone is running:
Now you need to get the matching kernel. On your desktop PC run
obviously you need to checkout the version matching your kernel in the 3rd command
The script will now endlessly download stuff (I think the standard linux kernel) and patch it. Then it will open the configuration menu. You need to set
So once you find Qualcomm Devices you select them with the space key. Then the various devices show up and you select ....QCA7000 SPI and press M.
Then navigate to the Save button and press it, then Exit by selecting "Exit" until the menu exits
Then the build process automatically starts.
Now in the "deploy" directory you will find 5.10.168-ti-r71-modules.tar.gz. Open it and navigate to
Here you'll find two .ko.xz files. Copy them to your BeagleBone
Now back to the BeagleBone console. Extract the xz files and copy them into the kernel tree with
Now create the file
and put the following code into it:
The interrupt line of the QCA chip is connected to P9_15 and the other pins are connected to P9 as well:
SPI0_CS:17 -> CS
SPI0_D1:18 -> MOSI
SPI0_D0:21 -> MISO
SPI0_CLK:22 -> CLK
Now compile the device trees and copy the new file where it is expected with
Now in /boot/uEnv.txt enable the new file with
Of course it can be any other addrX, too if you're already using other files.
Now reboot and watch the debug terminal in case something goes wrong.
Ultimately you should see
Check that you can find the chip with
Now pyPLC should run as well
It is a bit of a palaver.
Here's the howto running QCA7000 on BeagleBone via SPI
Find out which kernel your BeagleBone is running:
Code: Select all
> uname -r
< 5.10.168-ti-r71
Code: Select all
git clone https://github.com/RobertCNelson/ti-linux-kernel-dev.git
cd ti-linux-kernel-dev/
git checkout 5.10.168-ti-r71
./build_kernel.sh
The script will now endlessly download stuff (I think the standard linux kernel) and patch it. Then it will open the configuration menu. You need to set
Code: Select all
Device Drivers -> Network Device Support -> Ethernet Driver Support -> [*] Qualcomm Devices -> <M> Qualcomm Atheros QCA7000 SPI supportThen navigate to the Save button and press it, then Exit by selecting "Exit" until the menu exits
Then the build process automatically starts.
Now in the "deploy" directory you will find 5.10.168-ti-r71-modules.tar.gz. Open it and navigate to
Code: Select all
./lib/modules/5.10.168-ti-r71/kernel/drivers/net/ethernet/qualcommNow back to the BeagleBone console. Extract the xz files and copy them into the kernel tree with
Code: Select all
xz -d qca_7k_common.ko.xz
xz -d qcaspi.ko.xz
sudo mkdir /lib/modules/5.10.168-ti-r71/kernel/drivers/net/ethernet/qualcomm
sudo mv *.ko /lib/modules/5.10.168-ti-r71/kernel/drivers/net/ethernet/qualcomm
sudo depmod -a
Code: Select all
/opt/source/bb.org-overlays/src/arm/BB-SPI0-QCASPI-00A0.dtsCode: Select all
/*
* Copyright (C) 2019 Tomas Arturo Herrera Castro <taherrera@uc.cl>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* Written as part of my master's thesis at PUC Chile,
* to run the BeagleBone as an OpenThread Border Router w/o an NCP.
*
* https://www.sltech.cl
*
* Compiled using: make ./src/arm/BB-SPI0-QCASPI-00A0.dtbo
*
* Tested on BeagleBone Black Rev. C + REB233-XPRO. Linux beaglebone 4.14.71-ti-r80.
*
*/
/dts-v1/;
/plugin/;
#include <dt-bindings/board/am335x-bbw-bbb-base.h>
#include <dt-bindings/pinctrl/am33xx.h>
#include <dt-bindings/interrupt-controller/irq.h>
/ {
/*
* Helper to show loaded overlays under: /proc/device-tree/chosen/overlays/
*/
fragment@0 {
target-path="/";
__overlay__ {
chosen {
overlays {
BB-SPI0-QCASPI-00A0 = __TIMESTAMP__;
};
};
};
};
/*
* Free up the pins used by the cape from the pinmux helpers.
*/
fragment@1 {
target = <&ocp>;
__overlay__ {
P9_17_pinmux { status = "disabled"; }; /* P9_17 (A16) spi0_cs0.spi0_cs0 */
P9_18_pinmux { status = "disabled"; }; /* P9_18 (B16) spi0_d1.spi0_d1 */
P9_21_pinmux { status = "disabled"; }; /* P9_21 (B17) spi0_d0.spi0_d0 */
P9_22_pinmux { status = "disabled"; }; /* P9_22 (A17) spi0_sclk.spi0_sclk */
P9_15_pinmux { status = "disabled"; }; /* irq P9_15 (R13) gpmc_a0.gpio1[16] */
};
};
fragment@2 {
target = <&am33xx_pinmux>;
__overlay__ {
bb_qca_pins: bb_qca_pins {
pinctrl-single,pins = <
AM33XX_PADCONF(AM335X_PIN_GPMC_A0, PIN_INPUT_PULLDOWN, MUX_MODE7) /* irq P9_15 (R13) gpmc_a0.gpio1[16] */
>;
};
spi0_qca_s0: spi0_qca_s0 {
pinctrl-single,pins = <
AM33XX_PADCONF(AM335X_PIN_SPI0_SCLK, PIN_INPUT, MUX_MODE0) /* P9_22 (A17) spi0_sclk.spi0_sclk */
AM33XX_PADCONF(AM335X_PIN_SPI0_D0, PIN_INPUT, MUX_MODE0) /* P9_21 (B17) spi0_d0.spi0_d0 */
AM33XX_PADCONF(AM335X_PIN_SPI0_D1, PIN_INPUT, MUX_MODE0) /* P9_18 (B16) spi0_d1.spi0_d1 */
AM33XX_PADCONF(AM335X_PIN_SPI0_CS0, PIN_INPUT, MUX_MODE0) /* P9_17 (A16) spi0_cs0.spi0_cs0 */
>;
};
};
};
fragment@3 {
target = <&spi0>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&spi0_qca_s0>;
eth1: qcaspi@0 {
compatible = "qca,qca7000";
pinctrl-names = "default";
pinctrl-0 = <&bb_qca_pins>;
spi-max-frequency = <12000000>;
reg = <0>;
interrupt-parent = <&gpio1>;
interrupts = <16 IRQ_TYPE_EDGE_RISING>; /* gpio1[16] active high */
};
};
};
};SPI0_CS:17 -> CS
SPI0_D1:18 -> MOSI
SPI0_D0:21 -> MISO
SPI0_CLK:22 -> CLK
Now compile the device trees and copy the new file where it is expected with
Code: Select all
cd /opt/source/bb.org-overlays/
make
sudo cp src/arm/BB-SPI0-QCASPI-00A0.dtbo /lib/firmware/
Code: Select all
uboot_overlay_addr0=BB-SPI0-QCASPI-00A0.dtbo
Now reboot and watch the debug terminal in case something goes wrong.
Ultimately you should see
Code: Select all
[ 28.949382] qcaspi spi0.0: ver=0.2.7-i, clkspeed=12000000, burst_len=5000, pluggable=0
[ 29.041706] qcaspi spi0.0: Using random MAC address: 56:7b:be:8b:cd:74
Code: Select all
> int6klist -v -i eth1
00000000 00 B0 52 00 00 01 AA 38 9F A8 13 32 88 E1 00 00 ..R....8...2....
00000010 A0 00 B0 52 00 00 00 00 00 00 00 00 00 00 00 00 ...R............
00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000030 00 00 00 00 00 00 00 00 00 00 00 00 ............
00000000 AA 38 9F A8 13 32 04 65 65 FF FF FF 88 E1 00 01 .8...2.ee.......
00000010 A0 00 B0 52 00 22 25 4D 41 43 2D 51 43 41 37 30 ...R."%MAC-QCA70
00000020 30 35 2D 31 2E 31 2E 30 2E 37 33 30 2D 30 34 2D 05-1.1.0.730-04-
00000030 32 30 31 34 30 38 31 35 2D 43 53 00 CC CC CC CC 20140815-CS.....
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
-
PoloLbricolo
- Posts: 104
- Joined: Wed Apr 10, 2019 2:32 pm
- Location: France
- Has thanked: 3 times
- Been thanked: 11 times
Re: Energy Controller including CCS interface
Super interesting subject ! Could this be used to do bi-directional charging from solar / to house ?
- uhi22
- Posts: 1146
- Joined: Mon Mar 14, 2022 3:20 pm
- Location: Ingolstadt/Germany
- Has thanked: 231 times
- Been thanked: 639 times
Re: Energy Controller including CCS interface
This is exactly the topic. However, this is just the control box, it needs an additional power device like a hybrid solar inverter.
Github: http://github.com/uhi22 --- Patreon: https://www.patreon.com/uhi22
- johu
- Site Admin
- Posts: 6975
- Joined: Thu Nov 08, 2018 10:52 pm
- Location: Kassel/Germany
- Has thanked: 457 times
- Been thanked: 1774 times
- Contact:
Re: Energy Controller including CCS interface
And it's on the table
Almost worked out of the box, some resistors were not fitted and there ist a minor mistake in the pin mapping of the boost converter that makes +-12V for CP PWM.
With that fixed we have PWM and the QCA chip is detected and communicates
Currently no firmware on the flash, I'm trying to figure out whether I can flash it via plctools without messing with the solder jumpers. If anyone knows where to find a firmware image for the QCA7005 or how to extract it from uhis binary, let me know
https://github.com/uhi22/Ioniq28Investi ... _33_79.bin
With that fixed we have PWM and the QCA chip is detected and communicates
Currently no firmware on the flash, I'm trying to figure out whether I can flash it via plctools without messing with the solder jumpers. If anyone knows where to find a firmware image for the QCA7005 or how to extract it from uhis binary, let me know
https://github.com/uhi22/Ioniq28Investi ... _33_79.bin
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
- johu
- Site Admin
- Posts: 6975
- Joined: Thu Nov 08, 2018 10:52 pm
- Location: Kassel/Germany
- Has thanked: 457 times
- Been thanked: 1774 times
- Contact:
Re: Energy Controller including CCS interface
Flashed the image directly today, works well with the solder jumpers.
Changed the PIB file for EVSE use and simply flashed with plctool. I had to change more than the 4 items commonly mentioned here, used this script: https://github.com/qca/open-plc-utils/b ... ac/evse.sh
I also changed the MAC address using "modpib -m" as otherwise it's the same as Focccis.
Then started CP PWM, connected to Foccci which woke right up and off we go into CurrentDemand
Analog reading of CP PWM divided value reliably detects states A-C
Also tested CAN which also works. Very suspicious, no mistakes? huh
Changed the PIB file for EVSE use and simply flashed with plctool. I had to change more than the 4 items commonly mentioned here, used this script: https://github.com/qca/open-plc-utils/b ... ac/evse.sh
I also changed the MAC address using "modpib -m" as otherwise it's the same as Focccis.
Then started CP PWM, connected to Foccci which woke right up and off we go into CurrentDemand
Analog reading of CP PWM divided value reliably detects states A-C
Also tested CAN which also works. Very suspicious, no mistakes? huh
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
- johu
- Site Admin
- Posts: 6975
- Joined: Thu Nov 08, 2018 10:52 pm
- Location: Kassel/Germany
- Has thanked: 457 times
- Been thanked: 1774 times
- Contact:
Re: Energy Controller including CCS interface
And here's another closeup of the CP PWM slew rate
On V2 will probably change it to TLV1805
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
- johu
- Site Admin
- Posts: 6975
- Joined: Thu Nov 08, 2018 10:52 pm
- Location: Kassel/Germany
- Has thanked: 457 times
- Been thanked: 1774 times
- Contact:
Re: Energy Controller including CCS interface
And it's in
Just a reminder of what it used to look like

The switch became redundant for now because Ethernet is now only needed for inverter comms.
With a bit of consolidation I could go back to my single DIN rail enclosure
The switch became redundant for now because Ethernet is now only needed for inverter comms.
With a bit of consolidation I could go back to my single DIN rail enclosure
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
- johu
- Site Admin
- Posts: 6975
- Joined: Thu Nov 08, 2018 10:52 pm
- Location: Kassel/Germany
- Has thanked: 457 times
- Been thanked: 1774 times
- Contact:
Re: Energy Controller including CCS interface
haha, managed to boot strap the SPI flash without solder jumpers on my second module
All you need is the firmware image from uhis repo (https://github.com/uhi22/Ioniq28Investi ... _33_79.bin) and open-plc-utils.
We start with
See how it says "BootLoader"? That's what we want.
Then do
First command results in 3 files from the "file system" of the flash. We merge them back together.
Then we splice 64k from the beginning of the file which brings us to the firmware "partition" and repeat the same trick. Same with the PIB file which we modify for EVSE use.
And now we get
So the new firmware and the new MAC address from the PIB file.
We start with
Code: Select all
> int6klist -v
< 00000000 00 B0 52 00 00 01 AA 38 9F A8 13 32 88 E1 00 00 ..R....8...2....
00000010 A0 00 B0 52 00 00 00 00 00 00 00 00 00 00 00 00 ...R............
00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000030 00 00 00 00 00 00 00 00 00 00 00 00 ............
00000000 AA 38 9F A8 13 32 00 B0 52 00 00 01 88 E1 00 01 .8...2..R.......
00000010 A0 00 B0 52 00 06 0B 42 6F 6F 74 4C 6F 61 64 65 ...R...BootLoade
00000020 72 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 r...............
00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000050 00 00 00 00 00 00 00 00 7C 58 1B 00 00 00 00 00 ........|X......
00000060 01 00 00 00 3F 00 00 00 00 00 00 00 ....?.......
00:B0:52:00:00:01
Then do
Code: Select all
nvmsplit -v CCM_FlashDump_SpiFlash_2MB_Ioniq_00_33_79.bin
nvmmerge CCM_FlashDump_SpiFlash_2MB_Ioniq_00_33_79-0* > softloader.nvm
tail -c +65537 CCM_FlashDump_SpiFlash_2MB_Ioniq_00_33_79.bin > firmware.bin
nvmsplit firmware.bin
nvmmerge firmware-* > firmware.nvm
tail -c +917505 CCM_FlashDump_SpiFlash_2MB_Ioniq_00_33_79.bin > pib.bin
nvmsplit pib.bin
nvmmerge pib-0* > evse.pib
setpib evse.pib 74 hfid "EVSE"
setpib evse.pib F4 byte 2
setpib evse.pib 1653 byte 2
setpib evse.pib 1C98 long 10240 long 102400
setpib evse.pib 1F80 byte 0
setpib evse.pib 16D2 byte 0
setpib evse.pib 16D3 byte 1
modpib -M 04:65:65:FF:FF:00 evse.pib
plcboot -F -S softloader.nvm -N firmware.nvm -P evse.pib
Then we splice 64k from the beginning of the file which brings us to the firmware "partition" and repeat the same trick. Same with the PIB file which we modify for EVSE use.
And now we get
Code: Select all
> int6klist -v
< 00000000 00 B0 52 00 00 01 AA 38 9F A8 13 32 88 E1 00 00 ..R....8...2....
00000010 A0 00 B0 52 00 00 00 00 00 00 00 00 00 00 00 00 ...R............
00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000030 00 00 00 00 00 00 00 00 00 00 00 00 ............
00000000 AA 38 9F A8 13 32 04 65 65 FF FF 00 88 E1 00 01 .8...2.ee.......
00000010 A0 00 B0 52 00 22 25 4D 41 43 2D 51 43 41 37 30 ...R."%MAC-QCA70
00000020 30 35 2D 31 2E 31 2E 30 2E 37 33 30 2D 30 34 2D 05-1.1.0.730-04-
00000030 32 30 31 34 30 38 31 35 2D 43 53 00 CC CC CC CC 20140815-CS.....
00000040 CC CC CC CC CC 00 00 00 00 00 00 00 00 00 00 00 ................
00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000000A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000000B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000000C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000000D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000000E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000000F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000110 00 00 00 00 00 7C 58 1B 00 00 00 00 00 01 00 00 .....|X.........
00000120 00 3F 00 00 00 00 00 00 00 .?.......
04:65:65:FF:FF:00
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
- johu
- Site Admin
- Posts: 6975
- Joined: Thu Nov 08, 2018 10:52 pm
- Location: Kassel/Germany
- Has thanked: 457 times
- Been thanked: 1774 times
- Contact:
Re: Energy Controller including CCS interface
I set up a wiki page https://openinverter.org/wiki/FoccciCape
I've also added the precharge supply back in. I connected a 10uF 400V elcap and a 1M resistor to the output. This gives it a pretty deterministic voltage ramp which I think is also slow enough (0-400V in 6s) so that the vehicle will just report precharge completed.
Will start selling it on the shop soon. Hows interest?
I've also added the precharge supply back in. I connected a 10uF 400V elcap and a 1M resistor to the output. This gives it a pretty deterministic voltage ramp which I think is also slow enough (0-400V in 6s) so that the vehicle will just report precharge completed.
Will start selling it on the shop soon. Hows interest?
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
-
PoloLbricolo
- Posts: 104
- Joined: Wed Apr 10, 2019 2:32 pm
- Location: France
- Has thanked: 3 times
- Been thanked: 11 times
Re: Energy Controller including CCS interface
I'll be interested, quite curious if my old Tesla will let me draw power out of it.