Project

Week 7 Challenge: Micro-controllers

Week 7 Challenge: Micro-controllers

  1. What is the need of communication within charger, battery pack, and motor drive?
  2. Write a pseudo code for displaying speed on the digital dashboard as per below conditions; Update displayed speed every second, turn on high efficiency indicator between 50 to 60 kmph, Turn on safe drive indicator above 80 kmph.
  3. What are the factors affecting the selection of microprocessor / microcontroller?
  4. Differentiate between the embedded C programming and model based system approaches.
  1. What is the need of communication within charger, battery pack, and motor drive?

Communication is one of the most important part of the Battery Management System (BMS). BMS is designed to monitor the parameters associated with the battery pack and its individual cells, apply the collected data to eliminate the safety risks and optimize the battery performance. With the help of communication between devices BMS continuously monitors parameters such as temperature, voltage, current in and out of the pack to ensure it is being operated in safe conditions the entire time.

Electric vehicles run on very high voltage lithium-ion battery packs. Lithium-ion batteries have higher energy density (100-265 Wh/kg) than other battery chemistries. These batteries come with the risk of catching fire under unusual circumstances. It is imperative to operate the EV batteries in a pre-defined safe limits to ensure the safety of the user as well as the vehicle.

With the help of communication BMS is responsible for thermal management of the battery and monitors its temperature continuously. If required, BMS can adjust cooling and trigger other safety mechanisms to seize operations and minimize risk. For e.g. Hyundai Kona Electric, if overheating of the battery pack is detected by the BMS, the vehicle’s power is automatically limited and the car is put in full-safe mode.

Overcharging of lithium-ion cells can also lead to thermal runaway and potentially an explosion. BMS continuously monitors the voltage of the pack as well as individual battery cells and controls the supply of the current to avoid overcharging. BMS can enforce the limits of the maximum charge or discharge according to temperature.

Through communication BMS is responsible for optimising the performance of the battery pack. Lithium-ion batteries perform best when their State of Charge (SOC) is maintained between minimum and maximum charge limits defined in the battery profile. Overcharging as well as deep discharging degrades the capacity of the battery, thereby shortening its life. At the time of charging BMS determines how much current can safely go in & communicates the same to the EVSE (Electric Vehicle Supply Equipment or the charger). During discharge of the battery, BMS would communicate to the motor controller to avoid cell voltages reaching too low. Vehicles can show corresponding alert to the user to charge the battery pack. The BMS also controls the recharging of the battery pack by generated energy through regenerative braking.

Individual cells in the battery pack can develop differences in capacity with time, which amplify with each charge/discharge cycle. This imbalance limits the amount of energy that can be derived from the battery also how much the battery pack can be charged. Cell balancing is needed to maintain the cells at equal voltage levels and maximize the capacity utilisation of the battery pack.

Measurement of the individual cell voltages by BMS indicates their relative balance and acts as a pointer to how much charge equalization is required. The BMS performs cell balancing by draining excess energy from cells that are more charged than others, through active and passive balancing techniques.

With the help of communication technology BMS uses the collected data points (temperature, voltage, current) to estimate the State of Charge (SOC) & State of Health (SOH) of the battery pack. The SOC refers to the available energy in the battery & determines how far the vehicle can go before needing to charge. The SOH determines the current condition of the battery as compared to its original capacity and indicates the battery’s suitability for the application. Both SOC & SOH are presented as percentages. It also checks for anomalies in the parameters and behaviour of the cells and the battery pack. It stores the error codes and logs diagnostic information that helps fix any issues with the battery. BMS can either take necessary corrective actions or trigger failsafe mechanisms to preserve the health of the pack.

With the help of communication techniques BMS is responsible for communicating with other ECUs in the vehicle. It relays the necessary data about the battery parameters to the motor controller to ensure the smooth running of the vehicle. In case of AC charging the BMS communicates with the on board charger to monitor and control the charging of the battery pack. For DC charging the communication link is directly established between the EVSE and the BMS. BMS communicates the required output voltage and current levels to the EVSE. & sends instructions to start and stop the charging process.

  1. Write a pseudo code for displaying speed on the digital dashboard as per below conditions; Update displayed speed every second, turn on high efficiency indicator between 50 to 60 kmph, Turn on safe drive indicator above 80 kmph.

There are some important terms while writing Pseudo code –

Procedure – A Procedure is a finite sequence of well-defined instructions, each of which can be carried out in a finite amount of time.

Algorithm – An Algorithm is a step by step procedure to solve a given problem.

Flowchart – Flowchart is a type of diagram that represents an algorithm or process.

Pseudo Code – A Pseudo Code is a compact and informal high level description of a program. It is a step by step written outline of your code that you can gradually transcribe into the programming language.

  1. What are the factors affecting the selection of microprocessor / microcontroller?

The brain of an embedded device, which is the processing unit, is a key determinant of the success or failure of the device in accomplishing the task(s) for which it is designed. The processing unit is responsible for every process involving from input to the system, to the final output, thus selecting the right platform for the brain becomes very important during the device design as every other thing will depend on the accuracy of that decision.

Microcontroller and Microprocessor

The processing components used for embedded devices can be divided into two broad categories; Microcontrollers and Microprocessors.

Microcontrollers are small computing devices on a single chip that contain one or more processing cores, with memory devices embedded alongside programmable special and general purpose input and output (I/O) ports. They are used especially in applications where only specific repetitive tasks need to be performed.

Microprocessors on the other hand are general purpose computing devices which incorporate all the functions of the central processing unit on a chip but do not include peripherals like memory and input and output pins like the microcontroller.

Although manufacturers are now changing a lot of things that are blurring the line between microcontrollers and microprocessors like the use of memory on chips for microprocessors and the ability of microcontrollers to connect to an external memory, key differences still exist between these components and the designer will need to choose the best between them for a particular project.

Factors to Consider when Selecting a MPU or MCU

Before making any decision on the direction to go as regards the processing device to use for the design of an embedded product, it is important to develop the design specifications. Developing the design specifications provide an avenue for device pre-design which helps identify in details, the problem to be solved, how it is to be solved, highlights the components to be used and much more. This helps the designer make informed general decisions about the project and helps determine which direction to travel for the processing unit.

Some of the factors in the design specification that needs to be considered before choosing between a microcontroller and a microprocessor are described below.

  1. Processing Power

Processing power is one of the main (if not the main) things to consider when selecting between a microcontroller and a microprocessor. It’s one of the main factors that tilt use to microprocessors. It is measured in DMIPS (Dhrystone Millions of Instructions Per Seconds) and represents the number of instructions a microcontroller or microprocessor can process in a second. It is essentially an indication of how fast a device can complete a task assigned to it.

While determining the exact computational power your design requires can be a very difficult task, an educated guess can be made, by examining the task(s), the device is being created to perform and what the computational requirements of those tasks might be. For instance, the development of a device that requires the use of a full operating system either embedded Linux, windows CE or any of the other OS would require a processing power as high as 500 DMIPS, sounding like a processor? Yes. To add to it, running an operating system on a device will require a memory management unit (MMU) which will increase the required processing power. Device applications that involve a lot of arithmetic also require very high DMIPS values and the more the maths/numeric computations the device is to perform, the more the design requirements tilt towards the use of a microprocessor due to the processing power required.

One other main implication of processing power that affects the choice between microprocessors and microcontrollers is the complexity or simplicity of things like User interfaces. It is a desirable thing these days to have colourful and interactive GUIs even for the most basic of applications. Most libraries used in creating user interfaces like QT require processing power as much as 80 – 100 DMIPS and the more animations, images and other multimedia contents to be displayed, the more the required processing power. However, simpler user interfaces on low resolution screens require little processing power and can be powered using microcontrollers as quite a number of them these days, come with embedded interfaces to interact with different displays

Asides some of the core functions mentioned above, it is important to reserve some processing power for communications and other peripherals. Although most examples given above tend to support the use of a microprocessors, they are generally more expensive compared to microcontrollers and will be an overkill when used in certain solutions, for example using a 500 DMIPS microprocessor to automate a light bulb will make the overall cost of the product higher than normal and could ultimately lead to its failure in market.

  1. Interfaces

The interface to be used to connect different elements of the product is one of the factors to be considered before choosing between a microcontroller and a microprocessor. It is important to ensure the processing unit to be used has the interfaces required by the other components.

From connectivity and communications stand point for instance, Most microcontrollers and Microprocessors possess the interfaces required to connect to communication devices but when high speed communication peripherals like the super speed USB 3.0 interface, multiple 10/100 Ethernet ports or Gigabit Ethernet port are required, things tilt in the direction of the Microprocessor as the interface required to support these are generally only found on them because they are more capable of handling and processing the large amounts of data and the speed at which those data are transferred.

The Impact of the protocols used for these interfaces on the amount of memory required for the firmware should be confirmed as they tend to increase memory requirements. It’s a general rule of thumb that a microprocessor-based design, be adopted for applications that require high-speed connectivity with large amount of data being exchanged especially when the system involves the use of an operating system.

  1. Memory

These two data processing devices handle memory and data storage differently. Microcontrollers for instance come with embedded, fixed memory devices while microprocessors come with interfaces to which memory devices can be connected. Two major implications of this are;

  1. Cost

The microcontroller becomes a cheaper solution, since it does not require the use of an additional memory device while the microprocessor becomes an expensive solution to be adopted due to these additional requirements.

  1. Limited Memory

The fixed memory on the microcontroller makes the amount of data which can be stored on it limited. This is a situation not applicable to processors since they are usually connected to external memory devices. A good example of when this limitation can be a problem is when developing firmware for the device. Adding Additional kilobytes to the code size may require a change in the microcontroller to be used but if the design were based on a processor, we will only need to change the memory device. Thus Microprocessors offer more flexibility with memory.

There are several other factors based on the memory to be considered, one of them is the start-up (boot) time. The Microprocessors for instance stores the firmware on an external memory (Usually an external NAND or Serial Flash memory) and on boot, the firmware is loaded into the DRAM of the processor. While this takes place within a couple of seconds, it might not be Ideal for certain applications. The microcontroller on the other takes less time.

For general speed considerations, the MCU usually wins due to its ability to address the most time critical applications because of the processor core used in them, the fact that the memory is embedded and the firmware used with them is always either an RTOS or bare metal C.

  1. Power

A final point to consider is power consumption. While Microprocessors have low power modes, these modes are not as many as the ones available on a typical MCU and with the external components required by a microprocessor based design, it is slightly more complex to achieve low power modes. Asides from the low power modes, the actual amount of power consumed by an MCU is a whole lot lower than what a microprocessor consumes, because the larger the processing capability, the more the amount of power required to keep the processor up and running.

Microcontrollers therefore tend to find applications where ultra-low power processing units are required such as remote controls, consumer electronics and several smart devices where the design emphasis is on the longevity of battery life. They are also used where a highly deterministic behaviour is needed.

Microprocessors on the other hand are ideal for industrial and consumer applications that require an operating system, are computation intensive and require high-speed connectivity or a user interface with lots of media information.

Several other factors exist and serve as determinants for choosing between these two platforms and all fall under performance, capability and budget but the overall selection becomes easier when a proper systems pre-design is in place and the requirements clearly stated. Microcontrollers are mostly used in solutions with a very tight BOM budget and with stringent power requirements while, Microprocessors are used in applications with huge computation and performance requirements.

4. Differentiate between the embedded C programming and model based system approaches.

C is a general-purpose programming language, which is widely used to design any type of desktop-based applications. It was developed by Dennis Ritchieas a system programming language to develop the operating system. The main features of C language include low-level access to memory, a simple set of keywords, and clean style, these features make C language suitable for system programming like OS or compiler development. In nature it uses a native platform development scheme, i.e. the development of the application by it is platform-dependent and can only be used on a single platform.


Embedded C is an extension of C language and it is used to develop micro-controller based applications. The extensions in the Embedded C language from normal C Programming Language is the I/O Hardware Addressing, fixed-point arithmetic operations, accessing address spaces, etc. Embedded C Program has five layers of Basic Structures. They are:

  • Comment:These are simple readable text, written in code to make it more understandable to the user. Usually comments are written in // or /* */.
  • Pre-processor directives:The Pre-Processor directives tell the compiler which files to look in to find the symbols that are not present in the program.
  • Global Declaration:The part of the code where global variables are defined.
  • Local Declaration:The part of the code where local variables are defined.
  • Main function:Every C program has a main function which drives the whole code. It basically has two parts the declaration part and the execution part. Where, the declaration part is where all the variables are declared, and the execution part defines the whole structure of execution in the program.

In nature it uses a cross-platform development scheme, i.e., the development of the application by it is platform-independent and can be used on multiple platforms.

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.