Skip to content

Add virtual servos and bltouch support to the simulator #27779

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

Merged
merged 14 commits into from
Apr 19, 2025

Conversation

ellensp
Copy link
Contributor

@ellensp ellensp commented Apr 3, 2025

Description

This adds virtual servos to the Simulator.
It does not simulate the PWM signals on the pins, It just provides a mostly stub servo library.

This allows us to run bltouch code in the simulator.

Requirements

run the simulator + servos, includes bltouch

Benefits

Bltouch and servo support!!!

Configurations

Standard https://github.com/MarlinFirmware/Configurations/tree/bugfix-2.1.x/config/examples/Simulator + bltouch enabled

Notes

This requires a patch to the MarlinSimUI, so for review I have updated native.ini to point to my fork.
A PR to update MarlinSimUI is in thee works p3p/MarlinSimUI#49

I have set this to draft until MarlinSimUI is updated.

@bmourit
Copy link
Contributor

bmourit commented Apr 12, 2025

Love this!

@thisiskeithb thisiskeithb requested a review from p3p April 12, 2025 20:00
@thisiskeithb thisiskeithb added the T: Development Makefiles, PlatformIO, Python scripts, etc. label Apr 12, 2025
@classicrocker883
Copy link
Contributor

cant wait to see this merge

@classicrocker883
Copy link
Contributor

here are some changes i had to make to get it to compile:

  • add #include <algorithm> for std::find_if to .pio/libdeps/simulator_linux_release/MarlinSimUI/src/MarlinSimulator/virtual_printer.h
  • disable ENDSTOP_INTERRUPTS_FEATURE
  • comment out Z_MIN|MAX_ENDSTOP_HIT_STATE in Marlin/src/inc/Conditionals-5-post.h
#if !NEED_HIT_STATE(Z_MIN)
  //#undef Z_MIN_ENDSTOP_HIT_STATE
#endif
#if !NEED_HIT_STATE(Z_MAX)
  //#undef Z_MAX_ENDSTOP_HIT_STATE
#endif

I suppose the _ENDSTOP_HIT_STATE doesnt need changing if ENSTOP_INTERRUPTS_FEATURE could be enabled

@ellensp
Copy link
Contributor Author

ellensp commented Apr 14, 2025

ENDSTOP_INTERRUPTS_FEATURE is not part of https://github.com/MarlinFirmware/Configurations/tree/bugfix-2.1.x/config/examples/Simulator and its is not supported in the sim.

No changes are required with standard configs

@ellensp
Copy link
Contributor Author

ellensp commented Apr 14, 2025

Added servo's to menu

Servo

@classicrocker883
Copy link
Contributor

I was able to use basically an Ender-3 V2 config with DWIN lcd and it works. what about software interrupts

@bmourit
Copy link
Contributor

bmourit commented Apr 14, 2025

This emulator is one of the most under appreciated, but incredibly useful parts of Marlin, IMH. This added virtual servo support support is awesome.

@thisiskeithb
Copy link
Member

Just make sure this isn't merged early, changes are still being worked through in the simulator channel on Discord and I assume those will go upstream to @p3p's repo once that is all worked out.

@thinkyhead
Copy link
Member

Just make sure this isn't merged early, changes are still being worked through in the simulator channel on Discord and I assume those will go upstream to @p3p's repo once that is all worked out.

No worries. This will not be merged until MarlinSimUI=https://github.com/p3p/MarlinSimUI/archive/NEWGOODNESS.zip

@ellensp
Copy link
Contributor Author

ellensp commented Apr 16, 2025

Bltouch Looks good, tested homing and probing a 10x10 UBL

Currently breaks building if you enabled servos but not a bltouch.
eg #define NUM_SERVOS 3 with //#define BLTOUCH

@ellensp
Copy link
Contributor Author

ellensp commented Apr 16, 2025

I think we are all good to go, just waiting on p3p/MarlinSimUI#49 so can change native.ini back to p3p from my fork.

Now with a nice Bltouch menu thanks to p3p

Screenshot from 2025-04-16 14-42-47

@thinkyhead
Copy link
Member

This is a great bottle example of how to add new functionality to the Simulator! I'll be sure to put it on the list of examples for new developers in the Developer Guide, along with any other well-contained PRs that exemplify how to do a thing.

@thinkyhead thinkyhead marked this pull request as ready for review April 16, 2025 19:08
@ellensp
Copy link
Contributor Author

ellensp commented Apr 17, 2025

p3p MarlinSimUI has been updated, and ini/native.ini has been updated to use it.

@thinkyhead thinkyhead merged commit d009c48 into MarlinFirmware:bugfix-2.1.x Apr 19, 2025
66 checks passed
@ellensp ellensp deleted the add-simulated-servo branch April 19, 2025 02:28
EvilGremlin pushed a commit to EvilGremlin/Marlin that referenced this pull request May 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: Peripherals F: BLTouch T: Development Makefiles, PlatformIO, Python scripts, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants