linuxcnc-esp32 Software Stepping over Ethernet Using ESP32

More
28 Jan 2024 14:39 #291806 by schoch
Hope to see this on github soon! Looking forward to trying it out.

Please Log in or Create an account to join the conversation.

More
28 Jan 2024 21:49 #291839 by wez
4 Axis demo that I threw together using hardware step gen RMT peripheral, not hardware timers,

This is at 8 Microsteps so 1600 pulses per revolution for all drivers. Can easily be increased but 8x is enough for my use case.
Each axis Scale is set to 320 for 8mm ball leadscrew. All configurable within the HAL as normal.
Low frequency rattling noise at lower speeds are the motors hitting each other on the desk as they are unsecured - they are smooth at all speeds with no pulse jitter.

Please Log in or Create an account to join the conversation.

More
29 Jan 2024 19:45 - 29 Jan 2024 19:47 #291925 by wez
More latency and throughput tweaks. The result is 80khz per motor simultaneously without issue.
Processing 1500 packets per second to ensure f-error is less than 2.0 at high speeds (2800k rpm~) across all axes.
High accelerations and optimised direction pin delays for high speed switching of directions as can see in the video.

Each motors velocity command is highly dynamic and calculated in real time to ensure smooth movements, including position.

One test board has been running a job generating high speed pulses for 4 axes continuously for 24 hours without a board crash or follower error so it's proving to be stable.

Hardware based high speed encoder inputs will be next.


 
Last edit: 29 Jan 2024 19:47 by wez.

Please Log in or Create an account to join the conversation.

More
31 Jan 2024 08:54 - 31 Jan 2024 08:55 #292055 by wez
As promised, confirmed as working with 6 Axes on ESP32 at full 200khz.
24 hour torture and stability testing has been done.

Please read the readme carefully.

Be warned - the ESP32 GPIO is only technically 3.3v compliant so you may need level shifters depending on your application or use-case.

Although, that said, external Stepper motor or closed loop stepper servo drivers usually sink so little current across their EN,Step and DIR pins it isn't a major cause for concern - at least based on my testing here but your milage may vary. You have been warned at least.

Designing a low cost custom PCB with a $5 ESP32 WROOM or WROVER stamp and a LAN8720 Phy would be straightforward - there are plenty of reference designs out there. See Olimex github for a good example.

Just be sure to wire up your GPIOs and any level shifters or isolators accordingly.

Using a WT32-ETH01 module and a custom carrier board would work fine - just be aware of the IO limitations and map out your step and dir pins properly to ensure the RMT peripheral works (test it before designing your board).
Extending the firmware to use a I2S or I2C GPIO mux for other inputs and outputs would be recommended. There are plenty of ESP32 Arduino libs for this.
The software foundation is in place at least.

Adding hardware based high speed Servo Encoder pulse feedback via the Pulse Counter Peripheral hardware is also possible and can use existing Arduino ESP32 libraries for this. The stepper generator does not use the Pulse Counter Peripheral for this reason and future potential.

The firmware has been purposefully based on Arduino libraries and not native esp-idf to make it easier for everyone to extend/adapt to their own use-case. It's been designed and optimised heavily to be as extensible as possible by leaving a CPU core spare to do other tasks.

Project is based on the original HAL2UDP concept by Juhász Zoltán. Thanks goes to him and anyone else who helped contribute to the original project.

github.com/wezhunter/ESP32_LinuxCNC_MotionController_RealTime

Have fun
 
Last edit: 31 Jan 2024 08:55 by wez.
The following user(s) said Thank You: tommylight, aparecido, cornholio

Please Log in or Create an account to join the conversation.

More
31 Jan 2024 18:45 #292090 by wez
Follow-up regarding my note on 3.3V IO on the ESP32.

IIRC it was confirmed by Espressif CEO that the pins are 5v compliant however their logic levels will be 3.3v. They had a note in the original datasheet but removed it since people were powering the units with 5v directly to the 3.3v rail of the MCU.

You can connect a 5v device to any input pin and it will be fine. I've done it for years with no ill effect.
Current sinking is what to watch out for, just like any MCU pin.

Inputs pins configured as an ADC/Analog input at 5v will not read their full scale and so would require level shifters.
The following user(s) said Thank You: aparecido

Please Log in or Create an account to join the conversation.

More
02 Feb 2024 06:13 - 02 Feb 2024 06:14 #292195 by wez
Just published a new commit to my repo for hardware based ESP32 motion control.
 
Added SPI Ethernet W5500 support. Tested quite a bit and works flawlessly. The interrupt pin on the W5500 needs to be wired up for low latency reception of UDP packets unlike other implementations.

MKS-DLC32 ESP32 CNC board is now supported. Uses I2S output for Enable and Direction pins. See notes in Readme regarding this.

Refactored motor velocity commands and added debugging (disabled by default) and reduced jitter to ensure motors work in both velocity and position modes.
Changed readme.

ESP32-S2 and S3 support is next along with USB-C based device networking (these offer this hardware). Should hopefully become a truly plug & play LinuxCNC hardware based motion controller.
Last edit: 02 Feb 2024 06:14 by wez.
The following user(s) said Thank You: tommylight, aparecido

Please Log in or Create an account to join the conversation.

More
02 Feb 2024 15:08 #292221 by schoch
Thanks for releasing the source!!!

Just thinking outloud... Since remora, LinuxCNC-RIO, and this all have custom components and protocols I wonder if it wouldn't make sense at some point to have a standard protocol and linuxCNC component they can all share and then the devs for each project just need to focus mostly on their MCU/FPGA specific code?
The following user(s) said Thank You: aparecido

Please Log in or Create an account to join the conversation.

More
02 Feb 2024 19:08 #292239 by wez
Thanks for the suggestion, ideas are good. I think it all depends on each use case and protocol timing requirements of each of them. Someone would have to asses all different controller types and requires intimate knowledge of each sources, edge cases & detailed testing. I'm not aware of anyone that has this knowledge, a collab would be great but kind of unsure if the benefits cost/time analysis would be worth it?

For ESP32 - I intend on implementing some basic CI for compiled firmware release management. Users can flash a generic compiled release (ESP32/S2/S3) which starts up in WiFi hotspot mode which provides a simple web config page where pin mappings and firmware features can be configured and saved to either NVS or SPIFFS - similar to the way Tasmota does it. Once Ethernet is configured (or USB) the web interface can be accessed via that or hotspot enabled again via serial port command.
Web config interface would have to ensure that only available pins for that board are configurable making setup as fool proof as possible. Peripherals like external GPIO muxes and drivers could be added easily too, again much like how Tasmota does it.

Serial port will have a basic CLI for enabling debugging and configuring certain aspects.
Anyone can have a multi-axis controller for low cost with no vendor specific board type lock in and I think there's going to be ESP32/S2/S3 for quite a while
The following user(s) said Thank You: aparecido

Please Log in or Create an account to join the conversation.

More
02 Feb 2024 20:02 #292242 by tommylight

Someone would have to asses all different controller types and requires intimate knowledge of each sources, edge cases & detailed testing. I'm not aware of anyone that has this knowledge, a collab would be great but kind of unsure if the benefits cost/time analysis would be worth it?

+1

ESP32 is very good for a lot of stuff, so yes, it will most probably be around for quite some time.
I have built 12 channel RC receivers with them by just adding an ELRS RP1 or RP2 module or flight controllers by adding a 6050 accelerometer.
There is also FluidNC that does CNC control over the built in web browser.
Adding LinuxCNC for it is just the cherry on top. :)

Please Log in or Create an account to join the conversation.

More
02 Feb 2024 21:01 #292249 by wez
Glad to hear someone else has experience with the Espressif MCUs :)

In my experience over the years they are rock solid. Just as long as you get familiar with their build system, versioning and how all peripherals work. Yes in their early days they had hardware revs errata but that's pretty much a given early on.

FluidNC is great and showcases ESP32 capabilities but it's still based on 3D printer tech (GRBL) with movement trajectory planning, no encoder feedback support and so forth. It's just not a real time motion controller with step control and feedback over an interface with low latency. LinuxCNC is just another beast entirely!

Paired with a decent custom PCB with all required IO an ESP32 would run a retrofitted industrial CNC machine without any issues - I am certain of that.

Espressif's dev support on Github is very good.
I've used them in products and they are rock solid and incredibly fast - it's very difficult to break them unless doing something really silly. People have differing opinions when comparing to STM and the likes and whilst they're a standard in the makers space but when it comes down to cost, availability and reliability balance - Espressif MCUs are hard to challenge, especially when you know them in depth.

Reducing the hardware barrier to entry for LinuxCNC and other robotics based motion control I think would be useful to makers.

Just having a ESPS2/S3 that you plug in via USB and visit a Web based wizard to configure your IO and it generates a HAL config would be so good.
Simple case of having a custom PCB carrier then.

Once I've integrated my USB networking work from another project on the S2/S3 (I already know UDP latency is not an issue) I think people may be pleasantly surprised at just how useful and easy it will be to get setup and running for little cost
The following user(s) said Thank You: tommylight, aparecido

Please Log in or Create an account to join the conversation.

Time to create page: 0.336 seconds
Powered by Kunena Forum