MCAL, Actuators and Sensor
Published: 2023-12-10 14:14:29

Hello Readers,
My name is Santosha S Chikkur, and I work at Luxoft India as a Junior Software Developer. Luxoft has given me several opportunities to work on various projects, which has inspired me to learn the essential processes involved in developing AUTOSAR Modulеs and Add-Ons in MCAL, Actuators and Sensor


**Introduction**

- AUTOSAR, which stands for Automotive Open System Architecture, is a global collaboration among vehicle manufacturers, suppliers, service providers, and companies from the automotive electronics, semiconductor, and software industry.
- MCAL is a software module that has direct access to all MCU peripherals and memory-bound peripherals. And this makes the upper software layer (Basic Software Layer or BSW, Application Layer) independent of the MCU. 
- MCAL provides a very important advantage of an AUTOSAR compatible design layer architecture. 
- It makes the application as well as the middleware (kernel software layer) independent of the underlying hardware platform.

**Software Architecture of AUTOSAR MCAL**


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8lauk0y9a921mvfb6e3m.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sjw14li4ymp3u63zrihn.png)


• MCAL offers a variety of software modules designed for specific purposes.
• Each Software Module (Driver) accesses the
corresponding On-chip peripheral function.
• The MCAL software module allows direct access to on-chip MCU peripheral modules.

**Modules in MCAL**

**Microcontroller Drivers:**

• **GPT Driver**: GPT (General Purpose Timer) device driver uses on-chip MCU timer. Initializes GPT and performs
timer count.
• **WDG Driver**: The WDG Driver initializes the WDG on-chip device and configures the WDG mode settings.
• **MCU Driver**: The MCU driver is responsible for configuring MCU settings and initializing the device.

**Memory Drivers:**

• **FLS Driver**: The Flash Driver initializes the Flash memory and performs read/write operations on the memory.

**Communication Drivers:**

• **SPI Handler/Driver**: SPI (Serial Peripheral Interface) is a Handler/Driver Device with on-chip clock serial feature that Initializes SPI, plays SPI input/output and SPI I/O buffer settings.
• **LIN Driver**: LIN (Local Interconnected network) is a tool driving force that initializes LIN and plays LIN input/output.
• **CAN Driver**: CAN (Controller Area Network) is a tool driving force that initializes CAN and plays CAN input/output.
• **FlexRay Driver**: FlexRaydevice driving force initializes FlexRay and plays FlexRay input/output.
• **Ethernet Driver**: Ethernet	device	driver	initializes Ethernet Driver	and performs Ethernet Driver input/output.


**IO Drivers:**

• **ICU Driver**: ICU (Input Capture Unit) is a device driver using on-chip MCU timer and initializes ICU. It also measures PWM waveforms.
• **PWM Driver**: PWM (Pulse Width Modulation) is a device driver that uses an on-chip MCU timer. It resets PWM and outputs PWM waveforms. 
• **ADC Driver**: ADC (Analog Digital Converter) is an on-chip ADC device driver, starts/stops AD conversion, units AD conversion end result buffer and reads AD conversion results.
• **DIO Driver**: DIO (Digital Input/Output) is an MCU port device driver that performs port signal (input/output).
• **PORT Driver**: PORT Driver is a MCU port device driver that performs MCU pin settings (I/O, shared functions).


**AUTOSAR Software Specification Document**

• Download the AUTOSAR Software Specification Document for each module.
• Go through the below mentioned chapters;
• Functional description of the module.
• Generic requirements and limitations of the module.
• Detailed design section includes Typedefs, Enums, Structures, API definitions, etc.
• Architectural/Data flow of the module and APIs.
• Configuration Parameters of the module.
• Read it carefully during each requirement analysis stage.
• Use the latest version always because it has updates/bug fixes.


**Sensors & Actuators**
 
• Sensor and actuator works in sync and is based on every different in an embedded system. 
• Sensors and actuators frequently paintings in tandem, however they may be basically contrary devices. 
• A sensor video display units situations and indicators whilst modifications occur. 
• An actuator gets a sign and plays an action, frequently withinside the shape of motion in a mechanical machine. - the sensor is used to display and degree the modifications withinside the surroundings and the actuator is used to manipulate the surroundings.



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8gh3iaqmtxeu9etrcrrt.png)

**Sensors**

• A sensor is a device that senses and measures any change in the physical environment.
• It converts the bodily portions into an electrical signal. • It takes any enter from the actual global surroundings and feeds it right into a gadget withinside the shape of an electrical signal. 
• It is hooked up on the enter of a gadget and it components all of the important information for processing. 
• Few examples of sensors are temperature, ultrasonic, strain and function sensor, etc. As their call suggests, they're used for sensing and measuring the respective portions.



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3y9r47zyji4w0kuid341.png)

**Actuators**


• Actuators are linked on the output of a gadget. 
• The actuator relies upon at the facts supplied via way of means of the sensor. 
• It takes electric sign as its enter and generates mechanical motion as its output. 
• A fan is used to lessen temperature. A servo motor is used for converting function etc. 
• The sensor presents the facts to a sign circumstance unit or a gadget that approaches the facts and based on that data it sends command to the actuator. An example of such system is a “temperature control system”, where a temperature sensor monitors the temperature. If the temperature exceeds a certain limit, the system sends command to fan (actuator) to increase its speed and reduce the temperature.
- Another example is an automatic door that opens on human perception.


**Sensors & Actuators - Example**
• Discuss some example of Sensors and actuators.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rffm952q6t2i8ma1t8o3.png)

**Conclusion**


The various layers of the AUTOSAR architecture are developed independently, and the MCAL drivers are no exception. In this way, the necessary abstraction and thus standardization is achieved. MCAL drivers are also very important because they are the bridge between the upper layers of the AUTOSAR architecture and the microcontroller. The sensor and actuator work in sync and trust each other in an embedded system. They are used to automate operations, make the system more reliable and eliminate human errors. The main difference lies in their function; the sensor is used to monitor and measure changes in the environment and the environment is controlled by an actuator.


This will be continued in the next article, including examples. Please let me know in the comments below if you have any questions. Thanks for reading.