-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
StrokeEngine: fix: drive StrokeEngine by speed #134
StrokeEngine: fix: drive StrokeEngine by speed #134
Conversation
I noticed an increase in speed if the stroke setpoint is higher than the depth setpoint.
|
c23a7c2
to
cbb5c79
Compare
float speedConsignePercent = ossm->setting.speed; | ||
ESP_LOGD("UTILS", "speedConsignePercent: %f%", speedConsignePercent); | ||
ESP_LOGD("UTILS", "maxSpeedMmPerSecond: %fmm/s", Config::Driver::maxSpeedMmPerSecond); | ||
float speedMmPerSecond = (Config::Driver::maxSpeedMmPerSecond * speedConsignePercent) / 100.0F; | ||
ESP_LOGD("UTILS", "speedMmPerSecond: %fmm/s", speedMmPerSecond); | ||
|
||
float strokeMm = Stroker.getStroke(); | ||
ESP_LOGD("UTILS", "strokeMm: %fmm", strokeMm); | ||
float depthMm = Stroker.getDepth(); | ||
ESP_LOGD("UTILS", "depthMm: %fmm", depthMm); | ||
float travelMm = min(abs(strokeMm), abs(depthMm)); | ||
ESP_LOGD("UTILS", "travelMm: %fmm", travelMm); | ||
float tripMm = travelMm * 2.0F; | ||
ESP_LOGD("UTILS", "tripMm: %fmm", tripMm); | ||
|
||
float tripPerSecond = speedMmPerSecond / tripMm; | ||
ESP_LOGD("UTILS", "tripPerSecond: %ftrip/s", tripPerSecond); | ||
float tripPerMinute = tripPerSecond * 60.0F; | ||
ESP_LOGD("UTILS", "tripPerMinute: %ftrip/min", tripPerMinute); | ||
|
||
float newSpeedMmPerSecond = tripPerMinute * tripMm / 60.0F; | ||
ESP_LOGD("UTILS", "newSpeedMmPerSecond: %fmm/s", newSpeedMmPerSecond); | ||
|
||
Stroker.setSpeed(tripPerMinute, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
float speedConsignePercent = ossm->setting.speed; | |
ESP_LOGD("UTILS", "speedConsignePercent: %f%", speedConsignePercent); | |
ESP_LOGD("UTILS", "maxSpeedMmPerSecond: %fmm/s", Config::Driver::maxSpeedMmPerSecond); | |
float speedMmPerSecond = (Config::Driver::maxSpeedMmPerSecond * speedConsignePercent) / 100.0F; | |
ESP_LOGD("UTILS", "speedMmPerSecond: %fmm/s", speedMmPerSecond); | |
float strokeMm = Stroker.getStroke(); | |
ESP_LOGD("UTILS", "strokeMm: %fmm", strokeMm); | |
float depthMm = Stroker.getDepth(); | |
ESP_LOGD("UTILS", "depthMm: %fmm", depthMm); | |
float travelMm = min(abs(strokeMm), abs(depthMm)); | |
ESP_LOGD("UTILS", "travelMm: %fmm", travelMm); | |
float tripMm = travelMm * 2.0F; | |
ESP_LOGD("UTILS", "tripMm: %fmm", tripMm); | |
float tripPerSecond = speedMmPerSecond / tripMm; | |
ESP_LOGD("UTILS", "tripPerSecond: %ftrip/s", tripPerSecond); | |
float tripPerMinute = tripPerSecond * 60.0F; | |
ESP_LOGD("UTILS", "tripPerMinute: %ftrip/min", tripPerMinute); | |
float newSpeedMmPerSecond = tripPerMinute * tripMm / 60.0F; | |
ESP_LOGD("UTILS", "newSpeedMmPerSecond: %fmm/s", newSpeedMmPerSecond); | |
Stroker.setSpeed(tripPerMinute, true); | |
float tripPerMinute = 0.0F; | |
#ifdef DEBUG_TALKATIVE | |
float speedConsignePercent = ossm->setting.speed; | |
ESP_LOGD("UTILS", "speedConsignePercent: %f%", speedConsignePercent); | |
ESP_LOGD("UTILS", "maxSpeedMmPerSecond: %fmm/s", Config::Driver::maxSpeedMmPerSecond); | |
float speedMmPerSecond = (Config::Driver::maxSpeedMmPerSecond * speedConsignePercent) / 100.0F; | |
ESP_LOGD("UTILS", "speedMmPerSecond: %fmm/s", speedMmPerSecond); | |
float strokeMm = Stroker.getStroke(); | |
ESP_LOGD("UTILS", "strokeMm: %fmm", strokeMm); | |
float depthMm = Stroker.getDepth(); | |
ESP_LOGD("UTILS", "depthMm: %fmm", depthMm); | |
float travelMm = min(abs(strokeMm), abs(depthMm)); | |
ESP_LOGD("UTILS", "travelMm: %fmm", travelMm); | |
float tripMm = travelMm * 2.0F; | |
ESP_LOGD("UTILS", "tripMm: %fmm", tripMm); | |
float tripPerSecond = speedMmPerSecond / tripMm; | |
ESP_LOGD("UTILS", "tripPerSecond: %ftrip/s", tripPerSecond); | |
tripPerMinute = tripPerSecond * 60.0F; | |
ESP_LOGD("UTILS", "tripPerMinute: %ftrip/min", tripPerMinute); | |
float newSpeedMmPerSecond = tripPerMinute * tripMm / 60.0F; | |
ESP_LOGD("UTILS", "newSpeedMmPerSecond: %fmm/s", newSpeedMmPerSecond); | |
#endif | |
tripPerMinute = ((Config::Driver::maxSpeedMmPerSecond * ossm->setting.speed / 100.0F) / (min(abs(Stroker.getStroke()), abs(Stroker.getDepth())) * 2.0F)) * 60.0F; | |
Stroker.setSpeed(tripPerMinute, true); |
Suggestion: Reduce memory footprint of calculations and cpu footprint of debug logging unless in debug mode.
Code suggestion is not an implied approval.
Will bench test this functionality later this week.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@armpitMFG , suggestion applied and checked with my setup.
Thank for your review.
I'll keep the footprint in mind for the future.
It's been a long time since I did any dev on mcu.
985ee03
to
7ee0f81
Compare
use speed on main consigne to reduce injuries risk. speed is more stable when depth, distance and sensation are updated Signed-off-by: benoit robert <benoit.robert.dev@gmail.com>
7ee0f81
to
db70c5f
Compare
@armpitMFG, I've adjusting your proposition to group some values |
@AJ-Koenig, @armpitMFG |
use speed on main consigne to reduce injuries risk.
speed is more stable when stroke, depth and sensation are updated.