ESP32/S2/S3 LinuxCNC Controller (6 axis hardware step gen), USB plug-and-play

More
28 Feb 2024 22:15 - 28 Feb 2024 22:17 #294733 by Mecanix
Pretty exciting indeed. Should be a walk in the park for you to ramp this project up from 40 to 100kHz, and potentially add the missing two axis in the lot (6ax). Can't wait to see what you'll do with it... should be fun.

edit. oh hang on, just saw your thread title flashing **(6 axis hardware step gen)**. geez...
Last edit: 28 Feb 2024 22:17 by Mecanix.

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

More
28 Feb 2024 22:21 - 28 Feb 2024 22:27 #294734 by wez
Yeah the S3 can do 6 axis but restricted to 200khz total pulse gen.
I have confirmed that. Does remarkedly well for what it is and most use-cases.

Full closed loop encoders for 6 axis at 400khz+ (poss more) pulse gen that would be nice. I think it might be in the realms of possibility. Gone are the days of "cheap" being seen as sub-par
Last edit: 28 Feb 2024 22:27 by wez.

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

More
28 Feb 2024 22:32 #294736 by Mecanix
Impressive already, not sure what else to say. I can't promise but I'll try to set-up an environment that match yours and see if I can contribute positive barebits. I'm currently keil and eclipse here, custom gcc & libs... I'd hate to screw this up. In other words I can't clone nor compile anything you did atm. Drives me nuts lool

Let me find a spare pc somewhere...

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

More
28 Feb 2024 22:36 #294737 by wez
I can see about porting the work over to Eclipse at the weekend if you like?

VS Code is just fast to get setup but being an industrial dev I'd like to move it over to Eclipse at some point anyway. Segger JTAG debugging is much 'easier' then in VS Code.

Just in case you didn't know the ESP-IDE native IDE is Eclipse based anyways. CMake under the hood etc

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

More
28 Feb 2024 22:43 #294738 by Mecanix
yeah I've seen you're using cmake, feeling at home with that already. Prolly better I set-up like you are with vs and the add-ons, I've actually never used vs let alone those arduino libs, all about learning new tricks.

If nothing works (I doubt) then we can think about porting over eclipse.

Assuming nothing works out of a vm (usb, comm parts) and I need a dedicated pc? Correct assumption?

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

More
28 Feb 2024 22:53 - 28 Feb 2024 22:57 #294739 by wez
Most hypervisors can do USB pass through, if it helps.
I believe MS Hyper-V Gen2 machine types would be the only ones that won't.

Which OS do you prefer?

VS Code and PlatformIO is easy and quick to use, once you get the fundamentals. Has its quirks when dealing with larger projects, it likes to randomly re-pull libraries occasionally (not an antivirus issue) which can slow things down sometimes. The "compile checks" on Upload can be infuriating so I flash using esptool from the build directory directly. I'm sure they can be disabled somewhere but not had chance to dig into it much.

The wokwi simulator has been very useful but it's not essential (looks are deceiving, it's actually good for testing non-motion related changes quick)

EDIT: here's a video of the dev simulator - don't think I've shared this on here before. Apologies if I have:
Last edit: 28 Feb 2024 22:57 by wez.
The following user(s) said Thank You: tommylight, Mecanix

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

More
28 Feb 2024 23:00 - 28 Feb 2024 23:09 #294742 by Mecanix
Dev on win10. Ok, using hypervisor and the usbid tool . Severe perf issue but it works (not so much lol). Cool. Let's set-up a successful compile in hyper-v first and take it from there.

Off to the weather channel. Anticipating a rainy day, and I'll get going! Appreciated man ++

edit. wait wait, hypervisor is the tech, not hyper-v. Tired, sorry... I'll update. 
Last edit: 28 Feb 2024 23:09 by Mecanix.
The following user(s) said Thank You: tommylight, wez

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

More
29 Feb 2024 00:06 - 29 Feb 2024 00:12 #294743 by wez
For those wondering - Once I get hands on one, for the ESP32-P4 I plan to experiment with developing a raw socket ioctl driver and custom ethernet frames. Essentially an abstraction layer for the Espressif RMT peripheral registers wants developing. If the native Ethernet PHY is anything like the current ESP32 that is...

With a custom emcmot driver it should, in theory, be possible to directly generate pulses from LinuxCNC RTAPI over native Ethernet via the ESP32-P4. It will not be easy.
High count rate servo encoders will likely be more of a challenge and I'm still undecided how to approach that just yet.

Goal being - have motion native to LCNC. I've had quite a few people ask for this already...

I recommend reading how the RMT peripheral generates pulses
docs.espressif.com/projects/esp-idf/en/v...peripherals/rmt.html
Multi TX, pulse bit stream etc

A stepper example via their IDF APIs here: github.com/espressif/esp-idf/tree/v5.2/e...ls/rmt/stepper_motor
 
Last edit: 29 Feb 2024 00:12 by wez.
The following user(s) said Thank You: tommylight

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

More
01 Mar 2024 12:24 - 01 Mar 2024 12:36 #294835 by wez
Proof of the revised smooth motion engine on the ESP32 (works across all ESP32, S2 and S3).
Ultra high speed, high precision and high accelerations. 80khz on a Nema 23 stepper servo. No pulse filtering enabled on the driver either.

A 2$ microcontroller.

Listen to it scream!

Those are actual mm units flying by on LinuxCNC. 320 Axis scaling (5mm pitch ballscrew) at 1600ppr driver. 



 
Last edit: 01 Mar 2024 12:36 by wez.
The following user(s) said Thank You: tommylight, hairy

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

More
01 Mar 2024 20:57 - 02 Mar 2024 05:58 #294860 by wez
Conscious of development scope creep...

After more research, subject to licensing and legal review, I've concluded that it is possible to implement EtherCAT. This could be a slave device with LinuxCNC being the master due to the amazing work on LinuxCNC that's been done already.

It should work over USB since the stack just sees Ethernet frames, ideally though, ESP32 or new ESP32-P4 with native Ethernet PHY would be most appropriate. Why not both?

No TCP/UDP overhead, configurable, fits into any existing EtherCAT setups. Proven. EoE (Ethernet over EtherCAT) support so ESP32 can continue to be configured/diagnosed via its WebUI too.

What's the interest in an EtherCAT multi-axis stepper & DC motor controller?

EDIT: EtherCAT will solve the minor ferror delay since master (LCNC) and slave (ESP32) will be timing synchronised over Ethernet. Therefore LCNC should know precisely where an axis is at any point in time. 
It's also no longer a "slave" card anymore, as others may put it, take a look at AC Servo drives and LinuxCNC - Marco Reps video for example.
Effectively becomes a well integrated extension of LCNC for steppers and DC servos. Once Encoder support is added then allowing LCNC to perform axis PID closed loop with all the benefits that brings.

For those that say its impossible.... wanna bet? :) Lets start at 1 BTC and go from there?

EDIT:
Well... I'll eat part of my hat... it's "technically" possible to develop a solution without an ESC via the ET9300 slave stack and build a virtual state machine (there are slave simulators) and most of the work can be done in DMA etc - I'd ultimately still have to be part of the ET group (usual membership licensing) in order to actually use it and so realistically whilst it's "possible" it's not feasible considering the cost vs time benefits. 
External hardware can be purchased (ESC IC) but that's not the project goal. ESC ICs are reasonably priced (LAN9252 etc), SOES exists as open source so developing a EtherCAT slave motion controller is most certainly realistically feasibly (look at EasyCAT) - but is it actually worth it for the use-case?

I believe a bespoke "simple" custom Ethernet frames would be faster to develop overall with no extra hardware dependencies, given that (IMHO at least anyway) most Stepper/DC servo driven LinuxCNC deployments are a point-to-point motion controller and not aimed at an industrial solution (Ethernet based). Nothing prevents users from using multiple Ethernet interfaces if they require EtherCAT master in LCNC in addition to a stepper solution (rarely, but it's possible).

That's not to say an ESP32 hardware with an ESC IC and being fully EtherCAT slave "compliant" won't be developed in future though, once the current opensource UDP version is proven.

I'm sure a multi-axis EtherCAT ESP32 motion controller board will be beneficial to the project longer term. Trust will eventually build on the ESP32s, I've had 7 years of continual experience with them (various ECOs etc) in numerous environments - IC cost and "tinkerer" reputation really should not be a consideration. IC reliability, availability and longevity should!
 
Last edit: 02 Mar 2024 05:58 by wez.
The following user(s) said Thank You: tommylight

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

Time to create page: 0.094 seconds
Powered by Kunena Forum