SlideShare a Scribd company logo
General Drivers
Embedded Systems
Agenda
• What is Generic Drivers
• Digital Input and Output Ports
• Keys
• Key Matrix
• LEDs
• LED Matrix
• PWM Outputs
• Displays
• Seven Segments Displays
• Alphanumeric LCDs
• EEPROM Interface
• RS232 vs RS485
Key Input
• We can use the microcontroller, GPIO to detect the key input signal. We need to
configured the microcontroller pin/port as input port. Here in above example
microcontroller pin (port 7 bit 0) P70 is used to capture the input. Consider when
switch is not pressed (OFF), the value at microcontroller pin will be HIGH (1) and
when switch is pressed (ON), the value at microcontroller will be LOW (0). The
program should be written to monitor the status of pin 0 (Port 7) to detect the
switch position (OFF/ON)
Key Debouncing Delay
• Generally bouncing and debouncing delay is
required to avoid wrong key detection in case of
momentary spike because of noise.
• This delay can be of 5ms to 10ms, which can be
implemented using timers.
4x4 Matrix Keypad
• To increase the number of key connection,
keys can be connected in matrix. We will be able
to connect 16 keys using 4x4 matrix on one
microcontroller port (8 pins). Let's consider we
port 0 for key connection. First 4 pins from left
(X1, X2, X3, X4) are considered as row and rest 4
(Y1, Y2, Y3, Y4) are columns.
• We need to make rows pins (X1, X2, X3, X4) as
output pins and columns pins as input pints (Y1,
Y2, Y3, Y4). To make the pins as output, we load
the value LOW (0) to the pins. To configure pins as
input we make the pin HIGH(1). For example, if
key 1 is pressed then Y1 should goes LOW (0), as
X1 is low. X1 value is transferred to Y1. Similarly, it
will be applied for the rest of the keys as well.
4x4 Matrix Keypad
• To configure X1, X2, X3, X4 as output, we
configured pins as LOW (0).
• To detect the switch position (pressed/released),
We need to make the Y1, Y2, Y3 and Y4 as high or
1.
• Otherwise, we will not be able to detect the
changes, of switch position (pressed/released)
• PORTX = 0xF0;
4x4 Matrix Keypad
• Key2 Pressed: As key2 comes in X1 line make the X1 as LOW (0)
• X1 = 0; X2 = 1; X2 = 1; X4 = 1;
• Now if Y2 == 0 then considered that key2 is being pressed.
• Here _delay_ms(100) is deboucing delay to confirm the key pressed.
• X1 is for key1, key2, key3, key4 (scan from Y1, Y2, Y3, Y4 to detect key
pressed)
• X2 is for key5, key6, key7, key8(scan from Y1, Y2, Y3, Y4 to detect key
pressed)
• X3 is for key9, key10, key11, key12(scan from Y1, Y2, Y3, Y4 to detect key
pressed)
• X4 is for key13, key14, key15, key16(scan from Y1, Y2, Y3, Y4 to detect
key pressed)
PWM Output
PWM : Pulse Width Modulation
PWM is based on duty cycle variation which will
control the on & off time. It is being used for
multiple application.
Duty cycle = ON Time / Total Time
Example:
Total Time : 100ms
ON Time : 23ms
Duty Cycle : 23%
Duty cycle can be controlled based on timer
implementation to make the pin HIGH (1) and LOW
(0).
In most cases based on the certain Input signal
values, duty cycle will be decided.
LED Matrix
Depending on Interfacing type, HIGH or LOW will be sent on the port pin to make
the LED Glow.
/* To blink */
P0_0 = 1; /* Turn ON */
Delay_ms(100);
P0_0 = 0; /* Turn OFF */
Delay_ms(100);
LED Matrix
• Just like key Matrix we have LED matrix to
increase the number of connected LEDs. The
similary apporoach is being used here for LED
Matrix as well.
• To turn the specific LED ON, We need to set the
corresponding row pin to HIGH (1) and the column
pin to LOW (0)
LED Matrix
• const char raw[3] = {3,4,5};
• const char col[3] = {8,9,10};
• for (num =0; num<3; num++)
• {
• pinMode(raw[num]) = OUTPUT;
• pinMode(col[num]) = OUTPUT;
• digitalWrite(col[num]) = HIGH;
• }
LED Matrix
• void led_ON(int row, int col)
{
digitalWrite(pins_rows[row], HIGH);
digitalWrite(pins_cols[col], LOW);
}
void led_OFF(int row, int col)
{
digitalWrite(pins_rows[row], LOW);
digitalWrite(pins_cols[col], LOW);
}
ADC (Analog to Digital Convertors)
We always use analog to digital convertor to
measure the different parameters like
temperature, sound, pressure, light, voltage,
current etc. We will be able to store the recorded
values in controller or in memory as needed. We
need sensor which will gives us the analog values
corrosponding to the parameter which we are
going to measure. The output of sensor may be
linear or nonlinear depending on the type of
sensor. In case of linear output, it will be easy to
implement, process & map the values. However,
in case of nonlinear we may need to use table
which will be generally given in datasheet.
ADC (Analog to Digital Convertors)
• Analog to Digital Converter, commonly known as (ADC) is an electronic integrated circuit which is used to
convert the analog signals to digital form consisting of 1s/0s.Most of the ADCs take a voltage input as 0 to 5V,
etc. correspondingly ADC will produce digital output depending on the resolution of the ADC.
ADC can be based on I2C or SPI protocol, which is now commonly used across different industries.
• Serial ADC (SPI or I2C based ADC)
• Parallel ADC
ADC (Analog to Digital Convertors)
Output
Example:
Resolution
How to calculate voltage
corrosponding to 1 ADC
Count
10 bits ADC : 2^10 States :
1024 Values (5V)
• 0V = 0 ADC Count
• 5V = 1024 ADC Count
5000 mv/4095 = 1.23 mv
minimum change is
required to move 1 ADC
count
12 bits ADC : 2^12 States :
4096 Values (5V)
• 0V = 0 ADC Count
• 5V = 4095 ADC Count
5000 mv/1024 = 4.9 mv
minimum change is
required to move 1 ADC
count
Output
ADC Comparison
Alphanumeric
LCDs (16x2)
Alphanumeric LCDs
(16x2)
Alphanumeric
LCDs (16x2)
• The 16x2 Alphanumeric LCD means, I can show
up-to 2 lines of 16 characters. Each LCD character
contains the 5x8 pixel grid. The most LCD will have
two registers.
• Command Register (Required to send the
different
commands/instruction/operations)
• Data Register (Required to send data
to display on LCD)
• The LCD have the different required commands to
provide the display functionality.
Examples:
• Clear Display, shift display right, shift display left,
force cursor position at beginning of line1/line2
• Shift entire display right, Shift entire display left
Alphanumeric LCDs
(16x2)
• Address range of each lines:
• Line 1: 0x80
• Line 2: 0xC0
• The value of data register will be displayed on LCD. To display the value on LCD, we need to load
the ASCII value of characters in data register.
Alphanumeric
LCDs (16x2)
• Data Bus:
• Data bus contains the data lines from D0-D7. In 8-bit data bus mode, we can send the
data/command to LCD in bytes. Most LCD supports 4-bit mode where we can send the
data/command in chunks of 4-bit, which is used when we have limited available GPIO
lines on the microcontroller.
Register Select(RS): As we know LCD has two register namely
• Data register : To display data on the LCD, we should
write to the data register.
• To select between the command or the data register, the RS signal is used. If we make
the RS pin HIGH & feed input to the data lines (DB0 to DB7), this input will be interpreted
as the data that is to be displayed on the LCD screen.
• If the RS signal is HIGH, then the LCD interprets the 8-bit info (DB0 to DB7) as data and
copies it to data register. After that the LCD decodes the data for generating the 5x7
pattern and finally displays on the LCD.
• Command register : To send the different command to LCD, we should write
to command register.
• If we make the RS pin LOW and feed input to the data lines (DB0 to DB7), then this
will be interpreted as a command.
• If the RS signal is LOW, then the LCD interprets the 8-bit info (DB0 to DB7)
as Command and writes it Command register and performs the action as per the
command.
Alphanumeric
LCDs (16x2)
R/W (bar): Read / Write (bar)
• It is used switch between read & write operation mode.
• R/W (bar) = LOW (0), Indicates Write Mode
• R/W (bar) = HIGH (1), Indicates Read Mode
• This signal is used to write the data/command to LCD & reads
the busy flag of LCD. For write operation the RW should
be LOW and for read operation the R/W should be HIGH.
EN: Enable
• The Enable signal is used to latch the data (that is to place the
data on the data bus from D0 – D7 and wait for a clock or pulse to
send it), and when high to low pulse is sent into the E pin of LCD
the data is displayed on the LCD.
• A HIGH-to-LOW pulse is required be sent on enable pin, which
will latch the info into the LCD register. This will trigger the LCD to
act accordingly.
Alphanumeri
c LCDs
Alphanumeri
c LCDs
Alphanumeric
LCDs
Data send
Alphanumeric LCDs
Command Send
Alphanumeric
LCDs
Sequence:
• Send the command on data lines (DB0 to DB7)
• Select the command register using RS (RS = LOW)
• Select the write operation using R/W (bar), (RW = LOW)
• Send High to Low pulse on Enabler (EN) pin with delay
Alphanumeric
LCDs
Sequence:
• Send the ASCII data (Characters) required to displayed on-data lines
(DB0 to DB7)
• Select the data register using RS (RS = HIGH)
• Select the write operation using R/W (bar), (RW = LOW)
• Send High to Low pulse on Enabler (EN) pin with delay
Seven Segment Displays
Seven
Segment
Displays
Seven
Segment
Displays
Seven
Segment
Displays
Seven Segment
Displays
Digit gfedcba abcdefg a b c d e f g
0 0×3F 0×7E on on on on on on off
1 0×06 0×30 off on on off off off off
2 0×5B 0×6D on on off on on off on
3 0×4F 0×79 on on on on off off on
4 0×66 0×33 off on on off off on on
5 0×6D 0×5B on off on on off on on
6 0×7D 0×5F on off on on on on on
7 0×07 0×70 on on on off off off off
8 0×7F 0×7F on on on on on on on
9 0×6F 0×7B on on on on off on on
A 0×77 0×77 on on on off on on on
B 0×7C 0×1F off off on on on on on
C 0×39 0×4E on off off on on on off
D 0×5E 0×3D off on on on on off on
E 0×79 0×4F on off off on on on on
F 0×71 0×47 on off off off on on on
Seven
Segment
Displays
Interfacing
Memory
Interfacing
Memory
• START CONDITION: A high-to-low transition of SDA with SCL high is a
start condition which must precede any other command (refer to Start
and Stop Definition timing diagram).
• STOP CONDITION: A low-to-high transition of SDA with SCL high is a
stop condition. After a read sequence, the stop command will place the
EEPROM in a standby power mode (refer to Start and Stop Definition
timing diagram)
Interfacing
Memory
Interfacing
Memory
Interfacing
EEPROM
Interfacing
EEPROM
RS232 Vs RS485
RS232 Vs RS485
Description RS-232 RS-485
Transfer type Full duplex
Half duplex (2 wires),
full duplex (4 wires)
Maximum distance 15 meters at 9600 bps 1200 meters at 9600 bps
Contacts in use
TxD, RxD, RTS, CTS, DTR,
DSR, DCD, GND*
DataA, DataB, GND
Topology Point-to-Point Multi-point
Max. Number of connected
devices
1
32 (with repeaters larger, usually
up to 256)
Voltage Range
3V to 25V (Logic 0)
-3V to -25V (Logic 1)
200mV (Logic 0)
-200mV (Logic 1)
RS232 Vs
RS485
Questions

More Related Content

Similar to Basic of Firmware & Embedded Software Programming in C

Calculator design with lcd using fpga
Calculator design with lcd using fpgaCalculator design with lcd using fpga
Calculator design with lcd using fpga
Hossam Hassan
 
Decoders-Digital Electronics
Decoders-Digital ElectronicsDecoders-Digital Electronics
Decoders-Digital Electronics
Paurav Shah
 
8085 paper-presentation
8085 paper-presentation8085 paper-presentation
8085 paper-presentation
JiMs ChAcko
 
decoders121-170714184489769876987698749.pptx
decoders121-170714184489769876987698749.pptxdecoders121-170714184489769876987698749.pptx
decoders121-170714184489769876987698749.pptx
tlap4412
 
Interfacing technique with 8085- ADC[0808]
Interfacing technique with 8085- ADC[0808]Interfacing technique with 8085- ADC[0808]
Interfacing technique with 8085- ADC[0808]
Guhan k
 
Assembly Language and microprocessor
Assembly Language and microprocessorAssembly Language and microprocessor
Assembly Language and microprocessor
Khaled Sany
 
Training Report on embedded Systems and Robotics
Training Report on embedded  Systems and RoboticsTraining Report on embedded  Systems and Robotics
Training Report on embedded Systems and Robotics
NIT Raipur
 
Product catlog
Product catlogProduct catlog
Product catlog
Aarya Technologies
 
CC2500 Wireless Trans-receiver Module
CC2500 Wireless Trans-receiver ModuleCC2500 Wireless Trans-receiver Module
CC2500 Wireless Trans-receiver Module
Aarya Technologies
 
8085-paper-presentation.ppt
8085-paper-presentation.ppt8085-paper-presentation.ppt
8085-paper-presentation.ppt
KalaiSelvan911913
 
digitalvoltmeterusing805112b2-170214173216 (1).pdf
digitalvoltmeterusing805112b2-170214173216 (1).pdfdigitalvoltmeterusing805112b2-170214173216 (1).pdf
digitalvoltmeterusing805112b2-170214173216 (1).pdf
satyamsinha37
 
Interfacing to the analog world
Interfacing to the analog worldInterfacing to the analog world
Interfacing to the analog world
Islam Samir
 
DIGITAL VOLTMETER USING 8051 MICROCONTROLLER
DIGITAL VOLTMETER USING 8051 MICROCONTROLLERDIGITAL VOLTMETER USING 8051 MICROCONTROLLER
DIGITAL VOLTMETER USING 8051 MICROCONTROLLER
Chirag Lakhani
 
Lathe Spindle Sensor
Lathe Spindle SensorLathe Spindle Sensor
Lathe Spindle Sensor
JoeCritt
 
8255
82558255
The presentation is about USART and serial communication
The presentation is about USART and serial communicationThe presentation is about USART and serial communication
The presentation is about USART and serial communication
sinaankhalil
 
Universal synchronous asynchronous receiver transmitter(usart) and AtoD Coverter
Universal synchronous asynchronous receiver transmitter(usart) and AtoD CoverterUniversal synchronous asynchronous receiver transmitter(usart) and AtoD Coverter
Universal synchronous asynchronous receiver transmitter(usart) and AtoD Coverter
Tejas Shetye
 
Lec08
Lec08Lec08
EEE UNIT-2 PPT.pdf
EEE UNIT-2 PPT.pdfEEE UNIT-2 PPT.pdf
EEE UNIT-2 PPT.pdf
VishalPatil57559
 
Encoder-and-decoder.pptx
Encoder-and-decoder.pptxEncoder-and-decoder.pptx
Encoder-and-decoder.pptx
KamranAli649587
 

Similar to Basic of Firmware & Embedded Software Programming in C (20)

Calculator design with lcd using fpga
Calculator design with lcd using fpgaCalculator design with lcd using fpga
Calculator design with lcd using fpga
 
Decoders-Digital Electronics
Decoders-Digital ElectronicsDecoders-Digital Electronics
Decoders-Digital Electronics
 
8085 paper-presentation
8085 paper-presentation8085 paper-presentation
8085 paper-presentation
 
decoders121-170714184489769876987698749.pptx
decoders121-170714184489769876987698749.pptxdecoders121-170714184489769876987698749.pptx
decoders121-170714184489769876987698749.pptx
 
Interfacing technique with 8085- ADC[0808]
Interfacing technique with 8085- ADC[0808]Interfacing technique with 8085- ADC[0808]
Interfacing technique with 8085- ADC[0808]
 
Assembly Language and microprocessor
Assembly Language and microprocessorAssembly Language and microprocessor
Assembly Language and microprocessor
 
Training Report on embedded Systems and Robotics
Training Report on embedded  Systems and RoboticsTraining Report on embedded  Systems and Robotics
Training Report on embedded Systems and Robotics
 
Product catlog
Product catlogProduct catlog
Product catlog
 
CC2500 Wireless Trans-receiver Module
CC2500 Wireless Trans-receiver ModuleCC2500 Wireless Trans-receiver Module
CC2500 Wireless Trans-receiver Module
 
8085-paper-presentation.ppt
8085-paper-presentation.ppt8085-paper-presentation.ppt
8085-paper-presentation.ppt
 
digitalvoltmeterusing805112b2-170214173216 (1).pdf
digitalvoltmeterusing805112b2-170214173216 (1).pdfdigitalvoltmeterusing805112b2-170214173216 (1).pdf
digitalvoltmeterusing805112b2-170214173216 (1).pdf
 
Interfacing to the analog world
Interfacing to the analog worldInterfacing to the analog world
Interfacing to the analog world
 
DIGITAL VOLTMETER USING 8051 MICROCONTROLLER
DIGITAL VOLTMETER USING 8051 MICROCONTROLLERDIGITAL VOLTMETER USING 8051 MICROCONTROLLER
DIGITAL VOLTMETER USING 8051 MICROCONTROLLER
 
Lathe Spindle Sensor
Lathe Spindle SensorLathe Spindle Sensor
Lathe Spindle Sensor
 
8255
82558255
8255
 
The presentation is about USART and serial communication
The presentation is about USART and serial communicationThe presentation is about USART and serial communication
The presentation is about USART and serial communication
 
Universal synchronous asynchronous receiver transmitter(usart) and AtoD Coverter
Universal synchronous asynchronous receiver transmitter(usart) and AtoD CoverterUniversal synchronous asynchronous receiver transmitter(usart) and AtoD Coverter
Universal synchronous asynchronous receiver transmitter(usart) and AtoD Coverter
 
Lec08
Lec08Lec08
Lec08
 
EEE UNIT-2 PPT.pdf
EEE UNIT-2 PPT.pdfEEE UNIT-2 PPT.pdf
EEE UNIT-2 PPT.pdf
 
Encoder-and-decoder.pptx
Encoder-and-decoder.pptxEncoder-and-decoder.pptx
Encoder-and-decoder.pptx
 

More from Kapil Thakar

Timer Handling in UDS | S3 Server Timer | P2 and P2 Start Timer
Timer Handling in UDS | S3 Server Timer | P2 and P2 Start TimerTimer Handling in UDS | S3 Server Timer | P2 and P2 Start Timer
Timer Handling in UDS | S3 Server Timer | P2 and P2 Start Timer
Kapil Thakar
 
Introduction to UDS over CAN | UDS Service
Introduction to UDS over CAN | UDS ServiceIntroduction to UDS over CAN | UDS Service
Introduction to UDS over CAN | UDS Service
Kapil Thakar
 
Introduction to Automotive Bootloader | Programming Sequence
Introduction to Automotive Bootloader | Programming SequenceIntroduction to Automotive Bootloader | Programming Sequence
Introduction to Automotive Bootloader | Programming Sequence
Kapil Thakar
 
Automotive Bootloader Complete Guide with UDS Frame Format
Automotive Bootloader Complete Guide with UDS Frame FormatAutomotive Bootloader Complete Guide with UDS Frame Format
Automotive Bootloader Complete Guide with UDS Frame Format
Kapil Thakar
 
Automotive CAN Protocol | Flow Control | Block Size | ST Min | First Frame
Automotive CAN Protocol | Flow Control | Block Size | ST Min | First FrameAutomotive CAN Protocol | Flow Control | Block Size | ST Min | First Frame
Automotive CAN Protocol | Flow Control | Block Size | ST Min | First Frame
Kapil Thakar
 
Can Transport Protocol : UDS
Can Transport Protocol : UDS Can Transport Protocol : UDS
Can Transport Protocol : UDS
Kapil Thakar
 

More from Kapil Thakar (6)

Timer Handling in UDS | S3 Server Timer | P2 and P2 Start Timer
Timer Handling in UDS | S3 Server Timer | P2 and P2 Start TimerTimer Handling in UDS | S3 Server Timer | P2 and P2 Start Timer
Timer Handling in UDS | S3 Server Timer | P2 and P2 Start Timer
 
Introduction to UDS over CAN | UDS Service
Introduction to UDS over CAN | UDS ServiceIntroduction to UDS over CAN | UDS Service
Introduction to UDS over CAN | UDS Service
 
Introduction to Automotive Bootloader | Programming Sequence
Introduction to Automotive Bootloader | Programming SequenceIntroduction to Automotive Bootloader | Programming Sequence
Introduction to Automotive Bootloader | Programming Sequence
 
Automotive Bootloader Complete Guide with UDS Frame Format
Automotive Bootloader Complete Guide with UDS Frame FormatAutomotive Bootloader Complete Guide with UDS Frame Format
Automotive Bootloader Complete Guide with UDS Frame Format
 
Automotive CAN Protocol | Flow Control | Block Size | ST Min | First Frame
Automotive CAN Protocol | Flow Control | Block Size | ST Min | First FrameAutomotive CAN Protocol | Flow Control | Block Size | ST Min | First Frame
Automotive CAN Protocol | Flow Control | Block Size | ST Min | First Frame
 
Can Transport Protocol : UDS
Can Transport Protocol : UDS Can Transport Protocol : UDS
Can Transport Protocol : UDS
 

Recently uploaded

快速办理(napier毕业证书)英国龙比亚大学毕业证在读证明一模一样
快速办理(napier毕业证书)英国龙比亚大学毕业证在读证明一模一样快速办理(napier毕业证书)英国龙比亚大学毕业证在读证明一模一样
快速办理(napier毕业证书)英国龙比亚大学毕业证在读证明一模一样
78tq3hi2
 
一比一原版(Columbia文凭证书)哥伦比亚大学毕业证如何办理
一比一原版(Columbia文凭证书)哥伦比亚大学毕业证如何办理一比一原版(Columbia文凭证书)哥伦比亚大学毕业证如何办理
一比一原版(Columbia文凭证书)哥伦比亚大学毕业证如何办理
afkxen
 
EN Artificial Intelligence by Slidesgo.pptx
EN Artificial Intelligence by Slidesgo.pptxEN Artificial Intelligence by Slidesgo.pptx
EN Artificial Intelligence by Slidesgo.pptx
aichamardi99
 
原版制作(Exeter毕业证书)埃克塞特大学毕业证完成信一模一样
原版制作(Exeter毕业证书)埃克塞特大学毕业证完成信一模一样原版制作(Exeter毕业证书)埃克塞特大学毕业证完成信一模一样
原版制作(Exeter毕业证书)埃克塞特大学毕业证完成信一模一样
78tq3hi2
 
Hand Gesture Control Robotic Arm using image processing.pptx
Hand Gesture Control Robotic Arm using image processing.pptxHand Gesture Control Robotic Arm using image processing.pptx
Hand Gesture Control Robotic Arm using image processing.pptx
wstatus456
 
Charging and Fueling Infrastructure Grant: Round 2 by Brandt Hertenstein
Charging and Fueling Infrastructure Grant: Round 2 by Brandt HertensteinCharging and Fueling Infrastructure Grant: Round 2 by Brandt Hertenstein
Charging and Fueling Infrastructure Grant: Round 2 by Brandt Hertenstein
Forth
 
EV Charging at Multifamily Properties by Kevin Donnelly
EV Charging at Multifamily Properties by Kevin DonnellyEV Charging at Multifamily Properties by Kevin Donnelly
EV Charging at Multifamily Properties by Kevin Donnelly
Forth
 
Charging Fueling & Infrastructure (CFI) Program by Kevin Miller
Charging Fueling & Infrastructure (CFI) Program  by Kevin MillerCharging Fueling & Infrastructure (CFI) Program  by Kevin Miller
Charging Fueling & Infrastructure (CFI) Program by Kevin Miller
Forth
 
Kaizen SMT_MI_PCBA for Quality Engineerspptx
Kaizen SMT_MI_PCBA for Quality EngineerspptxKaizen SMT_MI_PCBA for Quality Engineerspptx
Kaizen SMT_MI_PCBA for Quality Engineerspptx
vaibhavsrivastava482521
 
Catalytic Converter theft prevention - NYC.pptx
Catalytic Converter theft prevention - NYC.pptxCatalytic Converter theft prevention - NYC.pptx
Catalytic Converter theft prevention - NYC.pptx
Blue Star Brothers
 
原版制作(澳洲WSU毕业证书)西悉尼大学毕业证文凭证书一模一样
原版制作(澳洲WSU毕业证书)西悉尼大学毕业证文凭证书一模一样原版制作(澳洲WSU毕业证书)西悉尼大学毕业证文凭证书一模一样
原版制作(澳洲WSU毕业证书)西悉尼大学毕业证文凭证书一模一样
g1inbfro
 
53286592-Global-Entrepreneurship-and-the-Successful-Growth-Strategies-of-Earl...
53286592-Global-Entrepreneurship-and-the-Successful-Growth-Strategies-of-Earl...53286592-Global-Entrepreneurship-and-the-Successful-Growth-Strategies-of-Earl...
53286592-Global-Entrepreneurship-and-the-Successful-Growth-Strategies-of-Earl...
MarynaYurchenko2
 
一比一原版(WashU文凭证书)圣路易斯华盛顿大学毕业证如何办理
一比一原版(WashU文凭证书)圣路易斯华盛顿大学毕业证如何办理一比一原版(WashU文凭证书)圣路易斯华盛顿大学毕业证如何办理
一比一原版(WashU文凭证书)圣路易斯华盛顿大学毕业证如何办理
afkxen
 
MODULE ONE PRPC19 Design of Machine Elements- 1 .pdf
MODULE  ONE PRPC19 Design of Machine Elements- 1 .pdfMODULE  ONE PRPC19 Design of Machine Elements- 1 .pdf
MODULE ONE PRPC19 Design of Machine Elements- 1 .pdf
ShanthiniSellamuthu
 
AadiShakti Projects ( Asp Cranes ) Raipur
AadiShakti Projects ( Asp Cranes ) RaipurAadiShakti Projects ( Asp Cranes ) Raipur
AadiShakti Projects ( Asp Cranes ) Raipur
AadiShakti Projects
 
Here's Why Every Semi-Truck Should Have ELDs
Here's Why Every Semi-Truck Should Have ELDsHere's Why Every Semi-Truck Should Have ELDs
Here's Why Every Semi-Truck Should Have ELDs
jennifermiller8137
 
Expanding Access to Affordable At-Home EV Charging by Vanessa Warheit
Expanding Access to Affordable At-Home EV Charging by Vanessa WarheitExpanding Access to Affordable At-Home EV Charging by Vanessa Warheit
Expanding Access to Affordable At-Home EV Charging by Vanessa Warheit
Forth
 
Charging Fueling & Infrastructure (CFI) Program Resources by Cat Plein
Charging Fueling & Infrastructure (CFI) Program Resources by Cat PleinCharging Fueling & Infrastructure (CFI) Program Resources by Cat Plein
Charging Fueling & Infrastructure (CFI) Program Resources by Cat Plein
Forth
 
EV Charging at MFH Properties by Whitaker Jamieson
EV Charging at MFH Properties by Whitaker JamiesonEV Charging at MFH Properties by Whitaker Jamieson
EV Charging at MFH Properties by Whitaker Jamieson
Forth
 
RACI Matrix Managed Services on Cloud 08-11-19_AS.pdf
RACI Matrix Managed Services on Cloud 08-11-19_AS.pdfRACI Matrix Managed Services on Cloud 08-11-19_AS.pdf
RACI Matrix Managed Services on Cloud 08-11-19_AS.pdf
xmasmen4u
 

Recently uploaded (20)

快速办理(napier毕业证书)英国龙比亚大学毕业证在读证明一模一样
快速办理(napier毕业证书)英国龙比亚大学毕业证在读证明一模一样快速办理(napier毕业证书)英国龙比亚大学毕业证在读证明一模一样
快速办理(napier毕业证书)英国龙比亚大学毕业证在读证明一模一样
 
一比一原版(Columbia文凭证书)哥伦比亚大学毕业证如何办理
一比一原版(Columbia文凭证书)哥伦比亚大学毕业证如何办理一比一原版(Columbia文凭证书)哥伦比亚大学毕业证如何办理
一比一原版(Columbia文凭证书)哥伦比亚大学毕业证如何办理
 
EN Artificial Intelligence by Slidesgo.pptx
EN Artificial Intelligence by Slidesgo.pptxEN Artificial Intelligence by Slidesgo.pptx
EN Artificial Intelligence by Slidesgo.pptx
 
原版制作(Exeter毕业证书)埃克塞特大学毕业证完成信一模一样
原版制作(Exeter毕业证书)埃克塞特大学毕业证完成信一模一样原版制作(Exeter毕业证书)埃克塞特大学毕业证完成信一模一样
原版制作(Exeter毕业证书)埃克塞特大学毕业证完成信一模一样
 
Hand Gesture Control Robotic Arm using image processing.pptx
Hand Gesture Control Robotic Arm using image processing.pptxHand Gesture Control Robotic Arm using image processing.pptx
Hand Gesture Control Robotic Arm using image processing.pptx
 
Charging and Fueling Infrastructure Grant: Round 2 by Brandt Hertenstein
Charging and Fueling Infrastructure Grant: Round 2 by Brandt HertensteinCharging and Fueling Infrastructure Grant: Round 2 by Brandt Hertenstein
Charging and Fueling Infrastructure Grant: Round 2 by Brandt Hertenstein
 
EV Charging at Multifamily Properties by Kevin Donnelly
EV Charging at Multifamily Properties by Kevin DonnellyEV Charging at Multifamily Properties by Kevin Donnelly
EV Charging at Multifamily Properties by Kevin Donnelly
 
Charging Fueling & Infrastructure (CFI) Program by Kevin Miller
Charging Fueling & Infrastructure (CFI) Program  by Kevin MillerCharging Fueling & Infrastructure (CFI) Program  by Kevin Miller
Charging Fueling & Infrastructure (CFI) Program by Kevin Miller
 
Kaizen SMT_MI_PCBA for Quality Engineerspptx
Kaizen SMT_MI_PCBA for Quality EngineerspptxKaizen SMT_MI_PCBA for Quality Engineerspptx
Kaizen SMT_MI_PCBA for Quality Engineerspptx
 
Catalytic Converter theft prevention - NYC.pptx
Catalytic Converter theft prevention - NYC.pptxCatalytic Converter theft prevention - NYC.pptx
Catalytic Converter theft prevention - NYC.pptx
 
原版制作(澳洲WSU毕业证书)西悉尼大学毕业证文凭证书一模一样
原版制作(澳洲WSU毕业证书)西悉尼大学毕业证文凭证书一模一样原版制作(澳洲WSU毕业证书)西悉尼大学毕业证文凭证书一模一样
原版制作(澳洲WSU毕业证书)西悉尼大学毕业证文凭证书一模一样
 
53286592-Global-Entrepreneurship-and-the-Successful-Growth-Strategies-of-Earl...
53286592-Global-Entrepreneurship-and-the-Successful-Growth-Strategies-of-Earl...53286592-Global-Entrepreneurship-and-the-Successful-Growth-Strategies-of-Earl...
53286592-Global-Entrepreneurship-and-the-Successful-Growth-Strategies-of-Earl...
 
一比一原版(WashU文凭证书)圣路易斯华盛顿大学毕业证如何办理
一比一原版(WashU文凭证书)圣路易斯华盛顿大学毕业证如何办理一比一原版(WashU文凭证书)圣路易斯华盛顿大学毕业证如何办理
一比一原版(WashU文凭证书)圣路易斯华盛顿大学毕业证如何办理
 
MODULE ONE PRPC19 Design of Machine Elements- 1 .pdf
MODULE  ONE PRPC19 Design of Machine Elements- 1 .pdfMODULE  ONE PRPC19 Design of Machine Elements- 1 .pdf
MODULE ONE PRPC19 Design of Machine Elements- 1 .pdf
 
AadiShakti Projects ( Asp Cranes ) Raipur
AadiShakti Projects ( Asp Cranes ) RaipurAadiShakti Projects ( Asp Cranes ) Raipur
AadiShakti Projects ( Asp Cranes ) Raipur
 
Here's Why Every Semi-Truck Should Have ELDs
Here's Why Every Semi-Truck Should Have ELDsHere's Why Every Semi-Truck Should Have ELDs
Here's Why Every Semi-Truck Should Have ELDs
 
Expanding Access to Affordable At-Home EV Charging by Vanessa Warheit
Expanding Access to Affordable At-Home EV Charging by Vanessa WarheitExpanding Access to Affordable At-Home EV Charging by Vanessa Warheit
Expanding Access to Affordable At-Home EV Charging by Vanessa Warheit
 
Charging Fueling & Infrastructure (CFI) Program Resources by Cat Plein
Charging Fueling & Infrastructure (CFI) Program Resources by Cat PleinCharging Fueling & Infrastructure (CFI) Program Resources by Cat Plein
Charging Fueling & Infrastructure (CFI) Program Resources by Cat Plein
 
EV Charging at MFH Properties by Whitaker Jamieson
EV Charging at MFH Properties by Whitaker JamiesonEV Charging at MFH Properties by Whitaker Jamieson
EV Charging at MFH Properties by Whitaker Jamieson
 
RACI Matrix Managed Services on Cloud 08-11-19_AS.pdf
RACI Matrix Managed Services on Cloud 08-11-19_AS.pdfRACI Matrix Managed Services on Cloud 08-11-19_AS.pdf
RACI Matrix Managed Services on Cloud 08-11-19_AS.pdf
 

Basic of Firmware & Embedded Software Programming in C

  • 2.
  • 3. Agenda • What is Generic Drivers • Digital Input and Output Ports • Keys • Key Matrix • LEDs • LED Matrix • PWM Outputs • Displays • Seven Segments Displays • Alphanumeric LCDs • EEPROM Interface • RS232 vs RS485
  • 4. Key Input • We can use the microcontroller, GPIO to detect the key input signal. We need to configured the microcontroller pin/port as input port. Here in above example microcontroller pin (port 7 bit 0) P70 is used to capture the input. Consider when switch is not pressed (OFF), the value at microcontroller pin will be HIGH (1) and when switch is pressed (ON), the value at microcontroller will be LOW (0). The program should be written to monitor the status of pin 0 (Port 7) to detect the switch position (OFF/ON)
  • 5. Key Debouncing Delay • Generally bouncing and debouncing delay is required to avoid wrong key detection in case of momentary spike because of noise. • This delay can be of 5ms to 10ms, which can be implemented using timers.
  • 6. 4x4 Matrix Keypad • To increase the number of key connection, keys can be connected in matrix. We will be able to connect 16 keys using 4x4 matrix on one microcontroller port (8 pins). Let's consider we port 0 for key connection. First 4 pins from left (X1, X2, X3, X4) are considered as row and rest 4 (Y1, Y2, Y3, Y4) are columns. • We need to make rows pins (X1, X2, X3, X4) as output pins and columns pins as input pints (Y1, Y2, Y3, Y4). To make the pins as output, we load the value LOW (0) to the pins. To configure pins as input we make the pin HIGH(1). For example, if key 1 is pressed then Y1 should goes LOW (0), as X1 is low. X1 value is transferred to Y1. Similarly, it will be applied for the rest of the keys as well.
  • 7. 4x4 Matrix Keypad • To configure X1, X2, X3, X4 as output, we configured pins as LOW (0). • To detect the switch position (pressed/released), We need to make the Y1, Y2, Y3 and Y4 as high or 1. • Otherwise, we will not be able to detect the changes, of switch position (pressed/released) • PORTX = 0xF0;
  • 8. 4x4 Matrix Keypad • Key2 Pressed: As key2 comes in X1 line make the X1 as LOW (0) • X1 = 0; X2 = 1; X2 = 1; X4 = 1; • Now if Y2 == 0 then considered that key2 is being pressed. • Here _delay_ms(100) is deboucing delay to confirm the key pressed. • X1 is for key1, key2, key3, key4 (scan from Y1, Y2, Y3, Y4 to detect key pressed) • X2 is for key5, key6, key7, key8(scan from Y1, Y2, Y3, Y4 to detect key pressed) • X3 is for key9, key10, key11, key12(scan from Y1, Y2, Y3, Y4 to detect key pressed) • X4 is for key13, key14, key15, key16(scan from Y1, Y2, Y3, Y4 to detect key pressed)
  • 9. PWM Output PWM : Pulse Width Modulation PWM is based on duty cycle variation which will control the on & off time. It is being used for multiple application. Duty cycle = ON Time / Total Time Example: Total Time : 100ms ON Time : 23ms Duty Cycle : 23% Duty cycle can be controlled based on timer implementation to make the pin HIGH (1) and LOW (0). In most cases based on the certain Input signal values, duty cycle will be decided.
  • 10. LED Matrix Depending on Interfacing type, HIGH or LOW will be sent on the port pin to make the LED Glow. /* To blink */ P0_0 = 1; /* Turn ON */ Delay_ms(100); P0_0 = 0; /* Turn OFF */ Delay_ms(100);
  • 11. LED Matrix • Just like key Matrix we have LED matrix to increase the number of connected LEDs. The similary apporoach is being used here for LED Matrix as well. • To turn the specific LED ON, We need to set the corresponding row pin to HIGH (1) and the column pin to LOW (0)
  • 12. LED Matrix • const char raw[3] = {3,4,5}; • const char col[3] = {8,9,10}; • for (num =0; num<3; num++) • { • pinMode(raw[num]) = OUTPUT; • pinMode(col[num]) = OUTPUT; • digitalWrite(col[num]) = HIGH; • }
  • 13. LED Matrix • void led_ON(int row, int col) { digitalWrite(pins_rows[row], HIGH); digitalWrite(pins_cols[col], LOW); } void led_OFF(int row, int col) { digitalWrite(pins_rows[row], LOW); digitalWrite(pins_cols[col], LOW); }
  • 14. ADC (Analog to Digital Convertors) We always use analog to digital convertor to measure the different parameters like temperature, sound, pressure, light, voltage, current etc. We will be able to store the recorded values in controller or in memory as needed. We need sensor which will gives us the analog values corrosponding to the parameter which we are going to measure. The output of sensor may be linear or nonlinear depending on the type of sensor. In case of linear output, it will be easy to implement, process & map the values. However, in case of nonlinear we may need to use table which will be generally given in datasheet.
  • 15. ADC (Analog to Digital Convertors) • Analog to Digital Converter, commonly known as (ADC) is an electronic integrated circuit which is used to convert the analog signals to digital form consisting of 1s/0s.Most of the ADCs take a voltage input as 0 to 5V, etc. correspondingly ADC will produce digital output depending on the resolution of the ADC. ADC can be based on I2C or SPI protocol, which is now commonly used across different industries. • Serial ADC (SPI or I2C based ADC) • Parallel ADC
  • 16. ADC (Analog to Digital Convertors)
  • 18. Example: Resolution How to calculate voltage corrosponding to 1 ADC Count 10 bits ADC : 2^10 States : 1024 Values (5V) • 0V = 0 ADC Count • 5V = 1024 ADC Count 5000 mv/4095 = 1.23 mv minimum change is required to move 1 ADC count 12 bits ADC : 2^12 States : 4096 Values (5V) • 0V = 0 ADC Count • 5V = 4095 ADC Count 5000 mv/1024 = 4.9 mv minimum change is required to move 1 ADC count
  • 23. Alphanumeric LCDs (16x2) • The 16x2 Alphanumeric LCD means, I can show up-to 2 lines of 16 characters. Each LCD character contains the 5x8 pixel grid. The most LCD will have two registers. • Command Register (Required to send the different commands/instruction/operations) • Data Register (Required to send data to display on LCD) • The LCD have the different required commands to provide the display functionality. Examples: • Clear Display, shift display right, shift display left, force cursor position at beginning of line1/line2 • Shift entire display right, Shift entire display left
  • 24. Alphanumeric LCDs (16x2) • Address range of each lines: • Line 1: 0x80 • Line 2: 0xC0 • The value of data register will be displayed on LCD. To display the value on LCD, we need to load the ASCII value of characters in data register.
  • 25. Alphanumeric LCDs (16x2) • Data Bus: • Data bus contains the data lines from D0-D7. In 8-bit data bus mode, we can send the data/command to LCD in bytes. Most LCD supports 4-bit mode where we can send the data/command in chunks of 4-bit, which is used when we have limited available GPIO lines on the microcontroller. Register Select(RS): As we know LCD has two register namely • Data register : To display data on the LCD, we should write to the data register. • To select between the command or the data register, the RS signal is used. If we make the RS pin HIGH & feed input to the data lines (DB0 to DB7), this input will be interpreted as the data that is to be displayed on the LCD screen. • If the RS signal is HIGH, then the LCD interprets the 8-bit info (DB0 to DB7) as data and copies it to data register. After that the LCD decodes the data for generating the 5x7 pattern and finally displays on the LCD. • Command register : To send the different command to LCD, we should write to command register. • If we make the RS pin LOW and feed input to the data lines (DB0 to DB7), then this will be interpreted as a command. • If the RS signal is LOW, then the LCD interprets the 8-bit info (DB0 to DB7) as Command and writes it Command register and performs the action as per the command.
  • 26. Alphanumeric LCDs (16x2) R/W (bar): Read / Write (bar) • It is used switch between read & write operation mode. • R/W (bar) = LOW (0), Indicates Write Mode • R/W (bar) = HIGH (1), Indicates Read Mode • This signal is used to write the data/command to LCD & reads the busy flag of LCD. For write operation the RW should be LOW and for read operation the R/W should be HIGH. EN: Enable • The Enable signal is used to latch the data (that is to place the data on the data bus from D0 – D7 and wait for a clock or pulse to send it), and when high to low pulse is sent into the E pin of LCD the data is displayed on the LCD. • A HIGH-to-LOW pulse is required be sent on enable pin, which will latch the info into the LCD register. This will trigger the LCD to act accordingly.
  • 31. Alphanumeric LCDs Sequence: • Send the command on data lines (DB0 to DB7) • Select the command register using RS (RS = LOW) • Select the write operation using R/W (bar), (RW = LOW) • Send High to Low pulse on Enabler (EN) pin with delay
  • 32. Alphanumeric LCDs Sequence: • Send the ASCII data (Characters) required to displayed on-data lines (DB0 to DB7) • Select the data register using RS (RS = HIGH) • Select the write operation using R/W (bar), (RW = LOW) • Send High to Low pulse on Enabler (EN) pin with delay
  • 37. Seven Segment Displays Digit gfedcba abcdefg a b c d e f g 0 0×3F 0×7E on on on on on on off 1 0×06 0×30 off on on off off off off 2 0×5B 0×6D on on off on on off on 3 0×4F 0×79 on on on on off off on 4 0×66 0×33 off on on off off on on 5 0×6D 0×5B on off on on off on on 6 0×7D 0×5F on off on on on on on 7 0×07 0×70 on on on off off off off 8 0×7F 0×7F on on on on on on on 9 0×6F 0×7B on on on on off on on A 0×77 0×77 on on on off on on on B 0×7C 0×1F off off on on on on on C 0×39 0×4E on off off on on on off D 0×5E 0×3D off on on on on off on E 0×79 0×4F on off off on on on on F 0×71 0×47 on off off off on on on
  • 40. Interfacing Memory • START CONDITION: A high-to-low transition of SDA with SCL high is a start condition which must precede any other command (refer to Start and Stop Definition timing diagram). • STOP CONDITION: A low-to-high transition of SDA with SCL high is a stop condition. After a read sequence, the stop command will place the EEPROM in a standby power mode (refer to Start and Stop Definition timing diagram)
  • 46. RS232 Vs RS485 Description RS-232 RS-485 Transfer type Full duplex Half duplex (2 wires), full duplex (4 wires) Maximum distance 15 meters at 9600 bps 1200 meters at 9600 bps Contacts in use TxD, RxD, RTS, CTS, DTR, DSR, DCD, GND* DataA, DataB, GND Topology Point-to-Point Multi-point Max. Number of connected devices 1 32 (with repeaters larger, usually up to 256) Voltage Range 3V to 25V (Logic 0) -3V to -25V (Logic 1) 200mV (Logic 0) -200mV (Logic 1)