Memfault State of IoT Report

Choice of microcontroller for a project

Started by Skorartyl 5 years ago11 replieslatest reply 5 years ago260 views
I want to develop a small "pointing robot" with a micro-controller.
I'm a bit of a starter, but i learn fast, but in order to start, i'd like to have advice on which microcontroller i should start learning for my project.
for the inputs, i need to use 6 press-buttons (like a mini joypad), and for the output, 2 bipolar steppers, 2 relay, and one LCD (graphical would be nice, but a 4 lines alphanumerical could do instead).
I played around the PIC controller, so i might go with those, but still wonder what language (basic, C, pascal) would be easiest to work with.
Anyone have suggestion ?
[ - ]
Reply by rtomkinsMay 14, 2019

Assuming that your effort is to learn, then I want to suggest that ST Microelectronics has an excellent ecosystem waiting for you.

The STM32 MCU's come in a broad range of speed and abilities.

STM has taken great steps to enable developers to easily get started,

  • Free development tools
  • TrueStudio IDE, full feature, full functionality
  • STM32 Cube, a tool to create all the initialization code for a chosen MCU
  • Complete libraries of working code for every STM32 MCU family to start with. for all MCU peripherals
  • full demo code for all inexpensive developer module
  • agreements with multiple leading edge 3rd parties to use their code libraries for free, Segger, DSP Concepts and more
  • complete family of low cost modules to get you started, with full hardware, software, schematic and PCB support,

STM32 F4 Discovery module

And if all you need is a single board, then this can be your full hardware building block. If you are going to commercialize, then this is a great demon/proof of concept to help you show working protoypes to investors.

I believe that ST Microelectronics is the unsung hero of effective, low cost, versatile and diverse solution development availabel today.

[ - ]
Reply by natersozMay 14, 2019

ST is a very solid choice. Absolutely agree with the prior post.

[ - ]
Reply by sreenivasa_charyMay 14, 2019

@rtomkins - absolutely agree ! 

Most of the ARM development kits come without the compiler (IAR, Keil, etc) and that is a sad thing. They are very expensive to buy for an individual.

The best thing ST did was to make the Atollic TrueStudio free and all upgrades available from version 8 onwards (correct me if i am wrong). 

Atmel Studio is available free of cost to developers, and is great for developing on Atmega and AVR series of controllers. Though some of the elements like the Zigbee development kit (BitCloud) are only provided under some conditions...

Also, I read in some reviews that Atmel's ARM gcc compiler is not nearly as good as the IAR or Keil compilers and there are a lot of things one needs to tweak...

MPLabX for the PIC controllers is free with XC series of compilers....

[ - ]
Reply by rtomkinsMay 14, 2019

A majority of compilers for MCU's appear to be derivations of gcc. I have tried the PLAY versions of Keil and IAR and was not overly enamored with their use or results.

Atollic TrueStudio, which had been free (for learning) prior to ownership by STMicroelectronics, uses the Eclipse Foundation IDE. This IDE is superior to the offerings of Keil and IAR, ease of use, code colouring, stability, visually logical layout, organization of controls, ability to be expanded, and the list goes on.

OpenSTM32 also offers a free Eclipse IDE and gcc development environment. In fact, STM32Cube libraries typically have code that compiles and executes right away. I used this tool a number of times, but found that there were quirks that caused me to stumble and fumble at times.

gcc produces compact code, and it seemed that sometimes, the resultant binaries were smaller than Keil or IAR.

There are a great many attributes that can be set for gcc that can help to optimize your code.

[ - ]
Reply by CustomSargeMay 14, 2019

As a beginner, I'd stay with the simplest and most familiar. You can always up the complexity and functionality. The PIC would do fine to start and I'll say write it in BASIC. The next version can be a different (better) chip family and maybe jump to C. The PIC/BASIC will teach you a lot that you'll apply to subsequent versions.

Also, this version should be alphanumeric LCD, graphicals are a LOT more complicated. So keep it as a future build or version.

Good Hunting! You're boarding a train I jumped on in 1976 - and never regretted a minute.

[ - ]
Reply by DilbertoMay 14, 2019

Hi,  Skorartyl!

If you have played with PIC micro, probably you've done it in assembly language, right?
Well, IMHO it's time to change to a high level language.
Nowadays, by far the most used language to develop things like you're trying to do is C ( or C++ ).
if, as you say, you're "a bit of a starter", perhaps it should be a good idea to start with Arduino, because it has plenty of cheap microcontroller boards available worldwide, has an IDE with a very friendly user interface, may be programmed in C ( or C++ ), has an extensive ecosystem, including libraries and examples of stepper motors, robots, displays ( character and graphic ), etc.

It has also not only boards with 8 bit microcontrollers ( AVR ) as also  ARM Cortex ( DUE, for instance ) which should be your target microcontroller at the end.

Surely it's a very good starting point for newbies.

Hope it helps.


[ - ]
Reply by TheCaptainMay 14, 2019
For learning, and a one-off, I strongly suggest an Arduino, particularly one with a 32U4 for speed and versatility.  There are joystick and stepper-motor "shields" that plug straight onto it too.
[ - ]
Reply by alvarogramirezMay 14, 2019

It really depends of the project dead line. If it is for yesterday use a stepper driver like the https://www.st.com/en/motor-drivers/powerstep01.html, just tell the speed profile and the amount of steps (No clocking/steps). And use the knowledge or microcontroller you already have. For hobbie, (no deadline) move to C. You can always use Arduino but to me, that gives a false impression that you can program microcontrollers. Just write directly to registers and learn techniques to map or reuse routines like setting or clear GPIOs. Reading the manual is better that learn a HAL. But some may dissagre and love the abstraction of the HAL. To make the history short, HAL easy to program but decrease optimization and ties you to an specific manufacturer. Direct registers improves optimization but takes time to learn and let you to move to any brand.

[ - ]
Reply by JackCrensMay 14, 2019

I second (or third) the motion for Arduino. Not only are they cheap, but there's a ton of user-created software libraries for every possible I/O device you can name, but the Arduino RTOS and IDE are ridiculously easy to use.

For some devices, you may need what the Arduinists call "Shields," that plug into the Arduino headers, but there's also a shield for any imaginable I/O device.

You will definitely need a relay driver shield for your project.

[ - ]
Reply by mr_banditMay 14, 2019


Look at what adafruit.com and sparkfun.com have. Get a "normal" arduino && a motor shield

https://www.adafruit.com/product/2488   a "normal" arduino   $17.50

https://www.adafruit.com/product/1438   motor shield         $20

https://www.adafruit.com/product/3191    relay               $10

https://www.adafruit.com/product/2923    relay               $8

https://www.adafruit.com/product/196  prototype shield w/ terminal blocks    $15

https://www.adafruit.com/product/2077  simpler prototype shield  $10

https://www.adafruit.com/?q=lcd        variety of LCDs in $10..20 range

The prototype shield with the terminal blocks is very useful, because you can easily connect sensors/etc. When you have the connections you want, use the simpler prototype shield to solder connectors to.

I only included the adafruit examples  look on sparkfun for the equivalent or other choices. Part of the fun is seeing what is out there.

Also look on amazon when you have a pretty good idea of what you want.

The two relay boards are intended as shields for the adafruit "Feather" boards, the adafruit version of the pro-mini or teensy. With the simple prototype shield and berg connectors, you can mount them and just feed them the signals they need. Basically, treat them like breakout boards.

Terminology: connectors are male and or female.

The ones used for arduino shields are both. However, in the case of the breakout boards, you typically put the females on the proto shield board && the males on the breakout board. (That is convention; You could do it the other way.)

For the connectors:

1x30 male https://www.digikey.com/product-detail/en/sullins-connector-solutions/PRPC030SAAN-RC/S1011EC-30-ND/2775224

1x30 female https://www.digikey.com/product-detail/en/sullins-connector-solutions/PPTC301LFBN-RC/S7028-ND/810168

Cut them to length.

You can try these links to see the choices out there.  I have stripped out most of the cruft



[ - ]
Reply by s-lightMay 14, 2019

please tell us a bit more what your 'idea' behind this is!

as most of the other great answers already have written - there are a bunch of ways to go ;-)

also read through the FAQ

and in there is Selecting the Right Microcontroller for your Application

with some good ideas in there.

if you want to learn mainly software / coding - go with on of big Hardware 'frameworks':

- Arduino
- Adafruit Feather
- Sparkfun Qwiic
- lots of others on the market ;-)

my personal favorite board currently is the Adafruit ItsyBitsy M4 Express
120MHz - ATSAMD51 32-bit Cortex M4 :-)
it can be used 'out of the box' with arduino - or - for all that don't need the raw speed but like HighLevel language programming: use CircuitPython
I really enjoy this!

In my current personal project (a costume prop) i used it to control a 8x8 16Bit RGB-LED-matrix. i started the development in CircuitPython (CP) - that was easy to experiment with the different animation-formular if found... and after finishing it i decided that only 10FPS for my animation is to slow - i have no joy in optimmizing software - so CP was to slow for this task for me and i just ported the code to C++ and got pleasing fast 120FPS :-) → without optimizing anything - just porting syntax...
that means: all calculations are done in floating-point '0..1' math and colors are in HSV color-space and so on ;-)
if someone would optimize this iam sure it would be possible to get 10x more FPS...
(you can find both versions in this repository)

My goal for my projects is - enjoy the doing, - fast iterations & small steps that work & lots of learning along the way...
at most time i find that it takes longer than i first think..
so it is good to have small steps that work so i have enough motivation to go on..

For my Hardware i like all things to be as modular and versatile as possible -
so i like the 'Pin-Header' versions of things (controller / breakout boards for sensors and so on) - i can prototype on breadboards and for my props and finished projects i just solder some sockets to some wires to interconnect things as i need most of the time:



and if - at some point - there is some demand for a more 'product' like thing -
i generally choose / keep an eye on / try to understand what is needed / use only components / designs / controllers and so on - where i know i can use them or be able to replicate them for my 'self-designed product'..

So you see - it is really a 'style' question what is the best thing for you! :-)

hopefully this post inspires and gives some ideas of what is just one of many possible mindsets...

welcome in a time of posibilites :-)

sunny greetings


Memfault State of IoT Report