Skip to content
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

move esc code to separate class FactoryEsc #60

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AlexShutov
Copy link

@AlexShutov AlexShutov commented Jan 24, 2025

Esc code support only factory esc. I want to use T-motor Thunder 300A 24S esc, ordered it, but don't know format of data from that esc. So maybe it is a good idea to add support for several esc's.
In this pr esc interface is moved to abstrace EscBase class and existing code is moved to FactoryEsc class.
State of battery and esc is also moved to separate struct, singleton instance of which is created in .ino file instead of using 'extern' variables

@zjwhitehead
Copy link
Member

Hi and thanks for this. I've done something similar, but it has not been merged into master branch just yet. The new ESC we are testing uses CAN bus, so it's an entirely different protocol. We are probably moving away from PWM and UART reading of ESCs but I will look into having the ability to read and write to different types of ESCs in the future.
Check out how this is separated out here and let me know what you think https://github.com/openppg/eppg-controller/blob/esp32-can/src/sp140/esc.cpp

@AlexShutov
Copy link
Author

AlexShutov commented Jan 24, 2025

Hi and thanks for this. I've done something similar, but it has not been merged into master branch just yet. The new ESC we are testing uses CAN bus, so it's an entirely different protocol. We are probably moving away from PWM and UART reading of ESCs but I will look into having the ability to read and write to different types of ESCs in the future. Check out how this is separated out here and let me know what you think https://github.com/openppg/eppg-controller/blob/esp32-can/src/sp140/esc.cpp

I saw this branch, but not sure if Tmotor thunder has CAN bus support. There is also HobbyWing Xrotor esc, I thought about buying that one, but is has 120a continious current, It looks safer to use TMotor 300A

Regarding code, It seems worth abstracting protocol level (uart, CAN) to different class for sending and receiving packets and passing it by pointer into Esc implementation. I would also extract Logger and TelemetryCalculator for making code cleaner, so this logic will know nothing about esc protocol.

We can merge changes in this PR and make another class CanBaseEsc : EscBase, contract looks the same, and then implement throttle level calculators. On startup see config and use proper implementation

Unfortunately I don't have PPG for testing this code, only dev board for 2040. Ordered screen, vibration control on ali

@AlexShutov
Copy link
Author

photo_2025-01-25_00-41-24
something like that

@AlexShutov
Copy link
Author

Hi and thanks for this. I've done something similar, but it has not been merged into master branch just yet. The new ESC we are testing uses CAN bus, so it's an entirely different protocol. We are probably moving away from PWM and UART reading of ESCs but I will look into having the ability to read and write to different types of ESCs in the future. Check out how this is separated out here and let me know what you think https://github.com/openppg/eppg-controller/blob/esp32-can/src/sp140/esc.cpp

Hi, is that good idea?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants