echo '' ;

Category Archives: Embedded

Embedded Sensor – ADXL345

This article is a continuation of the series on “Embedded Sensor – ADXL345” and carries the discussion on Size, Functional Diagram, Pin Configuration, Application, Features and Benefits, ADXL345 Interface accelerometer, and Projects with this accelerometer. This sensor from Analog Devices

Digital output data is formatted as 16-bit twos complement and is accessible through either an SPI (3- or 4-wire) or I2C digital interface.

Read more… →

Interview Questions – UART

“In an interview, questions are the bridges between a candidate’s experiences and an employer’s expectations. They pave the way for understanding, insight, and the journey towards finding the perfect professional match. Before entering into UART interview questions, it is suggested to go through the UART protocol tutorial at least once. UART, or Universal Asynchronous Receiver-Transmitter, is a communication protocol used for serial communication between devices. It involves the transmission of data between devices bit by bit, without a shared clock signal.

UART

UART is commonly employed in various applications, serving functions such as connecting microcontrollers to other peripherals, facilitating communication between embedded systems, and interfacing with sensors and other hardware components. Moreover, its versatility extends across a spectrum of use cases. Additionally, this adaptability positions UART as an integral component in diverse fields, showcasing its significance in fostering seamless communication within a wide range of electronic systems

The protocol defines the format of the data being sent, including start and stop bits, data bits, and optional parity for error checking. Additionally, UART provides a simple and versatile method for devices to exchange information serially. Moreover, this inherent flexibility and ease of implementation make it a widely adopted communication standard in various applications, ranging from microcontroller communication to data logging and industrial automation.

Read more… →

Embedded – Little Endian and Big Endian

“Little Endian and Big Endian” are two different ways of storing multi-byte data types like integers, floating-point numbers, etc., in computer memory.

The architecture of the processor determines the choice between these two types. Little type is commonly used in x86 and x86-64 architectures, while Big type may be used in some older architectures and network protocols. The endianness of a system can affect data interchange between systems with different endianness.

  • Little and big are two ways of storing multibyte data types ( int, float, etc).

To illustrate this, let’s consider a 4-byte integer 0x12345678:

Big Type

In this type of system, the lowest memory address stores the most significant byte (referred to as the “big end”) of a multi-byte data type, while subsequent bytes store in decreasing order of significance. That is, the most significant byte comes first.

In this type, it would be stored as 12 34 56 78 in memory, with the most significant byte 12 stored at the lowest memory address.

Little Type

In a Little type system, multi-byte data types store the least significant byte (referred to as the “little end”) at the lowest memory address, with subsequent bytes arranged in increasing order of significance. That is, the least significant byte comes first.

In Little Type, it would be stored as 78 56 34 12 in memory, with the least significant byte 78 stored at the lowest memory address.

Example-1: Understanding of Little Endian and Big Endian

Lets assume the value 0x01234567 (4Byte Data) will be going to store in Memory.

The below Image Link

Example-2: Understanding

Lets assume the value 0xFFAA5500 (4Byte Data) will be going to store in address from 4000 to 40003.

Little Type

AddressData
4003FF
4002AA
400155
400000

Big Type

AddressData
400300
400255
4001AA
4000FF

Example-3: Understanding

Let’s assume the value 0x6573A429 (4Byte Data) will be going to store in a 32-bit machine address from 20008 to 20000B.

AddressLittle TypeBig Endian Type
200086565
200097373
2000AA4A4
2000B6529

C Example Code

Advantage and Disadvantage

Certainly! Here’s a table summarizing the advantages and disadvantages of Little Type and Big Type:

AspectLittle EndianBig Endian
Advantages
EfficiencyEfficient memory access due to direct access to least significant byteHuman-readable representation aligning with natural digit order
Conversion EaseSimplified byte swapping operations for data interchangeConsistency with some network protocols and file formats
Compatibility
Disadvantages
CompatibilityPotential compatibility issues when interacting with Big Endian systemsByte swapping overhead for data interchange with Little Endian systems
Memory AccessLess efficient memory access due to potential byte swapping

NEXT

CRC

A cyclic redundancy check (CRC) is an error-detecting code commonly used in digital networks and storage devices to identify accidental changes to raw data. Blocks of data entering these systems receive a short check value based on the remainder of a polynomial division of their contents. This method primarily detects data errors during data transmission and reception. Different types of Cheks are available based on the number of bits used.

CC
CRC

The sender and receiver share a generator polynomial. They utilize it whenever storing or transmitting digital data. The risk of data corruption exists in such processes. To address this risk, transmitted messages undergo segmentation into predetermined lengths. Subsequently, these segments are divided by a fixed divisor, and the remainder of this division gets calculated and appended to the message before transmission. Upon message reception, the recipient recalculates the remainder and compares it to the transmitted remainder. If the numbers fail to match, an error is detected. This process contributes to ensuring the integrity of transmitted data in digital systems.

You can access web-based online tools for Error Check calculation at this link: https://crccalc.com/

Read more… →

Embedded Protocol – XMODEM

Ward Christensen developed XMODEM, a straightforward file transfer protocol, in 1977. It frequently finds application between two computers employing the XMODEM protocol. The protocol initiates transmission with the ‘C’ character, followed by packets. The receiver provides proper acknowledgment (ACK) for each packet. Identification of the last packet is facilitated by EOT, and the completion of transmission is signaled by ETB.

Read more… →

MP LAB

Shortcut 

  • Search word in whole project (SHIFT + Ctrl + F) 
  • Search word in current file (Ctrl + F) 
  • Change Font size Increase/Decrease in file (Alt + Mouse scroll ball)

TIME and Date

  • __DATE__
  • __TIME__

using __TIME__ and __DATE__ with the xc8 compiler I’m able to get the time and date as strings. As I don’t have a RTCC and only limited program and data memory, I want to implement the time & date functionality as efficiently as possible. So I’ve tried to use macros and thought this would save some memory, but unfortunately it does not.

  • For example: this is the code I use to get the starting hour as an int:  

#define BUILD_HOUR ((__TIME__[0] - '0') * 10 + __TIME__[1] - '0') int hour = BUILD_HOUR;// start value

I assumed that the preprocessor and compiler would optimize this, so I would not get a lot of addidtional memory usage. But the whole cumputation is done by the pic 12F1572 I use. Is there a better solution for this problem or any workaround ? 

ESP8266 Arduino-Core Interface – LED

LEDs have two legs, an anode (longer leg, positive) and a cathode (shorter leg, negative). Connect the anode to a current-limiting resistor and the other end of the resistor to the microcontroller’s output pin. Connect the cathode directly to the microcontroller’s ground (GND) pin. Interfacing an LED with an ESP8266 using the Arduino core is quite similar to the basic Arduino example. The ESP8266 Arduino core provides a convenient platform for programming ESP8266 modules with the Arduino IDE. Here’s a simple example of “interfacing an LED with an ESP8266 using an Arduino-core”ESP8266 Arduino-Core Interface – LED”:

Read more… →

8051 Interface – LCD


Interfacing an LCD (Liquid Crystal Display) with the 8051 microcontroller is a common practice in embedded systems for displaying information. Here’s a brief overview of 8051 Interface LCD

  • Hardware Connections: Connect the data lines (D0-D7) of the LCD to the GPIO pins of the 8051. Connect the control lines (RS, RW, E) to specific GPIO pins. Optionally, connect the backlight control pin and adjust the contrast using a potentiometer.
  • Initialization: Send initialization commands to the LCD to configure its operation mode, display settings, and other parameters. This typically involves sending specific command codes over the data lines.
  • Sending Data: To display characters or strings on the LCD, send the ASCII codes of the characters over the data lines while setting the RS (Register Select) line appropriately to indicate data transmission mode.
  • Sending Commands: To control the operation of the LCD (such as clearing the display, setting the cursor position, etc.), send command codes over the data lines while setting the RS line to indicate command transmission mode.
  • Timing Considerations: Ensure proper timing between data/command transmissions and the strobing of the E (Enable) line to ensure reliable communication with the LCD.
  • Busy Flag Checking: Check the busy flag of the LCD before sending new commands or data to ensure that the LCD is ready to receive new instructions.
  • Writing Custom Characters: Some LCDs allow you to define custom characters by programming specific patterns into the CGRAM (Character Generator RAM) of the LCD.
  • Example Code: Here’s a basic example of initializing and sending data to an LCD connected to an 8051 microcontroller:
Read more: 8051 Interface – LCD

Uses of LCD

  • Displaying Information: LCDs (Liquid Crystal Displays) are used to visually display information such as text, numbers, and symbols.
  • Interface Compatibility: They can be easily interfaced with 8051 microcontrollers through parallel or serial communication interfaces.
  • Textual Output: LCDs allow for the display of textual information, making them suitable for user interfaces or information panels.
  • Low Power Consumption: They typically consume less power compared to other display technologies, making them suitable for battery-powered devices.
  • Compact Size: LCD modules come in various sizes, allowing for flexibility in design and integration into compact devices.
  • Backlighting Options: Some LCD modules offer backlighting options, enabling visibility in low-light conditions.
  • Dynamic Display: LCDs can be dynamically updated to show changing information or real-time data.
  • Multipurpose Usage: They find applications in various domains such as digital clocks, thermometers, calculators, and industrial control panels.

Next will see about code of 8051 Interface LCD

Code Header file (LCD8.h)

#define LCD_First_Line     0x80
#define LCD_Second_Line    0xc0
#define LCD_Curser_On          0x0f
#define LCD_Curser_Off         0x0c
#define LCD_Clear_Display 0x01
#define Lcd8_Data_Port         P2

sbit Lcd8_RS = P0^0;
sbit Lcd8_RW = P0^1;
sbit Lcd8_EN = P0^2;

void Lcd8_Init();
void Lcd8_Command(unsigned char);
void Lcd8_Write(unsigned char,unsigned char);
void Lcd8_Display(unsigned char,const unsigned char*,unsigned int);
void Lcd8_Decimal2(unsigned char,unsigned char);
void Lcd8_Decimal3(unsigned char,unsigned char);
void Lcd8_Decimal4(unsigned char,unsigned int);
void Delay(unsigned int);

void Lcd8_Init()
{
    Lcd8_Command(0x38);     //to select function set
    Lcd8_Command(0x06);     //entry mode set
    Lcd8_Command(0x0c);     //display on
    Lcd8_Command(0x01);     //clear display
}

void Lcd8_Command(unsigned char com)
{
    Lcd8_Data_Port=com;
    Lcd8_EN=1;
    Lcd8_RS=Lcd8_RW=0;
    Delay(125);
    Lcd8_EN=0;
    Delay(125);
}

void Lcd8_Write(unsigned char com,unsigned char lr)
{
    Lcd8_Command(com);

    Lcd8_Data_Port=lr;          // Data 
    Lcd8_EN=Lcd8_RS=1;
    Lcd8_RW=0;
    Delay(125);
    Lcd8_EN=0;
    Delay(125);
}

void Lcd8_Display(unsigned char com,const unsigned char *word,unsigned int n)
{
    unsigned char Lcd_i;

    for(Lcd_i=0;Lcd_i<n;Lcd_i++)
    { 
        Lcd8_Write(com+Lcd_i,word[Lcd_i]);
    }
}

void Lcd8_Decimal2(unsigned char com,unsigned char val)
{
    unsigned int Lcd_hr,Lcd_t,Lcd_o;

    Lcd_hr=val%100;
    Lcd_t=Lcd_hr/10;
    Lcd_o=Lcd_hr%10;
    
    Lcd8_Write(com,Lcd_t+0x30);
    Lcd8_Write(com+1,Lcd_o+0x30);
}


void Lcd8_Decimal3(unsigned char com,unsigned char val)
{
    unsigned int Lcd_h,Lcd_hr,Lcd_t,Lcd_o;

    Lcd_h=val/100;
    Lcd_hr=val%100;
    Lcd_t=Lcd_hr/10;
    Lcd_o=Lcd_hr%10;
    
    Lcd8_Write(com,Lcd_h+0x30);
    Lcd8_Write(com+1,Lcd_t+0x30);
    Lcd8_Write(com+2,Lcd_o+0x30);
}

void Lcd8_Decimal4(unsigned char com,unsigned int val) 
{
    unsigned int Lcd_th,Lcd_thr,Lcd_h,Lcd_hr,Lcd_t,Lcd_o;

    val = val%10000;
    Lcd_th=val/1000;
    Lcd_thr=val%1000;
    Lcd_h=Lcd_thr/100;
    Lcd_hr=Lcd_thr%100;
    Lcd_t=Lcd_hr/10;
    Lcd_o=Lcd_hr%10;

    Lcd8_Write(com,Lcd_th+0x30);
    Lcd8_Write(com+1,Lcd_h+0x30);
    Lcd8_Write(com+2,Lcd_t+0x30);
    Lcd8_Write(com+3,Lcd_o+0x30);
}

void Delay(unsigned int del)
{
    while(del--);
}     

Code Main File (LCD8_Interface_Main.c)

#include<reg51.h>
#include "LCD8.h"

void timer_init(void);

static unsigned char i;
static unsigned int x=100,y=150,cnt; 

void main()
{
    Lcd8_Init();
    Lcd8_Display(LCD_First_Line,"   Hello World  ",16);
    while(1)
    {
        Lcd8_Display(LCD_Second_Line," ArunEworld.com ",16);
    }//while(1)
}//void main()

8051 Interface – Servo

This tutorial demonstrates how to interface a servo motor with an 8051 microcontroller, allowing precise control over the motor’s position and movement.

One of the most commonly used motors for precise angular movement is the stepper motor. Its advantage lies in its ability to control the angular position without requiring any feedback mechanism. It finds widespread use in industrial and commercial applications, moreover, it is commonly employed in drive systems such as robots and washing machines.

Read more… →

8051 Interface – Keypad

In this tutorial, we’ll explore the process of interface a 4×4 or 4×3 matrix keypad with the 8051 microcontroller. Its versatility and ease of interfacing with external peripherals make the 8051 microcontroller a popular choice for various embedded systems. One common peripheral is the keypad, which serves as an input device in numerous applications such as security systems, industrial control systems, and consumer electronics.

Interfacing a keypad with the 8051 microcontroller involves connecting the keypad’s rows and columns to specific pins on the microcontroller. The keypad typically consists of a matrix of switches arranged in rows and columns. When a key is pressed, it connects a particular row to a specific column, enabling the microcontroller to detect the pressed key by scanning the rows and columns.

We’ll discuss the hardware connections required and the software implementation to read the pressed keys. Additionally, we’ll demonstrate how to display the pressed keys on an LCD (Liquid Crystal Display) connected to the microcontroller, providing a user-friendly interface for input.

By the end of this tutorial, you’ll have a solid understanding of how to interface a keypad with the 8051 microcontroller, enabling you to incorporate user input functionality into your embedded systems projects.

A widely used input device, the keypad, features in various applications like telephones, computers, ATMs, electronic locks, etc., enabling users to input data for further processing. In this setup, we interface a 4×3 matrix keypad, consisting of switches arranged in rows and columns, with the microcontroller. Additionally, we interface a 16×2 LCD to display the output. The concept of interfacing the keypad is straightforward: each key on the keypad has two unique parameters, row and column (R, C). Whenever a key is pressed, the microcontroller identifies the pressed key by detecting its corresponding row and column numbers on the keypad.

Read more… →

Mongoose-OS – Get Start

Getting started with Mongoose OS (MOS) is pretty straightforward. That’s a basic overview of getting started with Mongoose OS. As you become more familiar with the platform, you can explore more advanced features and capabilities offered by Mongoose OS for developing IoT applications.

Read more: Mongoose-OS – Get Start

Get started

Here’s a shortened version of the installation and setup process for Mongoose OS:

  1. Installation: Install Mongoose OS on your machine by following the instructions on the Mongoose OS documentation website. You can use a package manager like npm or pip, or download the binaries directly.
  2. Environment Setup: Configure your IDE or text editor to work with Mongoose OS projects. Install any additional tools or SDKs required for your target platform.
  3. Creating a Project: Use the Mongoose OS CLI to create a new project. Run mos init in your desired directory to initialize a new project.
  4. Project Configuration: Customize your project by editing the mos.yml file in your project directory. Configure settings such as device type and communication protocols.
  5. Application Development: Write your application code in C/C++ or JavaScript. Create new source files in the fs directory of your project.
  6. Building and Flashing: Compile your application code with mos build. Flash the firmware to your device with mos flash. Ensure your device is connected via USB.
  7. Device Monitoring: Monitor your device’s logs and interact with it using mos console. View debug output and send commands from the console.
  8. Debugging and Iteration: Test your application on the device, debug any issues, and iterate on your code. Use mos command-line tools for managing your device and updating firmware as needed.

Mongoose-OS IDE’s

  • Web Browser based
  • Visual basic extensions

mos tool

What is mos tool ?

  • We need IDE for our project development.
  • mos tool like a web browser-based IDE.
  • we can use the mos tool to firmware upload & update, Build the firmware from c source, debug purpose and so on.
Read more… →

Embedded Sensor – Smoke Sensor

A smoke sensor is a device that senses smoke, typically as an indicator of fire. Commercial and residential security devices issue a signal to a fire alarm control panel as part of a fire alarm system , while household detectors, known as alarms, generally issue a local audible or visual alarm from the detector itself. The Analog Smoke/LPG/CO  G as Sensor (MQ2) module utilizes an MQ  -2 as the sensitive component and has a protection resistor and an adjustable resistor on board. The MQ-2 gas sensor is sensitive to LPG, i-butane, propane, methane, alcohol,Hydrogen and . It could be used in gas leakage detecting equipments in family and industry. The resistance of the sensitive component changes as the concentration of the target gas changes.

About

Smoke sensors, also known as smoke detectors or smoke alarms, are devices designed to detect the presence of smoke or combustion products in the air. These sensors are crucial components of fire detection and safety systems, alerting occupants of potential fire hazards in residential, commercial, and industrial settings.

There are several types of smoke sensors, including ionization smoke detectors, photoelectric smoke detectors, and combination smoke detectors. Ionization smoke detectors use a small amount of radioactive material to ionize the air between two electrically charged plates. When smoke enters the chamber, it disrupts the ionization process, triggering the alarm. Photoelectric smoke detectors, on the other hand, use a light source and a photosensitive receiver. When smoke particles enter the chamber, they scatter the light, which triggers the alarm. Combination smoke detectors combine ionization and photoelectric technologies for enhanced fire detection capabilities.

Overall, smoke sensors play a critical role in fire prevention and safety, providing early detection of smoke and potentially saving lives and property.

Read more… →

Embedded Sensor – Proximity

A proximity sensor is a type of sensor that detects the presence or absence of an object or obstacle in close proximity to it without physical contact. It works by emitting an electromagnetic field or beam of electromagnetic radiation, and then detecting changes in the field or radiation caused by the presence or absence of an object. Proximity sensors are commonly used in various applications such as automatic door openers, touchless faucets, mobile devices for screen activation, and industrial automation for object detection.

Read more: Embedded Sensor – Proximity

Real-Time Usage

On Mobile

           This sensor installed on the front of an iPhone 5 next to the earpiece automatically turns off the touchscreen when the sensor comes within a predefined range of an object (such as a human ear) when using the handset.

On Parking Sensor

Ultrasonic parking sensor: Source

Parking sensor on a fender

Type of Proximity

  • Capacitive Proximity Sensors
  • Inductive Proximity Sensors
  • Magnetic Proximity Sensors
  • Optical Type
    • Photoelectric
    • PhotoCell
    • Infrared Proximity Sensor (Passive Thermal)
  • Ultrasonic Type
  • Hall Effect Type

Proximity Sensor Application

  • Parking sensors, systems mounted on car bumpers that sense distance to nearby cars for parking
  • Ground proximity warning system for aviation safety
  • Vibration measurements of rotating shafts in machinery
  • Top dead centre (TDC)/camshaft sensor in reciprocating engines.
  • Sheet break sensing in paper machine.
  • Anti-aircraft warfare
  • Roller coasters
  • Conveyor systems
  • Beverage and food can making lines
  • Improvised Explosive Devices or IEDs
  • Mobile devices
    • Touch screens that come in close proximity to the face
    • Attenuating radio power in close proximity to the body, in order to reduce radiation exposure
  • Automatic faucets

Other Proximity Sensor

PRD-12-8DP Inductive Type

LJ12A3-4-Z-BY-Inductive-Proximity-Senso

  • Types NPN
  • Type : PNP
    • Data Sheet : Inductive Proximity Sensor Detection Switch PNP Model: LJ12A3-4-Z/BY
    • Specification :
      • A component widely used in automatic control industry for detecting, controlling, and non-contact switching When proximity switch is close to some target object, it will send out control signal.
      • Model: LJ12A3-4-Z/AY
      • Output Type: PNP NC(Normally Close)
      • Detecting Distance: 4mm±10%
      • Theory: Inductive Sensor
      • Wire Type: 3 Wire Type (Brown, Blue, Black)
      • Switch Appearance Type: Cylinder Type, Aluminum Shell
      • Supply Voltage: DC 6-36V
      • Current: 200A
      • Detect Object: Iron
      • Diameter: 12mm
      • Cable Length: 1M/3.3Ft
      • 1 x Inductive Proximity Sensor Switch
    • Price Approximately :340rs (India)

Embedded Sensor – NTC Temperature

This tutorial is about NTC Temperature sensor. Thermistors are temperature-sensing elements made of semiconductor material that have been sintered to display large changes in resistance in proportion to small changes in temperature. This resistance can be measured by using a small and measured direct current, or dc, passed through the thermistor in order to measure the voltage drop produced. These solid state temperature sensors actually act like electrical resistors that are temperature sensitive. That is where the name, a clear combination of the words thermal and resistor, comes from. Ametherm specializes in NTC, or negative temperature coefficient, thermistors.

NTC Temparature sensor

NTC (Negative Temperature Coefficient) thermistors, also known as NTC temperature sensors, measure temperature. They consist of semiconductor materials with a resistance that decreases as temperature increases. NTC thermistors exhibit a nonlinear resistance-temperature relationship, with resistance decreasing rapidly as temperature rises and vice versa.

These sensors are widely used in various applications due to their simplicity, accuracy, and low cost. Some common applications of NTC temperature sensors include:

  1. Temperature Sensing: NTC thermistors commonly measure temperature in electronic circuits, appliances, automotive systems, and industrial processes.
  2. Temperature Compensation: They stabilize the performance of electronic devices and components over a wide temperature range in temperature compensation circuits.
  3. HVAC (Heating, Ventilation, and Air Conditioning): NTC thermistors sense and control temperature in HVAC systems, aiding in regulating heating and cooling for optimal comfort and energy efficiency.
  4. Food and Beverage Industry: NTC temperature sensors monitor and control temperature during cooking, refrigeration, and transportation in food processing and storage applications.
Read more… →