ET3491 Final - Merged Full Manual
ET3491 Final - Merged Full Manual
Name
Reg. No..
Sem./Branch..
Sub. Code/Subject...
Lecturer - in - charge
Head of the Department
Date
2
EXAMINERS
CONTENTS
Exercise No. Date Name of the Exercise Page No. Remarks
CONTENTS
Exercise No. Date Name of the Exercise Page No. Remarks
LAB MANUAL
EMBEDDED SYSTEMS AND IoT
VI SEMESTER- III YEAR- ECE
REGULATION: 2021
SUBJECT CODE: ET3491
ANNA UNIVERSITY CHENNAI
List of Experiments
AIM
APPARATUS REQUIRED
8051 kit
FLOWCHART
ADDITION/ SUBTRACTION
MULTIPLICATION / DIVISION
8 bit Addition
8 bit subtraction
8 bit
Multiplication
8 bit Division
16 bit Addition
16 bit subtraction
Logical AND
Logical OR
Logical EX-OR
LABEL ADDRESS OPCODE MNEMONICS COMMENTS
Experiment No: 02
Date:
Generation of Square waveform using 8051
.
AIM
APPARATUS REQUIRED
Algorithm:
3. Move the value 0FFH to Port 1 and then call the delay.
ACALL DELAY
ACALL DELAY
SJMP AGAIN
RET
END
RESULT:
OUTPUT
Experiment No: 03
Date:
Programming using On – Chip ports in 8051
AIM
APPARATUS REQUIRED
8051 kit
Algorithm:
1. Move the value 081H to the Interrupt Enable pin to enable it.
ORG 0000h
JB TCON.1, LOOP1
LOOP2: RETI
l3 : SJMP l3
END
OUTPUT
RESULT
Experiment No: 04
Date:
Programming using Serial Ports in 8051
AIM
APPARATUS REQUIRED
ALGORITHM:
4. Based on the bit value on SCON store the data in SBUF and move the data to register ‘A’.
5. Based on the bit value on SCON store the data in register ‘A’ and is moved to SBUF register.
MOV TMOD,#20H
MOV SCON,#50H
SETB TCON.6
MOV A, SBUF
CLR RI
MOV SBUF,A
CLR TI
CJNE A, #'$',REPEAT
END
OUTPUT
RESULT:
INSTRUCTION TO DO EMBEDDED LAB
3. Altera's Cyclone V
7. Flash Magic
8. Win X-Talk
9. PC/Laptop
Instruction:
Follow the given steps for getting started with the syllabus experiments:
1. Install IAR Embedded Workbench IDE software and Win X-Talk software
2. After successful installation of IAR and Win X- Talk, Install Flash Loader
Demonstrator.
3. Connect the RS232 cable/USB cable provided to the PC and the STM32 Syllabus
Board, and Power on the Development Board.
4. If you are using USB cable, then install the required USB to Serial driver (FTDI
for on beard converter).
5. Search/Set the COM Port no here:
Start >> My Computer >> Manage (on right click) >> Device Manager >> Ports
(COM & LPT)
6. Now, Identify the Mode-Select-Switch(SW9) provided on the Vi-STM32 Board
marked with the text +3.3V & GND
a. +3.3V: Programming Mode used for downloading the code/program into the flash
memory.
b. GND: Execution Mode used for executing program after downloading.
7. After selecting any position (+3.3V / GND) press the reset switch provided on the board.
8. After setting the proper COM port number & selecting the Mode-Select-Switch
position properly, Extract the “Vi – STM32 SB SOURCE CODES V 1.0” (Win RAR
archive) file.
9. Open the project and follow the instructions given in each experiment.
ABOUT VI-STM32 SB DEVELOPMENT BOARD
The Vi – STM32 syllabus board is a demonstration and development platform for the
STM32F4 series and includes an embedded STM32F407ZT6 high-performance ARM Cortex-
M4 32-bit microcontroller. The full range of hardware features on the board is provided to help
you evaluate all peripherals (Ethernet, motor control, CAN, USART etc.) and develop your own
applications. Extension headers make it possible to easily connect a daughterboard or wrapping
board for your specific application.
STM32F407ZG Features:
• Core: ARM 32-bit Cortex™-M4 CPU with FPU, Adaptive real-time accelerator (ART
Accelerator™) allowing 0-wait state execution from Flash memory, frequency up to 168
MHz, memory protection unit, 210 DMIPS/ 1.25 DMIPS/MHz (Dhrystone 2.1), and DSP
Instructions
• Memories
– Up to 1 Mbyte of Flash memory
– Up to 192+4 Kbytes of SRAM including 64-Kbyte of CCM (core coupled memory)
data RAM
– Flexible static memory controller supporting Compact Flash, SRAM, PSRAM,
NOR and NAND memories
• LCD parallel interface, 8080/6800 modes
• Clock, reset and supply management
– 1.8 V to 3.6 V application supply and I/Os
– POR, PDR, PVD and BOR
– 4-to-26 MHz crystal oscillator
– Internal 16 MHz factory-trimmed RC (1% accuracy)
– 32 kHz oscillator for RTC with calibration
– Internal 32 kHz RC with calibration
• Low power
– Sleep, Stop and Standby modes
– VBAT supply for RTC, 20×32 bit backup registers + optional 4 KB backup SRAM
• 3×12-bit, 2.4 MSPS A/D converters: up to 24 channels and 7.2 MSPS in triple interleaved
mode
• 2×12-bit D/A converters
• General-purpose DMA: 16-stream DMA controller with FIFOs and burst support
• Up to 17 timers: up to twelve 16-bit and two 32-bit timers up to 168 MHz, each with up to
4 IC/OC/PWM or pulse counter and quadrature (incremental) encoder input
• Debug mode
– Serial wire debug (SWD) & JTAG interfaces
– Cortex-M4 Embedded Trace Macrocell™
• Up to 140 I/O ports with interrupt capability
– Up to 136 fast I/Os up to 84 MHz
– Up to 138 5 V-tolerant I/Os
• Up to 15 communication interfaces
– Up to 3 × I2C interfaces (SMBus/PMBus)
– Up to 4 USARTs/2 UARTs (10.5 Mbit/s, ISO 7816 interface, LIN, IrDA, modem
control)
– Up to 3 SPIs (42 Mbits/s), 2 with muxed full-duplex I2S to achieve audio
class accuracy via internal audio PLL or external clock
– SDIO interface
• Advanced connectivity
– USB 2.0 full-speed device/host/OTG controller with on-chip PHY
– USB 2.0 high-speed/full-speed device/host/OTG controller with dedicated DMA, on-
chip full-speed PHY and ULPI
– 10/100 Ethernet MAC with dedicated DMA: supports IEEE 1588v2 hardware,
MII/RMII
• 8- to 14-bit parallel camera interface up to 54 Mbytes/s
• True random number generator
• CRC calculation unit
• 96-bit unique ID
• RTC: sub second accuracy, hardware calendar
Experiment : 6 (a)
Date :
INTERFACING ADC
Aim
To develop an embedded C program for reading an on-chip ADC, convert into decimal
and to display it in PC. The ADC input is connected to any analog sensor/ on board
potentiometer
Apparatus & Software Required
1. Vi – STM32 development board
2. IAR workbench
3. Flash Loader Demonstrator
4. USB cable
Theory
STM32F407ZG –cortex M4 controller has three 12-bit ADC channels. In vi-stm32
syllabus board includes two potentiometers for the analog voltage variations. The potentiometer
POT1 is connected to ADC3_IN8 (i.e.) PF10 of the controller. The potentiometer POT2 is
connected to ADC3_IN7 (i.e.) PF9 of the controller. The ADC varying between 0 to 4095.the
ADC outputs are displayed through the serial communication (P10 or P3 connector).
Procedure:
Result:
Experiment : 6(b)
Date :
INTERFACING DAC
Aim
To develop an embedded C program for converting given digital value into analog
Apparatus & Software Required
1. Vi – STM32 development board
2. IAR workbench
3. Flash Loader Demonstrator
4. CRO
5. USB cable
Theory
Digital to Analog Converters (DAC) is a device for converting a digital (usually binary)to
an analog signal (current, voltage or electric charge).STM32F407ZG controller has two 12-bit
D/A converters.DAC output pins are PA4 and PA5.for DAC channel one output is produced in
PA4 and DAC channel two output is produced in PA5.PA4 pin is available in 31st pin of P9
connector.PA5 is available in 28th pin of P9 connector.
Procedure
1. Create a new project.
2. Type the code and save the file with extension .C in the project.
3. Add the necessary files to the project.
4. Create the output file in the format .hex for downloading the code into the processor.
5. Build the project and compile it.
6. Download the hex file into the processor with the help of flash loader.
7. After downloading the program change the board to execution mode and reset it.
8. For DAC, the digital value given in the program is converted and the corresponding analog
signal is viewed with the help of CRO.
9. Make use of a CRO or DSO to view the DAC output by connecting the positive terminal to
PA5 pin of P9 connector (28th pin) and the negative terminal to GND.
Program:
DAC.C
Triangular wave
#include generation
"stm32f4xx.h"
#include
"stdio.h" int
main()
{
RCC->APB1ENR|=0x20000000; // DAC CLOCK
ENABLE DAC->CR|=0x00000000; // DAC
CHANNEL 1 ENABLE GPIOA-
>MODER|=0x00000300; //PA4 ANALOG MODE int i
= 0;
while(1)
{
for(i=0; i<4096;
i++) DAC-
>DHR12R1=i;
for(i=4096; i>=0 ; i-
-) DAC-
>DHR12R1=i;
};
}
SINE WAVE GENERATION
#include
"stm32f4xx.h"
#include
"stdio.h" int
main()
{
RCC->APB1ENR|=0x20000000; // DAC CLOCK
ENABLE DAC->CR|=0x00000000; // DAC
CHANNEL 1 ENABLE GPIOA-
>MODER|=0x00000300; //PA4 ANALOG MODE int i
= 0;
int
x[]={2048,2177,2305,2432,2557,2681,2802,2920,3035,3145,3252,3353,3450,3541,3626,3705,
3777,3843,3901,3952,3996,4032,4060,4080,4092,4096,4092,4080,4060,4032,3996,3952,3901,38
43,3777
,
3705,3626,3541,3450,3353,3252,3145,3035,2920,2802,2681,2557,2432,2305,2177,2048,1919,17
91,1664
,
1539,1415,1294,1176,1061,951,844,743,646,555,470,391,319,253,195,144,100,64,36,16,4,0,4,16,
36,64,
100,144,195,253,319,391,470,555,646,743,844,951,1061,1176,1294,1415,1539,1664,1791,1919,2
048};
while(1)
{
for(i=0; i<100 ; i++)
DAC->DHR12R1=x[i];
};
}
Square wave generation
#include
"stm32f4xx.h"
#include
"stdio.h" int
main()
{
RCC->APB1ENR|=0x20000000; // DAC CLOCK
ENABLE DAC->CR|=0x00000000; // DAC
CHANNEL 1 ENABLE GPIOA-
>MODER|=0x00000300; //PA4 ANALOG MODE int i
= 0;
while(1)
{
for(i=0; i<4096;
i++); DAC-
>DHR12R1=i;
for(i=4096; i>=0 ; i--
); DAC-
>DHR12R1=i;
};
}
Result:
Experiment : 7(a)
Date :
FLASHING OF LEDS
Aim
To develop an embedded ‘C’ program for flashing the LED with various time delay.
#include "stm32f4xx.h"
#include "stdio.h" void
delay(long int a)
{
long int b,c;
for (b=0 ; b<a; b++)
for (c=0 ; c<a; c++);
}
void LED_init()
{
RCC->AHB1ENR = 1<<5;
GPIOF->MODER = 0x55555555;
GPIOF->OTYPER = 0x00000000;
GPIOF->OSPEEDR = 0xAAAAAAAA;
GPIOF->PUPDR = 0x00000000;
}
void main()
{
LED_init();
while(1)
{
GPIOF->ODR = 0x0000000F;
delay(3000);
GPIOF->ODR = 0x00000000;
delay(3000);
}
}
Result:
Experiment : 7(b)
Date :
INTERFACING LCD
Aim
To develop a embedded C-Language program for displaying the Key pressed in the Keypad
in the LCD module. The display should come in the desired line and column.
Theory:
LCD
Liquid crystals are a phase of matter whose order is intermediate between that of a liquid and
that of a crystal. The molecules are typically rod-shaped organic matters about 25 Angstroms in
length and their ordering is a function of temperature. The molecular orientation can be
controlled with applied electric fields.
The Character LCD communicates with the microcontroller via 8 bit data bus. The pin
description for character LCD is given below.
VCC, GND AND V0 - While VCC and VSS provide +5V and ground, respectively; V0 is used
for controlling LCD contrast
RS (Register Select) - If RS = 0, the instruction command code register is selected, allowing the
user to send a command such as clear display, cursor at home, etc.
If RS = 1, the data register is selected, allowing the user to send data to be displayed on the LCD.
RW (Read/Write) - RW allows the user to write information to the LCD or read information
from it. RW=1 when reading; RW=0 when writing.
EN (Enable) - The LCD to latch information presented to its data pins uses the enable pin. When
data is supplied to data pins, a high to low pulse must be applied to this pin in order for the LCD
to latch in the data present at the data pins.
D0 – D7 - The 8-bit data pins, are used to send information to the LCD or read the contents of
the LCD’s internal registers. To display letters and numbers, we send ASCII codes for the letters
A-Z, a-z, and numbers 0-9 to these pins while making RS = 1.
LCD CONNECTION
Procedure:
Program:
#include "stm32f4xx.h"
void delay() {
int i,j;
for(i=0;i<0xff;i++)
for(j=0;j<0xff;j++);
}
void busy_check() {
delay();
GPIOB->BSRRH = 0x0020;
}
void command_write(int comm) {
busy_check();
GPIOG->ODR = comm << 8;
GPIOC->BSRRL = 0x0040;
delay();
GPIOC->BSRRH = 0x0040;
}
void lcd_init() {
command_write(0x38);
command_write(0x01);
command_write(0x0f);
command_write(0xC0);
command_write(0x06);
}
void lcd_out(unsigned char a) {
busy_check();
GPIOB->BSRRL = 0x0020;
GPIOG->ODR = a << 8;
GPIOC->BSRRL = 0x0040;
delay();
GPIOC->BSRRH = 0x0040;
}
void pin_config(void){
// Enable the clock for PB,PC,PF,PG ports
RCC->AHB1ENR |= ( 1 << 1 ) | ( 1 << 2 ) | ( 1 << 5 ) | ( 1 << 6 );
GPIO_Config( GPIOB,0x00000400) ;
GPIO_Config( GPIOC,0x00001000) ;
GPIO_Config( GPIOG,0x55550000) ;
int main(void){
pin_config();
lcd_init();
lcd_write(0x80,a);
delay();
lcd_write(0xc0,b);
Result:
Experiment : 8(a)
Date :
INTERFACING KEYBOARD
Aim
To develop a embedded C-Language program for displaying the Key pressed in the
Keypad in the LCD module. The display should come in the desired line and column.
Theory:
Keypad
The Matrix keyboard is used to minimize the number of I/O lines. Normally it is possible
to connect only one key or switch with an I/O line. If the number of keys in the system exceeds
the more I/O lines are required. To reduce the number of I/O lines the keys are connected in the
matrix circuit. Keyboards use a matrix with the rows and columns made up of wires. Each key
acts like a switch. When a key is pressed a column wire makes contact with row wire and
completes a circuit.
KEYBOARD CONNECTION
LCD
Liquid crystals are a phase of matter whose order is intermediate between that of a liquid and
that of a crystal. The molecules are typically rod-shaped organic matters about 25 Angstroms in
length and their ordering is a function of temperature. The molecular orientation can be
controlled with applied electric fields.
The Character LCD communicates with the microcontroller via 8 bit data bus. The pin
description for character LCD is given below.
VCC, GND AND V0 - While VCC and VSS provide +5V and ground, respectively; V0 is used
for controlling LCD contrast
RS (Register Select) - If RS = 0, the instruction command code register is selected, allowing the
user to send a command such as clear display, cursor at home, etc.
If RS = 1, the data register is selected, allowing the user to send data to be displayed on the LCD.
RW (Read/Write) - RW allows the user to write information to the LCD or read information
from it. RW=1 when reading; RW=0 when writing.
EN (Enable) - The LCD to latch information presented to its data pins uses the enable pin. When
data is supplied to data pins, a high to low pulse must be applied to this pin in order for the LCD
to latch in the data present at the data pins.
D0 – D7 - The 8-bit data pins, are used to send information to the LCD or read the contents of
the LCD’s internal registers. To display letters and numbers, we send ASCII codes for the letters
A-Z, a-z, and numbers 0-9 to these pins while making RS = 1
LCD CONNECTION
Procedure:
Program:
#include "stm32f4xx.h"
void delay() {
int i,j;
for(i=0;i<0xff;i++)
for(j=0;j<0xff;j++);
}
void busy_check() {
delay();
GPIOB->BSRRH = 0x0020;
}
void command_write(int comm) {
busy_check();
GPIOG->ODR = comm << 8;
GPIOC->BSRRL = 0x0040;
delay();
GPIOC->BSRRH = 0x0040;
}
void lcd_init() {
command_write(0x38);
command_write(0x01);
command_write(0x0f);
command_write(0xC0);
command_write(0x06);
}
void lcd_out(unsigned char a) {
busy_check();
GPIOB->BSRRL = 0x0020;
GPIOG->ODR = a << 8;
GPIOC->BSRRL = 0x0040;
delay();
GPIOC->BSRRH = 0x0040;
}
void pin_config(void){
// Enable the clock for PB,PC,PF,PG ports
RCC->AHB1ENR |= ( 1 << 1 ) | ( 1 << 2 ) | ( 1 << 5 ) | ( 1 << 6 );
GPIO_Config( GPIOB,0x00000400) ;
GPIO_Config( GPIOC,0x00001000) ;
GPIO_Config( GPIOF,0x00000500) ;
GPIO_Config( GPIOG,0x55550000) ;
int main(void){
pin_config();
lcd_init();
lcd_write(0x80,a);
delay();
lcd_write(0xc0,b);
while(1){
if(val == 0x40){
command_write(0x01);
lcd_write(0x80,sw5);
}
else if(val == 0x80){
command_write(0x01);
lcd_write(0x80,sw2);
}
if(val == 0x40){
command_write(0x01);
lcd_write(0x80,sw6);
}
else if(val == 0x80){
command_write(0x01);
lcd_write(0x80,sw3);
}
}
}
Experiment : 8(b)
Date :
INTERFACING STEPPER MOTOR
Aim:
To write C Programs for running stepper motor either in clock-wise or counter-clockwise
direction.
Theory:
The four input pins are PF13, PF14, PF15 and PD11.the ULN2003 driver IC supplies 5v
output to stepper motor. If the input pulse sequence is 1001,0101,0110,1010 means
stepper motor rotates in forward direction. If the input pulse sequence is
1010,0110,0101,1001 means stepper motor rotates in forward direction
Procedure:
Program:
STEPPER.C
#include "stm32f4xx.H"
#include "stdio.h"
void delay(long int a)
{
long int b,c;
for (b=0; b<a; b++)
{
for (c=0; c<a; c++)
{
{}
}
}
}
void stepper_init()
{
RCC->AHB1ENR|=1<<5; //ENABLE PORT F
GPIOF->MODER = 0x55555555; //PORTF AS OUTPUT MODE
GPIOF->OTYPER = 0x00000000; // PUSH PULL TYPE - PORT F
GPIOF->OSPEEDR = 0xAAAAAAAA; // PORT F 50 MHz SPEED
GPIOF->PUPDR =0x00000000; // PORT F NO PULL NO PUSH
RCC->AHB1ENR|=1<<3; //ENABLE PORT D
GPIOD->MODER = 0x55555555; // PORT D OUTPUT MODE
GPIOD->OTYPER = 0x00000000; // PUSH PULL TYPE - PORT D
GPIOD->OSPEEDR = 0xAAAAAAAA; // PORT D 50 MHz SPEED
GPIOD->PUPDR =0x00000000; // PORT D NO PULL NO PUSH
}
void main()
{
stepper_init();
while(1)
{
GPIOF->ODR = 0x00002000; // SETTING PF13
GPIOD->ODR = 0x00000800; // SETTING PD11
delay (3000);
GPIOF->ODR = 0x00004000; // SETTING PF14
GPIOD->ODR = 0x00000800; // SETTING PD11
delay (3000);
GPIOF->ODR = 0x0000C000; // SETTING PF14 AND PF15
GPIOD->ODR = 0x00000000; // SETTING -PORT D AS 0
delay (3000);
GPIOF->ODR = 0x0000A000; // SETTING PF13 AND PF15
GPIOD->ODR = 0x00000000; // SETTING -PORT D AS 0
delay (3000);
}
}
Result:
Experiment No:9 (a)
Date:
Interfacing sensors with Raspberry PI
AIM
APPARATUS REQUIRED
Raspberry Pi-4
Micropython- Thonny
DHT11 sensor
PROCEDURE
1. Make the connections as per the instructions.
2. Connect the Raspberry Pi board to a monitor.
CONNECTION :
OUTPUT
RESULT
Experiment No:9 (b)
Date:
Interfacing sensors with Raspberry PI
AIM
APPARATUS REQUIRED
Raspberry Pi-4
Micropython- Thonny
LDR sensor
PROCEDURE
CONNECTION
OUTPUT
RESULT
Experiment No:10
Date:
Interfacing Pi camera with Raspberry PI
AIM
APPARATUS REQUIRED
Raspberry Pi-4
Micropython- Thonny
Pi camera
PROCEDURE
camera = PiCamera()
camera.resolution = (1280, 720)
camera.vflip = True
camera.contrast = 10
camera.image_effect = "watercolor"
time.sleep(2)
camera.capture("/home/pi/Pictures/img.jpg")
print("Done.")
CONNECTION:
OUTPUT:
RESULT: