Software Development Platform Setup

Although I have read most of the posts on the forum, this is my first post.

I am fairly new to CNC machining, but I am not new to software development (or woodworking). I have developed software for about 40 years in C, C++, C# as well as numerous other languages on Windows and QNX (similar to Linux) mostly, but only on Intel CPU’s. I mention this because in the Intel CPU world, when necessary, I have written deterministic privity level 1 code which is required for real-time robotic systems. So other than my retirement playtime with Arduino IDE development in C, I have not worked with micro controllers such as the ESP32, which from what I understand, are fast, but not deterministic.

Now to the request. I would like at least two of the software developers in the Maslow community to outline their development environment for Maslow4. That is, the OS, IDE, required utilities, and any other information necessary for me to compile, link, and deploy to my Maslow4.

I have my Maslow4 assembled, on a 12’x8’ frame, and am doing dry (no cut) runs (Z-axis homed high) and on occasion, seeing behaviors which are undesirable. I will outline these in the appropriate area, but I would like to be able to dig in and understand the general flow of the code to help identify what is happening.

5 Likes

Great first post, Welcome. I have also been in software development for a loooong time, and these little microcontrolers are not something I’ve programmed for a lot until this, but I’m really enjoying learning freeRTOS and ESP32.

Here is what I use, I look forward to other responses!

Visual Studio Code (not visual studio, that is for windows only, and c# focused). Whatever OS you use this works well. I use mac and linux (prefer linux), and when I absolutely have to windows, although it does make me sad when I have to :wink:

For the arduino / ESP32 side, once you have visual studio code, install the platformio extension, and platformio on the host too so you can have the command line, which is super useful.

For the UI side, node and npm. I use nodenv, which allows me to install many node versions, but you could also just install the latest nodejs and be totally fine.

Also both projects make use of python for some scripting. I prefer installing python using pyenv, which allows me many versions, but it probably does not matter much for these projects.

There are buttons on vscode with platformio installed when in the project to do much of this, but here are some FluidNC project (ESP32 side) useful commands:

pio run -t upload --upload-port maslow.local # builds and installs remotely the project on your maslow
pio run -t uploadfs --upload-port maslow.local # wipes and uploads the file system in the data dir (not SD card, but flash) 
pio run -e usb --upload-port /dev/ttyACM0 -t upload .... # same commands but for connecting directly to USB - this example for linux, for windows it would be COM1 or whatever 

For the UI, I’ve added some npm scripts to build the index.html.gz and serve it locally on a proxy on port (whatever, default 8080):

WSPORT=8091 PORT=8090 FLUID_IP=maslow.lan npm start

if you are ok with 8080 you can leave off the two port env vars.

You can also just run npm run build:en which will build an index.html.gz and get it to your maslow.

1 Like

Welcome! Contributions of any kind are very much appreciated!

I use Mac, although I have a windows machine for testing too. On both I use Visual Studio Code with Platformio.

I use GitHub Desktop for interacting with github. It can all be done from the command line, but I like the GUI.

Platformio is a plugin for Visual Studio Code which works like a package manager. Basically when you open the project in Visual Studio Code platformio will automatically install and update the necessary libraries which is great.

The “Compiling” section here might be helpful: FluidNC Installation | Wiki.js

The most helpful thing that I can think of which might be non-obvious is that this button here lets you test compile the code or upload it directly to the machine over wifi.

If you run into any issues getting set up we’re here to help.

Since I will be setting up Linux on one of my laptops, which distribution are you using. I am considering Ubuntu, which is one I used several years ago.

1 Like

Is FreeRTOS running on the ESP32 for the Maslow4 project?

1 Like

We’re using FluidNC which uses FreeRTOS for the timing critical components of the code

I’ve used many over the years. My favorite right now for desktop linux is Mint, which is an ubuntu derivative. I dislike ubuntu’s default desktop a lot as I have multiple monitors and it does not handle that well. I generally though use my mac as a “desktop” and remote into my linux box with tiger vnc to do development as I prefer keybindings in linux to mac (that darn command key trips me up a lot).

1 Like

It seems like to me (I’m also new to this) that the ESP32 platformio libraries include FreeRTOS and run it on that chip by default. So not really a full distribution of FreeRTOS, but enough of it, it seems, to be similar / same as the docs I’ve seen out there on it. The headers turn out a bit different depending on what examples you are looking at.

1 Like

so long as your machine is on the network and named ‘maslow.local’ (which is default, but for me I’m different) :slight_smile:

1 Like

If FreeRTOS is used for timing, then can I assume that it contains a schedular and some kind of interrupt system which implies it can run a higher priority thread on a clock interrupt or external event?

1 Like

Yes, you can absolutely run an interrupt, but beware because it can lead to unexpected issues if the interrupt happens while the SD card is mid read of data or it can interrupt reading from the encoders

The esp32 has two cores, one runs the wifi stuff and one runs our code is the simplified version of things so we really only have one core to play with so if it’s doing something that means it’s not doing anything else

1 Like

ok. first I will digest Expressif FreeRTOS-IDF which is the version of FreeRTOS that the ESP32-S3 is running. From what I have read so far, the ESP32-S3 is more capable than I first thought.

2 Likes

I respectfully waited until the serious questions were asked and answered before cluttering this string with a glib comment. That said I just wanted to express my deep admiration and sense of awe that there are folks like you all that know how to code. Sadly when in high school we were using 7-hole across paper punch tape running Basic, and then in college in 1975 as an engineering major we used Fortran and had to prepare a whole cardboard tray of punchcards that we dutifully carried to the Computer Center where the Wizard of Oz would take them behind the curtain to run. That is of course if I didn’t drop them and let one single punchcard get out of sequence. Remember, at that point there was no GUI interface, hell there wasn’t ANY interface except for a teletype machine (no video screen), the output was 50 lbs of “computer paper” that was usually gibberish due to a syntax error somewhere in that tray of punchcards. I gave up thinking there was no way “computers” were ever going to be viable for use by the common person. 10 years later the Mac and PC came out and I jumped on it. Fast forward 40 more years later and I am a whiz with SketchUp producing construction documents for complex construction projects. But the coding — that eluded me and for that reason I will always consider you all that can build and control things like the Maslow as almost Gods. Thank you! (By the way anyone that would like to know more about “those days” there is a great book called “The Soul of a New Machine,” by Tracy Kidder that I highly recommend reading.

3 Likes

Thanks, Otis for your kind words and the memories. It sounds like I’m about a decade your junior, so by the time I was in college the personal computer and graphics workstation were in the process of replacing the mainframe systems. I read The Soul of a New Machine years ago and remember it was a fascinating read.

1 Like

Hardly. I remember the things you bring up here. I remember using the teletype at my high school to play “horse racing” where it printed out the track after every move of the “horses”. :joy:

I would like to do some work on the ui but I can’t seem to get the project running. I cloned the repo from github and I am stuck trying to find the PlatformIO configuration file. Do I need to create this myself?

1 Like

If you want to work on just the UI no need to mess with the code at all, just get a copy of GitHub - BarbourSmith/ESP3D-WEBUI: A Web UI for ESP8266 or ESP32 based boards connected to 3D printers / CNC and run the command gulp package -en to make it build a new index.html when you are ready to test.

1 Like

For the UI, as Bar says, just the ESP3D project, then if you want a “faster” way of testing than uploading index.html.gz, you can run it with npm start so long as you have python installed, then test on localhost:8080. It does not do “hot reloading” so you have to restart npm and reload to get the latest code in the browser. See above for more details…

2 Likes

Hmm, I seem to be getting an error when running the gulp package command.

Error [ERR_REQUIRE_ESM]: require() of ES Module C:\REPOs\webui\node_modules\del\index.js from C:\REPOs\webui\gulpfile.js not supported.
Instead change the require of index.js in C:\REPOs\webui\gulpfile.js to a dynamic import() which is available in all CommonJS modules.
at Object. (C:\REPOs\webui\gulpfile.js:9:11) {
code: ‘ERR_REQUIRE_ESM’

It’s complaining about the way that code is being imported in the gulp file. Are you guys running an older version of gulp that isn’t as strict with using ES modules? Or is there another addon I might be missing. I haven’t used gulp before.

I just npm install to get gulp. I have used it before a long time ago but this would not be my choice these days either… we had a big thread about this at one point, but this is what upstream is using. We could go off another direction but I for one don’t have the time to commit to that.

Here is my environment (Linux, but it should not matter)

ron@ron-Alienware:~/p/ESP3D-WEBUI$ npm ls
ESP3D-WebUI@ /home/ron/p/ESP3D-WEBUI
├── del@6.0.0
├── deprecated@0.0.2
├── fs@0.0.1-security
├── global@4.4.0
├── gulp-bytediff@1.0.0
├── gulp-cdnizer@2.2.0
├── gulp-clean-css@4.3.0
├── gulp-concat@2.6.1
├── gulp-filesize@0.0.6
├── gulp-gzip@1.4.2
├── gulp-htmlmin@5.0.1
├── gulp-if@3.0.0
├── gulp-jshint@2.1.0
├── gulp-ng-annotate@2.1.0
├── gulp-remove-code@3.0.4
├── gulp-replace@1.1.3
├── gulp-smoosher@0.0.9
├── gulp-uglify@3.0.2
├── gulp-zip@5.1.0
├── gulp@4.0.2
├── jshint@2.13.1
├── merge-stream@2.0.0
└── uglify-js@3.14.2

ron@ron-Alienware:~/p/ESP3D-WEBUI$ node --version
v20.16.0
ron@ron-Alienware:~/p/ESP3D-WEBUI$ npm --version
10.8.1
1 Like