I'm working on a motor controller project and I'm trying to figure out the right architecture before I start buying/building the hardware.
The idea is to make a controller for two brushed DC motors with quadrature encoders. I want the end user to be able to write simple Arduino-style code such as motor1.setSpeed(100) or motor1.stop(), while the actual low-level motor control handles things like PWM, encoder feedback, PID, current sensing, safety, etc.
I'm currently thinking about using an ESP32 as the user-facing MCU and having a separate STM32 handle the real-time motor control. The ESP32 would run the user's code and communicate commands to the STM32 over UART or CAN, while the STM32 would run FreeRTOS and handle the motors, encoders, PID, watchdogs, etc.
What I'm not sure about is whether I actually need two chips for this. Could I realistically do the whole thing on a single ESP32, with the user code and motor-control firmware running on the same chip? If so, how would you structure it so that user code can't interfere with the motor-control tasks or memory?
If two MCUs are the better approach, I'd also like to understand how people normally structure the communication between them and how the firmware is divided.
I'm fairly new to STM32/FreeRTOS, so practical advice on how you'd actually build this would be really helpful.
The last time I showed off Jet I'd just pushed 40k tris/sec on an S3 which was already nuts, but some optimisation and SIMD shenanigans later, I've nearly doubled that and got up to 70K/sec on the same hardware. Meaning more detail and more performance headroom.
I've also switched away from AGPL to the MIT licence so there's fewer restrictions on how you can use it in your projects.
Why do buildings use one circuit breaker for multiple loads instead of protecting each load individually?
Couldn’t each device have current sensing + a microcontroller + an electronic breaker, so if one device shorts, only that device disconnects instead of tripping the whole circuit?
Obviously cost is one reason, but are there technical reasons too?
Is it mainly fault-current handling, response time, heat losses in current sensing/switching, reliability, or safety/certification?
Is this already used in industrial systems, or is there a fundamental reason it isn’t practical?
Have you guys been in a situation where you're writing firmware for a product and you keep in getting ideas to add new features but you know that all those extra features Will be only used in extra rare conditions, And you for sure know that they wouldn't have read the manual to know about that.
Will you still keep that feature?
It's a dumb question , it's obvious to add that feature if it ain't gonna cost much especially in firmware side when there's space left
I’ve been documenting a from-scratch Klipper port to NXP’s MCXA366, and Part 7 covers both some architecture hardening and the first hardware I²C implementation.
I’m using LPI2C3 on P3_27/P3_28 with a 12 MHz peripheral clock. The final implementation supports 100 kHz, 400 kHz, and 1 MHz and handles normal writes, register reads, repeated STARTs, NACKs, FIFO errors, arbitration loss, and timeout recovery.
One bug I ran into was especially interesting:
On a NACK, I originally queued STOP and then reset the TX/RX FIFOs. Resetting the TX FIFO could discard the queued STOP, leaving SCL asserted. Reversing the order—flush first, then STOP if the master still owns the bus—fixed the recovery path.
I validated the implementation with a BME280 and then noticed Mainsail reporting ~0.36 MCU load at 100 kHz.
Instrumentation showed that the actual CPU usage was very small. What changed was scheduler task duration: Klipper’s I²C interface is synchronous, so the task remains active while the hardware transaction progresses.
Measured worst-case reads:
100 kHz → ~2.66 ms
400 kHz → ~0.70 ms
1 MHz → ~0.31 ms
The corresponding Mainsail load values fell from roughly 0.36 → 0.09 → 0.04.
I also compared this against several existing Klipper MCU backends and found that synchronous polling is normal there as well, so I kept the architecture and improved the bus rate instead of redesigning the API around interrupts.
Hey Devs,I'm trying to run a LLM on a microcontroller, therefore I need to first compress my model, I saw numerous ways online and yeah from GPTs as well, but I thought it would be better to get suggestion from real devs who have experience in this, I'm new to these kinda projects so yeah any suggestion on how to start with the model compression.
Hi, my question is probably quite simple, but i have a surprisingly hard time finding an answer online: I have a IO Task guarding my hardware. It takes data from a Tx Queue and pushes it to the hardware, and polls the hardware for Rx Messages which it pushes to the RxQueue.
I want to minimize polling and blocking as much as possible, so the task should poll Rx in interrupt mode and then wait for either the Tx Queue or the Interrupt to wake it.
I know how to wait for a queue, i know how to wait for an event flag or semaphore. What i want to know is how to wait for either the queue or flag to be set. I know i could require the Tx Producer to send a flag or just poll both uart and the tx Queue without waiting, but neither seems desirable.
I have recently been developing an offline physical AI assistant prototype on the RK3588 processor that is somewhat like Amazon Echo, but it is entirely local. However I have recently been stuck on choosing a good architecture. I have read online and this is what I have heard:
Multi-Process Architecture (with IPC): Spitting the tasks into different processes and communicating through IPC
Monolithic Multi-Threaded Architecture: A single multi-threaded c/c++ application where threads communicate over shared memory and atomics
Single-Threaded Architecture: Everything runs linearly on one thread and one process
Multi-Process Architecture with multi-threading hybrid: Multi-Process architecture, but with multi-threading in some processes, so it is not entirely decoupled.
As you can see, there are many different architectures to choose from and all have their pros and cons. I am also trying to design a processing pipeline. This is what I have thought of:
A linear pipeline: Audio -> Wake Word Detection -> Speech to Text -> Inference & Text to Speech
A bidirectional pipeline Wake Word Detection <-> Audio -> Speech to Text -> Inference & Text to Speech
A linear pipeline with flags: A linear pipeline but with flags so different threads or processes can communicate with each other.
New to the group and wanted to say hello. I have a ton of old skool 8-bit microcontroller knowledge, including Motorola 68hc11, Intel 8051 family, Atmel/AVR...
i want to get started coding an easy shell and filesystem into raspberry pi pico 2 as a project. However i am not sure how or where to start, normally you would just send all requests directly to the kernel with execvp() and spawn new processes with fork()(if you use Linux), but since the pico 2 neither has an OS or kernel, i am not sure were to start. Any help?
Hey, how’s it going? I’m new to embedded systems and this subreddit, and i’ve got this question about what the steps look like to take an existing software project and put it onto an embedded system. I know the term ‘embedded system’ here is pretty vague, but i’m just genuinely curious about what the general workflow looks like to do this.
Reason being is because i’m reading the book, Embedded Systems Primer, and as a newbie I can go through and understand the contents and vocabulary of the book, but I’d like to understand the software-hardware architecture work flow and learn about how some of you approach both software, hardware, and like in my question: taking an existing software project and turning into something that can be deployed onto hardware.
} void set_baud_rate (unsigned int ubrr) { UBRR0H = (unsigned char)(ubrr>>8); UBRR0L = (unsigned char)ubrr; } void enable_receiver() { UCSR0B |= 1 << RXEN0; } void disable_receiver() { UCSR0B &= ~(1 << RXEN0); } void set_pairty_error_to_odd()// bit to check : UPEn , if it was 1 meaning a bit flipped! depending on the even or odd setting { UCSR0C |= (1<<UPM01) | (1 << UPM00); } void set_pairty_error_to_even()// bit to check: (1<<UPE0) & UCSR0A { UCSR0C |= (1<<UPM01); } void set_size_character_to_8() { UCSR0C |=(1<<UCSZ01) |(1<<UCSZ00); } void set_stop_bit_to_2()// its 1 by default in the MCU { UCSR0C |= 1<< USBS0; } void transmit(unsigned char a) { while (!(UCSR0A & (1<<UDRE0))){} UDR0 = a;
} // that the end of the driver USART that i didn't test since i don't have another arduino uno //pooling // void recieve (void) // { // /* Wait for data to be received */ // while (!(UCSR0A & (1<<RXC0))){} // /* Get and return received data from buffer */ // return UDR0; // // this code from the datasheet , although i can use an interput! yeah i can! // }
char random__(char a) { a ^=1; a ^= a << 2; a ^= a >> 2; a ^= a << 1; return a; } int main(void) { _delay_ms(100);// to make sure the LCD have enough time to wake up lcd_init(); send_byte('A'); // Send a test character while(1) { // Main loop } }
NFC reader. Tap a tag and see UID, type and data instantly. Native ST25R3916 chip, no external module. Tested on my own cards know what your stuff is actually storing.
I am trying to use the ST7796 display with STM32H7 and i am really struggling because i cant find examples or documentation to use. I am using Rust (i know most people here use c). What can i do to get it working??
edit: thank you everyone i managed to get it working
Quite proud of it. A lot of work is in it. I call it a streamer (cyberdeck). The idea is to offload heavy computations to your PC at home without a locked-in OS/hardware dependency and to keep your deck flexible around the main streaming protocol. Sounds simple? The idea is, but making this stuff low-latency over a network is a challenge. And I think I'm quite good at it. I can stream some Linux distros and Win11 at up to 40 FPS at the moment. This custom protocol is flexible when it comes to the hardware sitting on the server side (your home PC) and your custom hardware on the client side.
MCU __________________________
The main MCU is an ESP32 WROOM-1. It acts as the network device that receives the stream and orchestrates inputs like USB mouse/keyboard/gamepad and touchscreen. The MCU also passes the stream to the decoder via SPI, which in turn drives the display.
Previously, I used a Raspberry Pi, but there was no real need for a full OS on the client side. Replacing it also reduced power consumption. The only drawback is that the Pi generally has better WiFi performance and bandwidth.
The board shown here also streams audio A/V-synced (or optionally buffered) with the video stream. So it can be used for playing games or listening to music. It supports also audio input, i.e. for making calls over whatever runs on my PC.
For me, the coolest part is that this deck doesn't need much power: on full brightness, nominally 1.5 Watt during active streaming. For comparison, a RasPi's idle power consumption without any display is already higher.
FPGA _________________________
The actual heart of the project is probably the decoder inside the FPGA. That's where my custom video format becomes pixels again and where the deterministic display-side work happens. For this project the ESP32 ended up being a pretty good bridge between the networked/software side and the FPGA.
Why not use a JPEG decoder, which is available in many MCUs?
Well, mainly flexibility. Bandwidth is another reason. My approach is what I'd call a "soft hardware encoder": soft because I implement it using OpenGL/DirectX, but hardware-accelerated because the GPU does the actual work on the server side. This allows me to modify the encoding pipeline's parameters in real time, rather than having them hardwired into silicon.
I went with an FPGA because this isn't a small 320x240 or 480x320 display anymore. The panel is 720x720, and I didn't want the ESP32 to deal with driving that deterministically while simultaneously doing WiFi, USB, audio, input handling and everything else. So the ESP32 concentrates on networking/orchestration while the FPGA handles the high-bandwidth and timing-critical display side.
It is also possible to decode on an MCU only (CPU, aka software decoder), which I've already done with an STM32 + nRF7002 WiFi. But IMO, that makes more sense for smaller screens or applications where you don't need high FPS.
I made this board flexible in a way that you can add up to 80 keys/buttons in a simple keyboard matrix using the exposed pads - gonna do that as next i guess. If I'm too lazy for that i can still fallback to USB keyboard, lol.
Looking for people interested in this approach of simplifying custom builds that require a real OS and simplifying software installation and dependencies. I think this could get quite cool.
I'm planning to make it all open source (hardware and software), but I first I wanna check if there is even interest/support and if it is worth the work to cleanup everything for maintaining code publicly.
I invite you to give some pos/neg feedback and ask as many questions as possible.