Sunday 9 April 2017

Typecasting in Embedded C


"In this blog we will study about “Typecasting in Embedded  C”

Type casting in C language is the process of converting one data type variable to another data type. For example converting integer value to long integer value. These are also called short instruction in embedded C. Some time type casting is handled by the compiler and in some IDE’s programmer has to take care of this.   On the base of compiler capability types casting is of two types:
Implicit Type casting: in this Compiler will take care of all type casting functionality. 
Explicit Type casting: In this programmer has to take cares type casting when solving mathematical expressions. 
Syntax of typecasting is as follows:
(data_type)expression;
Here data_type is the new data type in to which we have to convert expression. Type casting also called short instruction in embedded C.

/**********************Example of type Casting************************/
unsigned char var1;     // declaration of unsigned character var1
float var2;                    // declaration of float variable var2
unsigned int var3;       //declaration of unsigned int variable var3

var1=40;                      // save value 40 to var1
var3= var1*10;           // if compiler does not support implicit type casting after this instruction                        //execution  var3 will contain 190. Because compiler consider var1 as char
var3 =  (unsigned int)  var1/10;  // after execution of this instruction var3 will contain 400.
var1= 55;
var2=(float)var1/6;  //in this case first we have type cast var1 to float and then divide by 6. 
                                   //In this case var2 will contain 9.166666
There are two type of type casting first is Upcasting and Downcasting. If we converting data type from lower data type to higher data type i.e. chats to integer or integer to float, then it is called Upcasting.  If we are converting from higher data type to lower data type, it is called Downcasting.
Down casting help when we have to convert 16 bit integer values to two bytes. Lower byte can be easily extracted without shifting operation.  For example:
var3 = 0x1234;
var1 = (unsigned char)var3;
in this case we type cast var3 to unsigned char.  After execution of this instruction var1 will contain 0x34.
Type casting is also used in arithmetic operation to get correct result. this is very much needed in case of division when integer gets divided and the remainder is omitted. In order to get correct value always use typecasting.


Sunday 5 February 2017

The Future of IoT is Embedded Systems and Real-time Operating Systems (RTOS)

Embedded systems are highly customized, developed and programmed as per user requirements.  Conventional embedded systems are electronic components that possess a microprocessor, peripherals, memory card, and software program that run instructions, operating system and tools (debuggers, static and non-programmable), and follows firmware programming embedded in the micro-chip.
Embedded systems will play an important role in Internet of Things (IoT) due to their unique characteristics and features such as real time computing, low power consumption, low maintenance and high availability are becoming the key enabler of IoT.  Major players in embedded system hardware and software developments are aiming to bring these transformations into their products to take advantage of growing IoT market. The areas that are going to transform are Real Time Operating Systems (RTOS) and microprocessors and microcontrollers, followed by memory footprints and networking, open source communities and developers.
Smart embedded systems will require changing contemporary embedded system design and architecture to suit real-time operations, smaller size of the unit and lowered power consumption and become cost efficient. Use of microcontroller and technologies such as Systems on Chip (SoC) and Reduced Instruction set Computing Chips (RISC) will have greater scope in IoT.
Related to embedded systems is Real-time Operating Systems (RTOS), which is an OS that manages hardware resources, hosts applications, and processes data on real-time basis.  RTOS defines the real time task processing time, interrupt latency, and longer period reliability of both hardware and applications, especially for low powered and memory constrained devices and networks.  The key difference between RTOS and a general purpose OS lies within its high degree of reliability and consistency on timing between application's task acceptance and completion.

What is the future of a career in embedded systems engineering?

The field of embedded systems engineering has given me a good steady income since the 1970s, and it still does to this day.  The number of "intelligent" devices continues to multiply rapidly, and all of those devices are "embedded systems" (a device with a processor in it which is not considered a "traditional" computer).  All of those devices run on code, therefore needing software engineers skilled in the technologies of embedded systems to create that code.  As the number of different intelligent devices in the world grows, so does need for embedded engineers - it's that simple.  And since it appears that almost every technological device has an embedded processor in it, and the number and kind of those devices will only continue to increase there is most certainly a very bright future for embedded engineers.  Consider the latest tech "trend", IoT (Internet of Things) - it's all about embedded devices!!! 
A good analogy is cloud providers like AWS, GCE etc. Once upon a time, if you had to develop your application, on top of writing the application logic, you also had to configure DNS routing, load balancing, caching, data-store etc. Now that applications are getting hosted online via popular cloud service providers, most of this routine, non-creative but very-much-needed work is automatically given to you as basic platform services, leaving you with just the creative component of your unique application. This aspect of PaaS/IaaS providers is called as non-differentiated heavy lifting.
This is bound to happen in embedded systems engineering as well. As a matter of fact, its well underway with commodity hardware, off-the-shelf chips coming inbuilt with networking and routing, sensor and drones manufactured inexpensively in China/Taiwan with in-built MPLS, GPS algorithms, plug and play diagnostic routines etc, etc. You name it.
So the key is to have a unique value proposition for yourselves, beyond simply knowing to program in C/C++, experience in BIOS/PROM, SAS, PCI-e, I2C. That kind of job does exist very much in the market now, think IoT, connected cars, VR headsets or even the Pebble smart watch. It can be a niche role.