EEVblog Electronics Community Forum

Electronics => Beginners => Topic started by: ElectroNex on February 18, 2023, 10:16:19 am

Title: What Microcontroller should i use
Post by: ElectroNex on February 18, 2023, 10:16:19 am
hi im building a project which is quite simple and needs to be able to run 4 stepper motors 2 servos and a screen
i would love to build a pcb for my project for obvious reasons so im looking for micro controller ic i could use



[/size]
[/color][/font]
Title: Re: What Microcontroller should i use
Post by: BadeBhaiya on February 18, 2023, 10:49:17 am
Try to list out the hardware features you need from the microcontroller. How many GPIOs do you need? Do you need hardware SPI/I2C busses or can you bit-bang them?

For example if you need 4 stepper motors you would lets say need 4 GPIOs per motor, which comes to 4x4=16, 2 servo motors would need 2 additional GPIO lines with PWM capabilities. A screen would run off of an SPI bus and would need 4-5 GPIO lines. You may also need a few hardware timers to control stepper motors and stuff. Also try to estimate how much flash and RAM you can get away with.

In your case for example, the least amount of GPIO pins you can have is 16+2+5 = 23 GPIOs. You would also need hardware timers, SPI transreceiver, and PWM.

This is just a very simple example and you can of course do with less or more resources. Maybe you can share the 4 control lines for all stepper motors and just have 4 additional enable lines? 23 GPIOs -> 15 GPIOs. Maybe you don't need hardware PWM and can do it in software

Another important thing is clock speed. Do some very rough calculations on how long a particular action takes. Can you manage the system on a 1MHz clock? 8MHz? 64MHz? 300MHz?

Lastly, a few very general tips
Title: Re: What Microcontroller should i use
Post by: pcprogrammer on February 18, 2023, 12:18:06 pm
Why not experiment first with some store bought modules.

There are stepper motor boards for arduino compatible controllers that offer all the needed functionality. There are so many projects about this to be found on the internet.

For example https://howtomechatronics.com/tutorials/arduino/how-to-control-stepper-motor-with-a4988-driver-and-arduino/ (https://howtomechatronics.com/tutorials/arduino/how-to-control-stepper-motor-with-a4988-driver-and-arduino/)

If you need more processing power then an AVR based arduino, you can try a bluepill, or raspberry pico.

Controlling a servo is very simple. For this you can also find so many projects on the internet.

This way you can construct and test your system first and then draw a schematic based on it and design a PCB based on the schematic.
Title: Re: What Microcontroller should i use
Post by: BlackICE on February 18, 2023, 12:23:38 pm
I'm old school and hate to solder SMDs so prefer through hole. I use small pre-made boards using 328p or ESP32s and solder them to perf boards. With the current pricing ESP32s boards cost less or about the same as 328p board. So unless you want low power consumption why not use an ESP32. ESP32 supports FreeRTOS which is great if you are fluent in RTOS programming.
Title: Re: What Microcontroller should i use
Post by: Ian.M on February 18, 2023, 01:16:29 pm
Four steppers, two servos and a screen sounds like a good fit for an off-the-shelf 3D printer controller board, reprogrammed with your own firmware.
Title: Re: What Microcontroller should i use
Post by: Infraviolet on February 18, 2023, 06:25:12 pm
Right now, for part availabiliy reasons, I'd strongly consider the Raspberry Pi Pico.
Title: Re: What Microcontroller should i use
Post by: brucehoult on February 18, 2023, 10:14:36 pm
Four steppers, two servos and a screen sounds like a good fit for an off-the-shelf 3D printer controller board, reprogrammed with your own firmware.

Ten years ago those usually used an ATMega2560, which has lots of I/Os and despite being only 8 bit and 16 MHz and 8 KB RAM seemed to get the job done just fine. I haven't looked at them recently, but I'd guess they probably use something Arm now.