Get me outta here!

Saturday, September 24, 2022

Microprocessor, Microcontroller & Embedded Systems

 microcontroller is a small computer on a single integrated circuit chip. A microcontroller typically contains one or more processor cores, along with additional peripherals (memory, serial interface, timer, programmable I/O peripherals, etc.) on the same chip.

microprocessor is a computer processor that incorporates the functions of a central processing unit (CPU) onto just a few (and often only one) integrated circuits. 

Microprocessor and Microcontroller Architecture Explained

Microprocessors and microcontrollers perform relatively similar functions, but if we look specifically at the architecture of each type of chip, we'll see just how different they are.

The defining characteristic of a microcontroller is that it incorporates all of the necessary computing components onto a single chip. The CPU, memory, interrupt controls, timer, serial ports, bus controls, I/O peripheral ports, and any other necessary components are all present on the same chip and no external circuits are required. 

In contrast, a microprocessor consists of a CPU and several supporting chips that supply the memory, serial interface, inputs and outputs, timers, and other necessary components. Many sources indicate that the terms "microprocessor" and "CPU" are essentially synonymous, but you may also come across microprocessor architectural diagrams that depict the CPU as a component of the microprocessor.  You can think of a microprocessor as a single integrated circuit chip that contains a CPU. That chip can connect to other external peripherals such as a control bus or data bus that provide binary data inputs and receive outputs from the microprocessor (also in binary).

The key difference here is that microcontrollers are self-contained. All of the necessary computing peripherals are internal to the chip, where microprocessors deal with external peripherals. As we'll soon see, each of these architectures has its own unique advantages and disadvantages.

Microprocessor and Microcontroller Applications Explained

Microprocessors and microcontrollers are both ways of implementing CPUs in computing. So far we've learned that microcontrollers integrate the CPU onto the chip with several other peripherals, while a microprocessor consists of a CPU with wired connections to other supporting chips. While there may be some overlap, microprocessors and microcontrollers have relatively separate and distinct applications. 

Microprocessors depend on interfacing a number of additional chips to form a microcomputer system. They are often used in personal computers where users require powerful, high-speed processors with versatile capabilities that support a range of computing applications. The use of external peripherals with microprocessors means that components can be upgraded easily - for example, a user might replace their RAM chip to benefit from additional memory. 

Programmable microcontrollers contain all of the components of a microcomputer system on a single chip that runs at low power and performs a dedicated operation. Microcontrollers are most commonly used in embedded systems applications where devices are expected to execute basic functions reliably and without human interference for extended periods of time.

Three Key Differences Between Microcontrollers and Microprocessors

Cost

Generally speaking, microcontrollers tend to cost less than microprocessors. Microprocessors are typically manufactured for use with more expensive devices that will leverage external peripherals to drive performance. They are also significantly more complex, as they are meant to perform a variety of computational tasks while microcontrollers usually perform a dedicated function. This is another reason why microprocessors require a robust external memory source - to support more complex computational tasks.

With a microcontroller, engineers write and compile the code intended for the specific application and upload it into the microcontroller, which internally houses all of the necessary computing features and components to execute the code. Due to their narrow individual applications, microcontrollers frequently require less memory, less computing power, and less overall complexity than microprocessors, hence the lower cost.

Speed

When it comes to overall clock speed, there is a significant difference between industry-leading microprocessor chips and high-quality microcontrollers. This relates back to the idea that microcontrollers are meant to handle a specific task or application, while a microprocessor is meant for more complex, robust, and unpredictable computing tasks. 

One of the key design advantages associated with microcontrollers is that they can be optimized to run the code for a specific task. That means using just the right amount of speed and power to get the job done - no more and no less. As a result, many microprocessors are clocking speeds of up to 4 GHz while microcontrollers can operate with much lower speeds of 200 MHz or less.

At the same time, the close proximity of on-chip components can help microcontrollers perform functions quickly despite their slower clock speed. Microprocessors can sometimes operate more slowly because of their dependence on communicating with external peripherals.

Power Consumption

One of the key advantages associated with microcontrollers is their low power consumption. A computer processor that performs a dedicated task requires less speed, and therefore less power, than a processor with robust computational capacity. Power consumption plays an important role in implementation design: a processor that consumes a lot of power may need to be plugged in or supported by an external power supply, whereas a processor that consumes limited power could be powered for a long time by just a small battery. 

For tasks that require low computational power, it can be much more cost effective to implement a microcontroller versus a microprocessor that consumes much more power for the same output.

Embedded Systems and Microcontrollers

Microcontrollers include many features that make them suitable for application in embedded systems:

  • They are self-contained, including all of the necessary peripherals on a single integrated circuit chip
  • They are designed to run a single dedicated application
  • They can be optimized (software and hardware) for a single dedicated application
  • They exhibit low power consumption and may include power-saving features, making them ideal for applications that require the processor to function for long periods of time without human interference
  • They are relatively inexpensive when compared to CPUs, mainly because the entire system exists on a single chip

While microprocessors may be more powerful, that additional power comes at a cost that makes microprocessors less desirable for embedded systems applications: larger size, more power consumption, and greater cost.


How Do Embedded Systems Work?

An embedded system is a hardware-and-software system that performs a dedicated function within a larger mechanical or electrical system. Embedded systems are typically designed to deal with real-time computing constraints, and are controlled by a real-time operating system (RTOS) that can process data as soon as it is received without buffer delays. Most embedded systems today are based on programmable microcontrollers, small computers with integrated memory housed on a single integrated circuit. We can think of embedded systems as having three main components: the hardware component, the software component, and the real-time operating system.

Embedded Systems Hardware

Embedded systems are small embedded computers that live inside other mechanical or electrical systems. Embedded systems can be programmed to fulfill a variety of functions, but each one must include the basic components of a computer:

  • Processor - Embedded systems are built around a microprocessor or microcontroller. Microcontrollers include one or more processors (CPUs), along with integrated memory and programmable input/output peripherals. Most automatically controlled products or devices use microcontrollers , including office machines, power tools, and automobile engine control systems.
  • Power Supply - Embedded systems have significantly lower power requirements than a standard computer due to their small size and comparatively low processing power. Embedded engineers should choose a power supply that offers a stable and smooth output of power to the microcontroller with adequate output current to drive the load and stable performance in a variety of environments.
  • Memory - If an embedded system is powered by a microcontroller, the system's memory is already available on the chip. If using a microprocessor, a memory chip should be added to the system. Embedded systems use read-only memory (ROM) to store the software program used to operate the microcontroller and random access memory (RAM) to temporarily store data that is received or in-use by the system.
  • Communication Ports - Embedded systems use wired communications to transmit data between the microcontroller, peripheral devices, and other embedded systems. Engineers must select a communication protocol to facilitate this data exchange, ensuring that devices in the system are all "speaking the same language" when they communicate or transmit data. Common communication protocols for embedded systems include the I2C protocol, SPI protocol, and the USB protocol, but there are many other wired and wireless protocols available for engineers to choose from.

Embedded Systems Software and RTOS

Programming for embedded systems is most frequently done using C, C++, the Embedded C language or assembly language. The software programming for embedded systems, including the RTOS, resides in the memory chip and can be accessed whenever the power supply for the system is activated. Unlike standard computers, embedded systems are designed to carry out a specific task or function rather than for "general use". As such, embedded systems software is highly specific to each application of embedded systems.

Embedded Systems Applications Today

Embedded systems impact everyday life in so many ways, we may not always realize the number of devices in our immediate surroundings that are controlled by embedded systems. Let's take a brief inventory of some of the most important embedded systems applications and areas of innovation today.

Embedded Systems in Communications

Cellular phones are some of the most accessible examples of embedded systems that we interact with on a daily basis. Mobile phones contain all of the characteristic components of an embedded system: a power supply, some memory or storage, a processor, and ports for communicating with other devices. Mobile phones also contain additional hardware that supports utilities like audio, cameras, internet connectivity, touch screen and calling.

Like other embedded systems, your mobile phone uses a defined communication protocol to facilitate data transactions between the microcontroller or processor and peripheral devices that collect data.

Embedded Systems in Consumer Electronics

Embedded systems are finding their way into many categories of consumer electronics, including home security systems, home appliances, printers, watches, and more. Home appliances like refrigerators, microwave ovens and washing machines use simple embedded systems to provide features, collect input from users, and control the appliance according to user specifications. They may even use some sensors to collect information about how the appliance is functioning and modify settings accordingly.

Home security systems use embedded systems with peripheral sensors to collect information about activity in and around the home and either initiate a response (alarm) or communicate that data to the homeowner.

Embedded Systems in Automotive Applications

All cars manufactured today contain at least one computer that works to measure and minimize engine emissions throughout the operational life of the vehicle. This embedded computer collects data from a variety of peripheral sensor devices, including oxygen sensors, air pressure sensors, air temperature sensors, and the engine temperature sensor. The computer can use data from these sensors to measure the cleanliness of engine emissions and control the fuel injectors, spark plugs and other variables to optimize for engine performance while minimizing environmental impact.

Most vehicles have additional embedded systems that control things like automatic transmission, anti-lock braking systems, air bags, key-less entry or security systems, audio devices and safety applications like lane drift detection.

Embedded Systems in Healthcare

Embedded systems are used in medical scanning machines, imaging systems, and diagnostic equipment. Some of the most commonly used medical imaging devices, such as CT scanners, MRI machines, and Sonography equipment used to conduct ultrasound imaging are built around and controlled by embedded systems. Digital flow sensors used to monitor respiration, heart monitoring machines, and simple diagnostic machines that test for blood pressure or glucose content also use embedded systems.

The expansion of the Internet of Things (IoT) is leading to new trends in embedded systems for healthcare. In the future, patients will use wearable devices to track their vital signs with data regularly transmitted to their hospital or physician in real time. There will be no shortage of product development opportunities for embedded systems engineers that can use their skills to lower healthcare costs or improve access for patients.

The Future of Embedded Systems

Embedded systems are a major area of innovation that is expected to grow substantially on a per-year basis. Across industries, embedded systems engineers are deploying new products and technologies to increase safety and reduce costs.

In the automotive sector, we're seeing major technological growth in embedded systems as major manufacturers partner with leading technology companies to develop self-driving vehicles. The market for wearable medical devices is expanding rapidly, with an estimated growth rate of 18.5% through 2023. There is also a growing demand for "smart" home appliances and devices that can reduce energy consumption while offering convenience and features for homeowners.

Summary


Ultimately, microcontrollers and microprocessors are different ways of organizing and optimizing a computing system based on a CPU. While a microcontroller puts the CPU and all peripherals onto the same chip, a microprocessor houses a more powerful CPU on a single chip that connects to external peripherals. Microcontrollers are optimized to perform a dedicated low-power application - ideal for embedded systems - while microprocessors are more useful for general computing applications that require more complex and versatile computing operations.

The growing demand for "smart" devices across industries is creating a major area of opportunity for embedded systems engineers to develop their capabilities and launch new products. Embedded systems consist of a microcontroller with on-board memory, a power supply, and communication ports for transmitting data to other devices. Embedded software programs tell the microcontroller how to respond in real time to data collected from the environment through peripheral sensors and devices. Embedded systems are used to enhance safety, reduce costs, and offer convenience and cost-savings to customers in industries that include automotive, home/consumer electronics, communications, and healthcare.

Differences Between Arduino and Raspberry Pi

No.ArduinoRaspberry Pi
1.Control unit of Arduino is from Atmega family.While control unit of Raspberry Pi is from ARM family.
2.Arduino is based on a microcontroller.While Raspberry Pi is based on a microprocessor.
3.It is designed to control the electrical components connected to the circuit board in a system.While Raspberry Pi computes data and produces valuable outputs, and controls components in a system based on the outcome of its computation.
4.Arduino boards have a simple hardware and software structure.While Raspberry Pi boards have a complex architecture of hardware and software.
5.CPU architecture: 8 bit.CPU architecture: 64 bit.
6.It uses very less RAM, 2 kB.While Raspberry Pi requires more RAM, 1 GB.
7.It clocks a processing speed of 16 MHz.While Raspberry Pi clocks a processing speed of 1.4 GHz.
8.It is cheaper in cost.While Raspberry Pi is expensive.
9.It has a higher I/O current drive strength.While Raspberry Pi has a lower I/O current drive strength.
10.It consumes about 200 MW of power.While it consumes about 700 MW of power.
11.Its logic level is 5V.Its logic level is 3V.
12.It does not have internet support.It has inbuilt Ethernet port and WiFi support.
13.It has higher current drive strength.It has lower current drive strength.
14.Some of the applications of Arduino are traffic light countdown timer , Weighing machines , etc.Some of the application of Raspberry Pi are Stop motion cameras , Robot Controllers , Game Servers.

References

Total Phase Blog. 2022. Microcontroller vs Microprocessor - What are the Differences?. [online] Available at: <https://www.totalphase.com/blog/2019/12/microcontroller-vs-microprocessor-what-are-the-differences/#:~:text=Ultimately%2C%20microcontrollers%20and%20microprocessors%20are,that%20connects%20to%20external%20peripherals.> [Accessed 24 September 2022].

GeeksforGeeks. 2022. Difference between Arduino and Raspberry Pi - GeeksforGeeks. [online] Available at: <https://www.geeksforgeeks.org/difference-between-arduino-and-raspberry-pi/#:~:text=Arduino%20is%20based%20on%20a,circuit%20board%20in%20a%20system.> [Accessed 24 September 2022].


Sunday, August 28, 2022

What is JavaScript, NodeJs, ReactJs, TypeScript?

 

What is Java
Script?

JavaScript is a very powerful client-side scripting language(will discuss later). JavaScript is used mainly for enhancing the interaction of a user with the webpage(page opened in the browser). In other words, you can make your webpage more lively and interactive, with the help of JavaScript.

JavaScript was developed by Brendan Eich in 1995, which appeared in Netscape, a popular browser of that time. The language was initially called LiveScript and was later renamed JavaScript.

In simple words,

JavaScript was initially created to “make web pages alive”.

When people say “JavaScript is a very powerful client-side scripting language”, again you will wonder about, now what the heck is this Scripting language? Why we call some languages as “Core programing language” & some language as “Scripting language”? Don’t worry let me explain it to you.

Credits: Unplash

Language vs Script

So if you are new in the development profile you used to listen to these keywords very frequently. In one way all the scripting languages are programming languages, The theoretical difference between the two is that scripting languages do not require the compilation setup and are rather interpreted at run time like PHP & JavaScript. However, Language requires a full compilation environment to first compile the code and then run the code as we did in colleges and schools with Java & C. If you got the point you can move to the next heading but if you are still confused let's see this example.

Example 1:
In “C” (language), The C compilation process starts with the source code as input and converts the source code into machine-readable code. The process can be broken down into four steps: Preprocessing, Compiling, Assembling, and Linking.
Whereas in PHP/JavaScript(Scripts) interpreters read the code and execute in real-time rather than making a machine-readable code of the code first.

An interpreter produces a result from a program(Script), while a compiler produces a program(language) written in assembly language. :- Knowledge base, Indiana Univeristy

Language vs Framework

At the start of the college, Coding is quite simple, we have libraries(stdio.h, if you used C in college), variables, for loops, if conditions, functions, etc. But as we start developing more we introduced to the new keyword “Framework”.
What is this Framework? Don't we already have so much to understand and learn that this new terminology also introduced to create confusion? Let’s understand this by an example first.

Everybody knows about Hindi & Devanagiri correct? So as we know Devanagiri is a lipi to write Hindi & some other languages. Devanagiri defines the set of rules and the manner of writing in which Hindi is written. While In Hindi we have pre-defined keywords(made by Hindi alphabets अ आ इ ई उ ऊ) to use by which we communicate.

The same thing applied in language & framework also, A language is just a minimal set of rules for doing things like “Devanagiri”. Whereas the framework is a collection of useful tools written for a particular programming language as we discuss in the above example “Hindi”. So JavaScript is a language but Angular is a framework, JavaScript provides a minimal set of rules for coding and system tools to compile it whereas Angular provides a collection of useful tools to make coding easy and organized.

A software framework (be it front-end or backend) includes standardized, pre-written code, which makes the development of certain functionalities easier and faster. You have less freedom to code, as you have to code as the framework architecture dictates. :- DZone.com

I hope, now you got the difference between framework, Language & Scripts. Let’s come back on the topic for which you are here. JavaScript!

Credits: Codemagic blog

What JavaScript can do?

What is the purpose of reading JavaScript, what is the scope of JavaScript, is it really helpful if you want to pursue your career in this language? Let's check it out.
Basics

  • JavaScript can add new HTML to the page, change the existing content, modify styles.
  • JavaScript React to user actions, run on mouse clicks, pointer movements, key presses.
  • Send requests over the network to remote servers, which are called APIs.
  • Get and set cookies, ask questions to the visitor, show messages.
  • Remember the data on the client-side(store data in the browser’s local storage).

When you visit some websites and a popup appears from nowhere asking to subscribe to the website. JavaScript is at work.

Advance

  • JavaScript used to create server APIs.
  • JavaScript used to interact with the database.
  • We can make cross-platform mobile apps(both IOS/Android) in JavaScript.
  • JavaScript used to make desktop applications as well as a gaming platform.

So it’s like JavaScript can do anything, whatever you want whenever you want JavaScript has a solution for the same.

How did JavaScript run?

In the early days of JavaScript, it was executed only in the browser, but with the enhancement in the language now we can run JavaScript also on the browser, server, mobile apps, or actually on any device that has a special program called the JavaScript engine. With the help of a JavaScript engine, we can run JavaScript anywhere.

— — — — — — — — — — -For extra knowledge — — — — — — — — — —
The browser has an embedded engine sometimes called a “JavaScript virtual machine”.Different engines have different “codenames”. For example:
V8 in Chrome and Opera.
SpiderMonkey in Firefox.
- “Trident” and “Chakra” for different versions of IE.
- “ChakraCore” for Microsoft Edge.
- “SquirrelFish” for Safari.

So now you know what is JavaScript? What are its applications? How does it run and what is the difference between language/scripts/frameworks? Now when you google “JavaScript” on the internet or talk with some JavaScript developer, he will tell you I am a node developer or I am an angular developer or some kind of full stack developer. Again your mind gets confused now JavaScript is cool but what are these things everyone discussing about. No need to worry we are going to understand the same.

Heck between NodeJS, AngularJS, ReactJS & Typescript

Credits: Guru99

All these keywords(note: not saying language) include “JS” as the suffix, what is mean by that. Is it all some kind of language extracted from JavaScript or totally different like Java(Language) & JavaScript(Script).

NodeJS & AngularJS are the frameworks(already explained above) of JavaScript. Some people say “NodeJS is JavaScript run time”. For now it’s simply a framework for you. We will learn about this in upcoming tutorials. is Now let’s see how these two main frameworks are useful. I already told you JavaScript runs on the server-side(Back-end) as well as on the client-side(front-end, on the browser). So to implement JavaScript on the server(back-end) we use the NodeJS framework and to implement JavaScript on the client-side(front-end) we have AngularJS framework.

Simply put, Node JS is a back-end development framework, while Angular is a front-end development framework.:- Quora

Credits: ValueCoders

Other than these two frameworks ReactJS is a simple library. A library is a collection of functions and functionalities, which you can use to achieve your functionalities & requirements. For a better understanding of the library recall your starting days of coding in C when we need to use <stdio.h> for input/output operations & <math.h> for mathematical operation. So unlike Node & Angular, React is not a framework of JavaScript but a simple library that we can include in the existing code anytime(Click here) and use it predefined functions and other benefits to make our coding faster and easier. We can make the project in the React from scratch also. The basic difference between Library & Framework is…

Our code calls the library while the framework calls your code.

Frameworks are fine(Node/Angular), Libraries are fine(React) but what is TypeScript? TypeScript can be explained as a superset of JavaScript. It means that every JavaScript code is valid Typescript code, but Typescript comes with some additional features which JavaScript don’t have:
Strong-typed variables: We can define a variable’s type with the strong-typing feature like we define a variable in Java or C++. Strong typing means once variable type declared it can’t be changed or manipulated.
Object-oriented programming: We are able to write object-oriented code with Typescript whereas in JavaScript you will not(till ES5).

 If you are a newbie to JavaScript don’t worry about TypeScript for now because there is a whole sea of knowledge in JavaScript itself, For now, you can focus on JavaScript, Node, Angular, React and then you will get the point and use of TypeScript.

Reference: Singh, P., 2022. What are the differences between JavaScript, Node, TypeScript, Angular and React?. [online] Medium. Available at: <https://javascript.plainenglish.io/noobies-exploration-to-javascript-part-1-introduction-to-js-diff-b-w-93c8cc062fa8> [Accessed 28 August 2022].

Tuesday, August 16, 2022

Manual edit for Windows right click context menu

 

Edit Right Click Menu for Desktop

HKEY_CLASSES_ROOT\Directory\Background\shell

HKEY_CLASSES_ROOT\Directory\Background\shellex\ContextMenuHandlers




 

Edit Right Click Menu for Folders

HKEY_CLASSES_ROOT\Folder\shellex\ContextMenuHandlers\

HKEY_CLASSES_ROOT\Directory\shell

Edit Right Click Menu for Files

HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers\

Thursday, May 26, 2022

Calculate easy way (My created easy problem- Codeforces Style)

 

Solution

#include<iostream>

using namespace std;

int main()

{

    int n,p;

    cin>>n>>p;

    if(n>p)

    {

        while(n%10!=0)

        {

            n++;

            p--;

        }

        cout<<n<<" "<<p;

    }

    else if(p>n)

    {

        while(p%10!=0)

        {

            p++;

            n--;

        }

        cout<<n<<" "<<p;

    }

}