Electronic – How to come up with a list of requirements for a microcontroller for the project? How to then find microcontrollers that fit

controlmicrocontroller

I have been working on an eBike control project on the Arduino MEGA2560. The program runs 3x PID control loops, one battery capacity control loop (interpolation based on lookup tables), a speedometer (samples based on a reed switch) as well as an LCD screen to display information. Its inputs are 3 analog signals: battery voltage, current and user throttle input as well as a digital input: speedometer (reed switch) on/off signal. Currently, with all this running on "long" arithmetic the Arduino manages to complete 10 loops per second. As the TFT LCD screen takes tremendous amounts of computational power, I am thinking of replacing it with an Alphanumeric screen.

The outputs consist of an analog throttle signal going to a motor controller, the LCD screen and potentially a few other devices requiring analog signals. Thus, ADC converters are essential and DAC would be very useful although I am currently using the Arduino PWM output with an RC low pass filter. Similarly, the capacity to read digital and analog signals without interrupting the processor would be great.

I would like to potentially make a consumer product out of this, hence I want to build my own platform from the ground up with a different microcontroller that could give me at least 100 samples per second (10 times what the Arduino is achieving). Also, to avoid floating points, my calculations use long variables and consequently numbers larger than 16 bits, so I'm assuming a 32bit MCU would be a good idea. Also, a MCU able to do floating point calculations could be interesting to simplify the maths in the code.

In the end I am not sure how to start looking for MCUs that would satisfy these requirements and allow a swift transition from the Arduino environment. Any guidance on how to go about finding such MCUs would be greatly appreciated!

Best Answer

(This is a generic guide. I suspect you could also benefit from code optimisation, but that's outside the scope of this website.)

Step 1: Rough sizing, budget, vendor

Pick one of:

  • Computer (Raspberry Pi, Beagleboard, PC104 board, Intel Edison, etc). Boots a general-purpose operating system and has lots of processing power. More expensive and power-hungry. $10-$100.

  • Large MCU. ARM Cortex-A / PIC32 / dsPIC / AVR32 / TI C series DSP etc. Decent computing power, OS optional. ~$5.

  • Small MCU. Cortex-M / PIC16. Not really enough space for a true OS, maybe just a lightweight task scheduler. ~$2.

  • Tiny MCU. Only really for applications where you care about every last microamp of power consumption. ~$1 or less.

You should also consider at this stage which vendors and toolchains you like and dislike. Have a look at the cost of things like in-circuit debugging devices and IDEs.

Step 2: Minimum Peripherals

Do you need things like USB? PCI? HDMI? SATA? Unusually fast ADCs or DACs? Almost all of the "small" or "tiny" category do not have these, although USB is fairly widely available.

Step 3: Prototype

Pick something which meets the above criteria, at random if necessary, make a start, find out how feasible it is and how much space / processing power you need. You've already done some of this. Writing in C should make much of the logic portable.

Once you have the prototype you can say to yourself, "I need one like this, but with more X" and let that guide your decisions.

Step 4: Shrink

It's generally easier to start with the largest (most Flash and RAM) member of a CPU family, write v1 of your application, and then choose a smaller, cheaper one to fit. You can also spend time on the art of fitting software into fewer resources. What's worthwhile depends on how many units you're going to make.