forked from tbnobody/OpenDTU
-
-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Support VP230 for Huawei AC charger #1482
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AndreasBoehm
requested changes
Dec 27, 2024
AndreasBoehm
requested changes
Dec 27, 2024
AndreasBoehm
requested changes
Dec 27, 2024
AndreasBoehm
requested changes
Dec 28, 2024
use separate files to hold the controller logic and the CAN/data handling parts of the Huawei AC charger implementation. move the respective classes to new file system paths and C++ namespaces in the process.
this change only shows a few added/removed newlines when inspecting the commit using `git show --ignore-all-space`.
the ESP is restarted, so the removed code is not executed at all.
* move conversion of PSU-specific values to floats with SI units into hardware interface. * use enum class values to identify settings and values. * use a queue to manage settings to be sent. * use a map to manage received values, including the timestamp they were received. * move pin handling down to hardware interface implementation, as only it knows what pins to use for what and another implementation will use a different set of pin definitions. * make the power pin to control the slot detect relay optional.
these pins will be used to talk directly to a CAN transceiver using the TWAI controller.
this changeset adds support for talking to the Huawei grid charger using a CAN transceiver like the VP230 on the OpenDTU Fusion CAN/Iso shield. we need the ESP32's TWAI controller for that, so this feature conflicts with the Pylontech (and all other battery providers using CAN) battery implementation. the user selects which hardware interface to use in the web UI/config.
MCP215: make event-driven. in particular, this allows us to sleep for some time in the loop task instead of only yield()ing, which effectively keeps the core busy all the time because of this task. the newly added ISR now wakes the loop task once the IRQ pin goes low. use unique_ptr<> to manage the lifetime of the MCP2515 CAN lib object as well as the respective SPI host object.
instead of using a large receive queue and a large stack to handle it all, we now use a mechanism similar to the MCP2515 ISR, which alerts the hardware interface of inbound messages once they are available. this is done by creating another task which blocks on twai_read_alerts() and tests if new messages arrived. if so, the upstream task is notified and can process these messages in time.
schlimmchen
force-pushed
the
schlimmchen/feature/huawei-twai
branch
from
January 6, 2025 19:33
2dba698
to
45f08bd
Compare
For transparency, this is what I did:
|
it seems we are not supposed to do that, but instead use the FreeRTOS-specific functions and structures without #includ'ing the supposedly correct headers.
since this is really about using the internal TWAI controller and "any" compatible external CAN transceiver, we rename the setting.
it is likely that the previous implementation for the MCP2515 CAN controller and transceiver communicating with the Huawei charger did work even without the IRQ pin in use. the new implementation will miss CAN messages if the IRQ pin is not connected or not defined, because it is event-driven, rather than polling with maximum frequency. to avoid people yelling at us because their insane setup worked before but not does not any more, we mark this to be a breaking change.
oh. hope i can give it a try soon 🤗 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There is a lot more in this PR under the hood, all concerning the Huawei grid charger, especially restructuring into namespace, splitting the driver and the controller, removing code duplication (web API JSON creation, (de)serialization of settings), etc.