Lab Manual
Lab Manual
HOD/ ECE
EX.NO 1. Design with 8 bit Microcontrollers 8051/PIC Microcontrollers
I) I/O Programming, Timers, Interrupts, Serial port programming
ii) PWM Generation,
Motor Control, ADC/DAC, LCD and RTC Interfacing, Sensor Interfacing
iii) Both Assembly and C programming
AIM:
To design with 8 bit microcontrollers 8051/PIC microcontrollers
i) I/O Programming, Timers, Interrupts, Serial port programming ii) PWM Generation,
Motor Control, ADC/DAC, LCD and RTC Interfacing, Sensor Interfacing iii) Both Assembly
and C programming
Components:
8051 Microcontroller (AT89S52)
ADC0808/0809
16x2 LCD
Resistor (1k,10k)
POT(10k x4)
Capacitor(10uf,1000uf)
Red led
Bread board or PCB
7805
11.0592 MHz Crystal
Power
Connecting wires
1. I/O PROGRAMMING
PIN DIAGRAM
Pin Configuration Details
A brief explanation of all pins is given below
Vcc : It provides supply voltage to chip. The operating voltage is 5 volt.
GND : It connect with ground of voltage supply
XTAL1 and XTAL2 pin: Although 8051 have on chip crystal
oscillator. But still it requires an external clock oscillator.
External crystal oscillator is connected to XTAL1 and XTAL2
pins. It also requires two capacitors of 30pF as shown in figure
below. Capacitors one terminal is connected with crystal
oscillator and other terminal with ground. Processing speed of
8051 microcontroller depends on crystal oscillator frequency.
But each microcontroller have maximum limit of operating
frequency. We cannot connect crystal oscillator more than
maximum operating limit frequency.
EA Pin number 33 is used to store program. All family of 8051
microcontrollers comes with on chip ROM to store programs.
For such purpose EA pin is connected with Vcc. EA stands for
external access.
PSEN Pin number 29 is an output pin. It is stands for
“Program store enable”. It is also used for programming.
Input/output ports P0, P1, P2 and P3 use to interface 8051
microcontroller with external devices. I have already explained it
above.
8051 TIMERS:
// Use of Timer mode 1 for blinking LED using polling method
// XTAL frequency
11.0592MHz
#include<reg51.h>
sbit led = P1^0; // LED connected to 1st pin
o
f port P1
void delay();
main()
{
unsigned int
i; while(1)
{
led=~led; // Toggle LED
for(i=0;i<1000;i++)
delay(); // Call delay
}
}
Example code
main()
{
TMOD = 0x01; // Mode1 of Timer0
TH0=0x00; // Initial values loaded to
imer T
TL0=0x00;
IE = // Enable interrupt
0x82;
while(1); // Do nothing
}
TIMER BLOCK DIAGRAM:
Timer Registers
TMOD
Timer1 Timer 0
7 6 5 4 3 2 1 0
INTRUPPTS METHOD:
Interrupt Method
#include<reg51.h>
sbit LED = P0^0;
void main()
{
TMOD = 0x01; //Timer0 mode 1
TH0 = 0X4B; //Load the timer value
TL0 = 0XFD;
TR0 = 1; //turn ON Timer zero
ET0 = 1; //Enable TImer0 Interrupt
EA = 1; //Enable Global Interrupt bit
while(1)
{
// Do nothing
}
}
Write a program that continuously gets 8-bit data from PO and sends it to PI
while simultaneously creating a square wave of 200 (as period on pin P2.1.
Use Timer 0 to create the square wave. Assume that XTAL =11.0592 MHz.
Solution:
SERIAL PORT PROGRAMMING:
If you do not want to do complicated programming using serial communications registers, you
can simply use Mikro c compiler which has built in libraries for the UART communication. Now
I will explain about UART programming through mikro c and after that I will provide an
example of UART in keil compiler. We can use built-in UART library for handling 8051
serial communication, there are several functions. In this library.
UART_init() is used for initialization of 8051 UART module
UART_init() is used for initialization of 8051 UART module
UART_data_read() function checks if some data received on serial Port
UART_data_read() function checks if some data received on serial Port,
UART_read() reads one byte from serial port
whereas UART_Read_Text() can read multiple bytes
UART_Write() writes one byte to serial port. UART_Write() writes one byte to
serial port
while UART_Write_Text() can write multiple bytes.
UART_Set_Active() function is only used in micro-controllers that support more than
one UART ports.
sbit LCD_RS at P2_0_bit;
void main() {
char txt[6];
P0=0xFF;
P1=0xFF;
uart1_init(9600);
PCON.SMOD=0;
Lcd_init();
lcd_cmd(_LCD_CURSOR_OFF);
lcd_out(1,1,"****************");
uart1_write_text("Uart OK");
while(1){
sum=P0+P1;
wordToStr(sum,txt);
lcd_out(2,1,"P0+P1=");
lcd_out(2,7,txt);
uart1_write_text("P0+P1=");
uart1_write_text(txt);
uart1_write_text("\r\n");
delay_ms(500);
In above we are transmitting data through UART port and also displaying same data on LCD. If
you don’t know how to display data on LCD, you can check tutorial here. Now lets see the
explanation of code.
First we initialized serial port at 9600 baud rate using UART_Init() function.
Next we need to Clear SMOD bit of PCON register
Actually there is some bug in uart_init() function of UART library, it writes HIGH
to SMOD bit that causes erroneous baud rate.
we can send some string to serial port with uart_write_text() function.
Now in while(1) loop, we are sending “P0+P1” string to serial port with uart_write_text
function.
now we can send same text array to serial port that is being display on character LCD.
At the end, we are sending new line character, OK code is now
ready we can compile and test it.
CODE of serial communication
8051 microcontroller
#include <REGX51.H>
void cct_init(void);
void SerialInitialize(void);
void main()
cct_init();
SerialInitialize();
EA = 1;
ES = 1;
uart_msg("Initializing Serial Communication");
uart_tx(0x0d);
uart_msg("1,2,3,4 key can on leds and a,b,c,d can off them respectively.");
uart_tx(0x0d);
while(1);
}
void cct_init(void) //initialize cct
{
TMOD = 0x20; //Timer 1 In Mode 2 -Auto Reload to Generate Baud
Rate
while(*c != 0)
{
uart_tx(*c++);
if(RI==1)
chr = SBUF;
RI = 0;
}
switch(chr)
RI = 0;
Now, copy the below code and paste it into your Keil uvision
software. I have used Keil uvision 3 for this code compiling.
#include<reg51.h>
// PWM_Pin
sbit PWM_Pin = P2^0; // Pin P2.0 is named as
PWM_Pin
// Function declarations
void cct_init(void);
void InitTimer0(void);
void InitPWM(void);
// Global variables
unsigned char PWM = 0; // It can have a value from 0 (0%
duty cycle) to 255 (100% duty cycle)
unsigned int temp = 0; // Used inside Timer0 ISR
// Main Function
int main(void)
{
cct_init(); // Make all ports zero
InitPWM(); // Start PWM
// Timer0 initialize
void InitTimer0(void)
{
TMOD &= 0xF0; // Clear 4bit field for timer0
TMOD |= 0x01; // Set timer0 in mode 1 = 16bit mode
// PWM initialize
void InitPWM(void)
{
PWM = 0; // Initialize with 0% duty cycle
InitTimer0(); // Initialize timer0 to start
generating interrupts
// PWM generation code is
written inside the Timer0 ISR
}
// Timer0 ISR
void Timer0_ISR (void) interrupt 1
{
TR0 = 0; // Stop Timer 0
1 1 0 0 0
2 0 1 0 0
3 0 0 1 0
4 0 0 0 1
Full Drive Mode − In this mode, two coils are energized at the same
time. This mode produces more torque. Here the power consumption is
also high
The following table is showing the sequence of input states in different windings.
1 1 1 0 0
2 0 1 1 0
3 0 0 1 1
4 1 0 0 1
Half Drive Mode − In this mode, one and two coils are energized
alternately. At first, one coil is energized then two coils are
energized. This is basically a
combination of wave and full drive mode. It increases the angular
rotation of the motor
The following table is showing the sequence of input states in different windings.
1 1 0 0 0
2 1 1 0 0
3 0 1 0 0
4 0 1 1 0
5 0 0 1 0
6 0 0 1 1
7 0 0 0 1
8 1 0 0 1
The circuit diagram is like below: We are using the full drive mode.
Example
#include<reg51.h>
sbit LED_pin = P2^0; //set the LED pin as P2.0 void delay(int ms){
unsigned int i, j;
for(i = 0; i<ms; i++){ // Outer for loop for given milliseconds value
for(j = 0; j< 1275; j++){
//execute in each milliseconds;
}
}
}
void main(){
int rot_angle[] = {0x0C,0x06,0x03,0x09}; int i;
while(1){
//infinite loop for LED blinking for(i = 0; i<4; i++){
P0 = rot_angle[i];
delay(100);
}
}
}
ADC/DAC INTERFACING:
With this, you have successfully interfaced the 8051 to the ADC.
Now let us look at the logic to use the ADC with the microcontroller.
Logic to communicate between 8051 and ADC 0808
Several control signals need to be sent to the ADC to extract the
required data from it.
Step 1: Set the port you connected to the output lines of the
ADC as an input port. You can learn more about the Ports in
8051 here.
Step 2: Make the Port connected to EOC pin high. The reason
for doing this is that the ADC sends a high to low signal when
the conversion of data is complete. So this line needs to be
high so that the microcontroller can detect the change.
Step 3: Clear the data lines which are connected to pins ALE,
START, and OE as all these pins require a Low to High pulse
to get activated.
Step 4: Select the data lines according to the input port you
want to select. To do this, select the data lines and send a
High to Low pulse at the ALE pin to select the address.
Step 5: Now that we have selected the analog input pin, we
can tell the ADC to start the conversion by sending a pulse to
the START pin.
Step 6: Wait for the High to low signal by polling the EOC pin.
Step 7: Wait for the signal to get high again.
Step 8: Extract the converted data by sending a High to low
signal to the OE pin.
Assembly language program to interface ADC 0808 with 8051
Here is how the assembly code for the same looks like
ORG 0000H; Starting address
ACALL DELAY
ACALL DELAY
ACALL DELAY
ACALL DELAY
DJNZ R3,HERE2
RET
END
sbit OE = P2^5;
sbit SC = P2^6;
for(i=0;i<delay;i++)
for(j=0;j<1275;j++);
void main()
MYDATA = 0xFF;
EOC = 1;
ALE = 0;
OE = 0;
SC = 0;
while(1)
{
ADDR_C = 0;
ADDR_B = 0;
ADDR_A = 0;
MSDelay(1);
ALE = 1;
MSDelay(1);
SC = 1;
MSDelay(1);
ALE = 0;
SC = 0;
while(EOC==1);
while(EOC==0);
OE=1;
MSDelay(1);
value = MYDATA;
SENDDATA = value;
OE = 0 ;
}
DAC INTERFACING:
Circuit Diagram −
Source Code
#include<reg51.h>
sfr DAC = 0x80; //Port P0 address
void main(){
int sin_value[12] = {128,192,238,255,238,192,128,64,17,0,17,64};
int i;
while(1){
//infinite loop for LED
blinking for(i = 0; i<12; i++){
DAC = sin_value[i];
}
}
}
Output
The output will look like this −
Circuit Diagram and Explanation
Circuit diagram for LCD interfacing with 8051 microcontroller is shown in the
above figure. If you have basic understanding of 8051 then you must know
about EA(PIN 31), XTAL1 & XTAL2, RST pin(PIN 9), Vcc and Ground Pin of 8051
microcontroller. I have used
these Pins in above circuit. If you don’t have any idea about that then I
recommend you to read this Article LED Interfacing with 8051 Microcontroller
before going through LCD interfacing.
So besides these above pins we have connected the data pins (D0-D7) of LCD to
the Port 2 (P2_0 – P2_7) microcontroller. And control pins RS, RW and E to the
pin 12,13,14 (pin 2,3,4 of port 3) of microcontroller respectively.
PIN 2(VDD) and PIN 15(Backlight supply) of LCD are connected to voltage (5v),
and PIN 1 (VSS) and PIN 16(Backlight ground) are connected to ground.
Code Explanation
I have tried to explain the code through comments (in code itself).
As I have explained earlier about command mode and data mode, you can see
that while sending command (function lcd_cmd) we have set RS=0, RW=0 and a
HIGH to LOW pulse is given to E by making it 1, then 0. Also when sending data
(function lcd_data) to LCD we have set RS=1, RW=0 and a HIGH to LOW pulse is
given to E by making it 1 to 0. Function msdelay() has been created to create
delay in milliseconds and called frequently in the program, it is called so that
LCD module can have sufficient time to execute the internal operation and
commands.
A while loop has been created to print the string, which is calling the lcd_data
function each time to print a character until the last character (null terminator- ‘\
0’).
We have used the lcd_init() function to get the LCD ready by using the preset
command instructions (explained above).
Code
// Program for LCD Interfacing with 8051 Microcontroller (AT89S52)
#include<reg51.h>
#define display_port P2 //Data pins connected to port 2 on
microcontroller sbit rs = P3^2; //RS pin connected to pin 2 of port
3
sbit rw = P3^3; // RW pin connected to pin 3
of port 3 sbit e = P3^4; //E pin connected to
pin 4 of port 3
RTC INTERFACING:
sbit
SCL=P2^5;
sbit
SDA=P2^6;
void start();
void wirte(unsigned
char); delay(unsigned
char);
void main()
{
start();
write(0xA2); //slave address//
write(0x00); //control register
address// write(0x00); //control
register 1 value// write(0x00);
//control regiter2 vlaue// write
(0x28); //sec value//
write(0x50) ;//minute
value//
write(0x02);//hours
value//
}
void start()
{
unsigned char k,
j=0×80;
for(k=0;k<8;k++)
{ SDA=(d
&j);
J=j>>1;
SCL=1;
delay(4
);
SCL=0;
}
SDA=
1;
SCL=1
;
delay(2
);
c=SDA;
delay(2
);
SCL=0;
}
void delay(int p)
{
unsignedinta,b;
For(a=0;a<255;a++); //delay
function// For(b=0;b<p;b++);
}
Read Operation from Slave to Master:
#include<reg51
.h> sbit SCL=P2^
5;
sbit SDA=P2^
voi 6;
d cha start();
void write(usigned r );
voi read();
d ack()
voi ;
d char
void );
in read main(
delay(unsigned
void
{ )
start();
write(0xA3);// slave
address read(); mode
ack();
sec=valu
e; //
}
void
{
start()
SDA=1; //processing the
data// SCL=1; //clock is
high// delay(100);
SDA=0; //sent the
data// delay(100);
SCL=0; //clock signal is low//
}
void write(unsigned char d)
{
unsigned char k,
j=0×80;
for(k=0;k<8;k++)
{ SDA=(d
&j);
J=j>>1;
SCL=1;
delay(4
);
SCL=0;
}
SDA=
1;
SCL=1
;
delay(2
);
c=SDA;
delay(2
);
SCL=0;
}
void delay(int p)
{
unsignedinta,b;
For(a=0;a<255;a++); //delay
function// For(b=0;b<p;b++);
}
Void read ()
{
Unsigned char j, z=0×00,
q=0×80; SDA=1;
for(j=0;j<8;j++)
{ SCL
=1;
delay(100
);
flag=SDA
;
if(flag==
1)
{
z=(z|q);
q=q>>1;
delay
(100);
SCL=0;
}
void ack()
{
SDA=0; //SDA line goes to
low// SCL=1; //clock is high
to low// delay(100);
SCL=0;
}
SENSOR INTERFACING:
Circuit diagram
Programming Steps
Program
/*
DHT11 Interfacing with 8051
*/
TMOD = 0x01;
TH0 = 0xB8; TL0 = 0x0C;
/* Load higher 8-bit in TH0 */
/* Load lower 8-bit in TL0 */
TR0 = 1; /* Start timer0 */
while(TF0 == 0); /* Wait until timer0 flag set */
TR0 = 0; /* Stop timer0 */
TF0 = 0; /* Clear timer0 flag */
}
void main()
{
unsigned char dat[20];
LCD_Init(); /* initialize LCD */
while(1
)
{
Request(); /* send start pulse */
Response(); /* receive response */
else
{
sprintf(dat,"Hum = %d.
%d",I_RH,D_RH);
LCD_String_xy(0,0,dat);
sprintf(dat,"Tem = %d.
%d",I_Temp,D_Temp);
LCD_String_xy(1,0,dat);
LCD_Char(0xDF);
LCD_String("C");
memset(dat,0,20);
sprintf(dat,"%d ",CheckSum
); LCD_String_xy(1,13,dat);
}
delay(100);
RESULT:
DESIGNED ALL PARAMETERS OF 8051 8 BIT PROCESSORS.
EX.NO:2
DESIGN WITH 16 BIT PROCESSORS
I/O programming, Timers, Interrupts, Serial Communication,
AIM:
TO DESIGN 16 BIT PROCESSORS
I/O programming,timers,interrupts,serial communication
I/O Map
TIMERS:
delay
500us/1.080806us
461pulses
P=65535-461
P=65074
=FE32 TH1=0xFE;
TL1=0x32;
Example Programs:
Program- 1
Program- 2
Timer interrupt in 8051
8051 has two timer interrupts assigned with different vector address.
When Timer count rolls over from its max value to 0, it sets the timer
flag TFx. This will interrupt the 8051 microcontroller to serve ISR
(interrupt service routine) if global and timer interrupt is enabled.
The timer overflow interrupt assigned with the vector address shown in
the table. 8051 microcontroller jumps directly to the vector address on
the occurrence of a corresponding interrupt.
Example
And mode1 has a max count is 2^16 (0 - 65535) and it increment from
0 – 65535 so we need to load value which is 46080 less from its max.
count i.e. 65535. Hence value need to be load is,
*/
#include<reg51.h>/* Include x51 header file */
sbit test = P1^0;/* set test pin0 of port1 */
void Timer_init()
{
/* Start timer0 */
void Timer0_ISR() interrupt 1 /* Timer0 interrupt service routine (ISR) */
{
int main(void)
{
while(1);
}
SCON=0x50;
value=SBUF;
P1=value;
SBUF='k';
while(TI==0);
TI=0;
}
void main()
while(1)
initialize();
receive();
transmit();
RESULT:
DESIGNED ALL PARAMETERS OF 8051 16 BIT PROCESSORS.
AIM:
2.ORG 0000h
MOV r1 #10
,
MOV r2 #15
,
SUB r3, r2, r1 // r3=r2-r1 and the final value stored in r3 register//
The ARM Coretex-M3 Microcontroller Embedded C Level Programming:
WAP to toggle the single LED through Embedded C language using ARM
cortex microcontroller.
#include “stm32f10x_gpio.h”
#include “stm32f10x_rcc.h”
GPIO_InitTypeDef GPIO_InitStructure;
int i;
#define LED_PORT GPIOB
Void binky();
Void main()
{
Void binky();
}
void binky(void)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); //enable
the PORTB
pins//
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //set the port
frequency// GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //set the
PORTB in output// GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All ; //enabled all
PORTB pins// GPIO_Init(GPIOB, &GPIO_InitStructure); //initialize the PORTB
pins//
while(1){
GPIO_WriteBit(LED_PORT,GPIO_Pin_8,Bit_SET);
for (i=0;i<1000000;i++);
GPIO_WriteBit(LED_PORT,GPIO_Pin_8,Bit_RESET);
for (i=0;i<1000000;i++);
GPIO_WriteBit(LED_PORT,GPIO_Pin_9,Bit_SET);
for (i=0;i<1000000;i++);
GPIO_WriteBit(LED_PORT,GPIO_Pin_9,Bit_RESET);
for (i=0;i<1000000;i++);
GPIO_WriteBit(LED_PORT,GPIO_Pin_10,Bit_SET);
for (i=0;i<1000000;i++);
GPIO_WriteBit(LED_PORT,GPIO_Pin_10,Bit_RESET);
for (i=0;i<1000000;i++);
}
#include <lpc214x.h>
#include <stdint.h>
#include "LCD-16x2-
8bit.h" #include
<stdio.h> #include
<string.h>
int main(void)
{
uint32_t
result; float
voltage; char
volt[18];
AD0CR = 0x00200402; /* ADC operational, 10-bits, 11 clocks for
conversion
*/
while(1)
{
AD0CR = AD0CR | (1<<24); /* Start Conversion */
while ( !(AD0DR1 & 0x80000000) ); /* Wait till DONE */
result = AD0DR1;
result =
(result>>6);
result = (result & 0x000003FF);
voltage = ( (result/1023.0) * 3.3 ); /* Convert ADC value to
equiv alent voltage */
LCD_Command(0x80);
sprintf(volt, "Voltage=%.2f V ", voltage);
LCD_String(volt);
memset(volt, 0, 18);
}
DAC:
Program
/*
DAC in LPC2148(ARM7)
http://www.electronicwings.com/arm7/lpc2148-dac-digital-to-analog-converter
*/
#include <lpc214x.h>
#include <stdint.h>
void delay_ms(uint16_t j)
{
uint16_t x,i;
for(i=0;i<j;i++)
{
for(x=0; x<6000; x++); /* loop to generate 1 milisecond delay with
Cclk = 6 0MHz */
}
}
436,359,282,216,211,151,97,55,25,6,0,6,25,55,97,15
1,211,216,282,359,436 };
while(1)
{
if ( !(IO0PIN & (1<<8)) ) /* If switch for sine wave is pre
ssed
*/
{
while(i !=42)
{
value = sin_wave[i];
DACR = ( (1<<16) | (value<<6) );
delay_ms(1)
; i++;
}
i =
0;
}
value = 0;
while ( value != 1023 )
{
DACR = ( (1<<16) | (value<<6) );
value++;
}
}
else if ( !(IO0PIN & (1<<11)) ) /* If switch for square wave is p
ressed */
{
value = 1023;
DACR = ( (1<<16) | (value<<6) );
delay_ms(100); value = 0;
DACR = ( (1<<16) | (value<<6) );
delay_ms(100);
}
else
{ /* If no switch is pressed, 3.3V DC */
value = 1023;
DACR = ( (1<<16) | (value<<6) );
}
}
}
TIMERS:
Program
/*
Delay using Timer in LPC2148(ARM7)
http://www.electronicwings.com/arm7/lpc2148-
timercounter
*/
#include <lpc214x.h>
while (1);
}
INTERUPTS:
PROGRAM:
#include<lpc214x.h
T0CTCR =
0x00; T0PR =
60000-1;
T0TCR = 0x02;
T0MR0 =
1000-1;
{ T0TCR=0x
02;
T0TCR=0x0
1;
T0TCR=0x00;
}
/* ISR for the Interrupt */
long int
val; val =
T0IR; if
(z==0)
IOSET1 = led;
else
IOCLR1 = led;
z=~z;
T0IR = val;
VICVectAddr =
0x00;
}
VICIntSelect = 0x00;
VICIntEnable |=
(1<<4); VICVectCntl0
= 0x20 | 4;
int main()
PINSEL2 =
0x00; IODIR1
= led;
/* Enable PLL block and set the CCLK and PCLK to 60 MHz */
PLL0CON = 0x01;
PLL0CFG =
0x24; PLL0FEED
= 0xaa;
PLL0FEED =
0x55;
0x00000400)); PLL0CON =
0x03;
PLL0FEED =
0xaa; PLL0FEED
= 0x55; VPBDIV
= 0x01;
Function */ timer();
Function */ interrupt();
/* Enable
Timer */ T0TCR
= 0x01;
while(1);
}
RESULT:
DESIGNED ALL PARAMETERS OF ARM PROCESSORS
EX.NO:4
Components of
Real
Time Operating System
The Scheduler: This component of RTOS tells that in which order, the
tasks can be executed which is generally based on the priority.
Types of RTOS
Three types of RTOS systems are:
Features of RTOS
Here are important features of RTOS:
General-Purpose
Real-Time Operating System
Operating System
(RTOS)
(GPOS)
It used for desktop PC and It is only applied to the
laptop. embedded application.
Disadvantages of RTOS
Here, are drawbacks/cons of using RTOS system:
RESULT:
STUDIED ONE TYPE OF REAL TIME OPERATING SYSTEMS.
EX.NO:5
2. Sequential circuits:
A sequential circuit is specified by a time sequence of inputs, outputs,
and internal states. The output of a sequential circuit depends not
only the combination of present inputs but also on the previous
outputs. Unlike combinational circuits, sequential circuits include
memory elements with combinational circuits.
Successfully.
EX.NO 6:
Introduction
Traditionally offline simulation has been used extensively to
investigate the performance of an electrical system because of its
minimal effort and low cost. But, due to the computational
resources and run time restrictions, the emulation precision and
reliability suffer from various levels of model reductions [1]. So
offline simulation does not replicate the real behavior of the
electrical system.
If the application requires real-time processing, causal filters are the only choice for
implementation. Following consequences must be considered if causality is desired.
Ideal filters with finite bands of zero response (example: brick-wall filters), cannot be
implemented using causal filter structure. A direct consequence of causal filter is that
the response cannot be ideal. Hence, we must design the filter that provides a close
approximation to the desired response . If tolerance specification is given, it has to be
met.
For example, in the case of designing a low pass filter with given passband frequency (
) and stopband frequencies ( ), additional tolerance specifications like allowable
passband ripple factor ( ), stopband ripple factor ( ) need to be considered for the
design,. Therefore, the practical filter design involves choosing and and
then designing the filter with and that satisfies all the given
requirements/responses. Often, iterative procedures may be required to satisfy all the
above (example: Parks and McClellan algorithm used for designing optimal causal FIR
filters [1]).
RESULT:
Programming with DSP processors for Correlation, Convolution, Arithmetic adder, Multiplier,
Design of Filters - FIR based , IIR based are developed.
EX.NO:8
AIM;
Design with Programmable Logic Devices using Xilinx/Altera FPGA and CPLD Design and
Implementation of simple Combinational/Sequential Circuits
Employing the Artix®-7 FPGA and Xilinx IP solutions enables a smaller form
factor programmable logic controller (PLC) with greater flexibility, lower BOM
cost and lower total power consumption compared to traditional
architectures. Serving as a companion device to the main processor, the
FPGA replaces communication expansion modules.
Programmable Logic Controllers (PLC) grew from their classical role as a
dedicated layer in the Automation Pyramid to flexible Intelligent Edge nodes
with versatile and customizable functionality. While SW-runtimes for IEC
61131 guarantee traditional PLC functions, network offloading, image
processing and Digital Twins inside the same component increase the value
of this class of industrial products.
That's where intelligent and adaptive SOCs like Xilinx Zynq UltraScale+
MPSoC and Xilinx Versal come into the play. The applications processors
inside the SOC communicate with the Programmable Logic through a high-
performance architecture. Logic can be used for custom logic as well as for
Deep Learning using Neural Networks which sit in the FPGA portion and run
at optimal power to performance ratio. Typical applications to enrich a PLC, a
PAC and an IPC are:
Real time networking with scalable number of ports (TSN, UDP IP,
Industrial Ethernet)
Predictive Maintenance
Because Xilinx's development tools are safety certified and because Xilinx
provides in- depth information including reports from assessors about Zynq
UltraScale+ MPSoC on the Safety Lounge, this architecture can be used for
Safe PLC designs.
Xilinx's partner ecosystem provides you with the right boards and kits to
create a solution fast. Our product Xilinx Kria, a versatile SOM for industrial
applications, enables a fast start with accelerated applications around
machine vision and more to come in our App Store.
The PLC (Programmable Logic Controller) has been widely used to implement real-
time controllers in nuclear RPSs (Reactor Protection Systems). Increasing complexity
and maintenance cost, however, are now demanding more powerful and cost-effective
implementation such as FPGA (Field-Programmable Gate Array). Abandoning all
experience and knowledge accumulated over the decades and starting an all-new
development approach is too risky for such safety-critical systems. This paper
proposes an RPS software development process with a platform change from PLC to
FPGA, while retaining all outputs from the established development. This paper
transforms FBD designs of the PLC-based software development into a behaviorally-
equivalent Verilog program, which is a starting point of a typical FPGA-based
hardware development. We expect that the proposed software development process
can bridge the gap between two software developing approaches with different
platforms, such as PLC and FPGA. This paper also demonstrates its effectiveness
using an example of a prototype version of a real-world RPS in Korea.
Previous article in issue
Next article in issue
KEYWORDS
Embedded Software Development
PLC
FPGA
FBD
Verilog
Program Transformation
1. INTRODUCTION
A safety grade PLC is an industrial digital computer used to develop safety-critical
systems such as RPS (Reactor Protection System) for nuclear power plants. The
software loaded into a PLC is designed using specific PLC programming languages
[1] such as FBD (Function Block Diagram) and LD (Ladder Diagram), which are
then translated and compiled into a C program and executable machine code of a
specific target PLC.
Since the complexity of new RPSs and the maintenance cost of old RPSs have
increased rapidly, we need to find an efficient alternative for the PLC-based RPS
implementation. One solution [2, 3] proposed is to replace PLC with FPGA, which
can provide a powerful computation with lower hardware cost. However, it is a
challenge for software engineers in the nuclear domain to abandoning all experience,
knowledge and practice, based on PLC and start an FPGA-based development from
scratch. Such change is also too risky from the viewpoint of safety. We need to transit
to the new development approach safely and seamlessly, allowing all software
engineers to become familiar with the processes and procedures required for a proper
set up.
This paper proposes an RPS software development process with a change in the
hardware platform from PLC to FPGA.
Theory
In this section we are going to extend the simple wireless topology created
in section IX to create a mixed scenario consisting of a wireless and a wired
domain, where data is exchanged between the mobile and non-mobile
nodes. We are going to make modifications to the tcl script called
wireless1.tcl created in section IX.2 and name the resulting wired-cum-
wireless scenario file wireless2.tcl.
For the mixed scenario, we are going to have 2 wired nodes, W(0) and
W(1), connected to our wireless domain consisting of 3 mobilenodes (nodes
0, 1 & 2) via a base-station node, BS. Base station nodes are like gateways
between wireless and wired domains and allow packets to be exchanged
between the two types of nodes. For details on base- station node please
see section 2 (wired-cum-wireless networking) of chapter 15 of ns
notes&doc (now renamed as ns Manual). Fig1. shows the topology for this
example described above.
# create four nodes
set node1 [$ns node]
set node2 [$ns node]
set node3 [$ns node]
set node4 [$ns node]
# monitor the queue for the link between node 2 and node 3
$ns duplex-link-op $node3 $node4 queuePos 0.5
$ns_ node-config \
-llType LL
-ifqType "Queue/DropTail/PriQueue" 50
-ifqLen Mac/802_11 "Phy/WirelessPhy"
-macType
-phyType
-agentTrace ON or OFF
-routerTrace ON or OFF
-macTrace ON or OFF
-movementTrace ON or OFF
RESULT:
Simple wired/ wireless network simulation using NS2 are studied successfully.
EX.NO 10:
The TCP/IP protocol suite can be described using a reference model similar to the OSI
reference model. Figure 1-4 shows the corresponding OSI layers and some example
services at each layer. TCP/IP does not delineate the presentation and session layers as
the OSI model does; application code provides the necessary presentation or session
functionality.
RFCs define a number of applications, the most widely used being telnet, a terminal
emulation service on remote hosts, and ftp, which allows files to be transferred
between systems.
The following sections describes the parts of the TCP/IP protocol stack.
Device Drivers
The device driver layer (also called the Network Interface) is the lowest TCP/IP layer
and is responsible for accepting packets and transmitting them over a specific
network. A network interface might consist of a device driver or a complex subsystem
that uses its own data link protocol.
The Internet Protocol layer handles communication from one machine to another. It
accepts requests to send data from the transport layer along with an identification of
the machine to which the data is to be sent. It encapsulates the data into an IP
datagram, fills in the datagram header, uses the routing algorithm to determine how to
deliver the datagram, and passes the datagram to the appropriate device driver for
transmission.
The IP layer corresponds to the network layer in the OSI reference model. IP provides
a connectionless, "unreliable" packet-forwarding service that routes packets from one
system to another.
Transport Layer
The primary purpose of the transport layer is to provide communication from one
application program to another. The transport software divides the stream of data
being transmitted into smaller pieces called packets in the ISO terminology and
passes each packet along with the destination information to the next layer for
transmission.
Application Layer
Application Layer
Transport Layer
Internet Layer
Network Interface
Application Layer
Application layer interacts with an application program, which is the
highest level of OSI model. The application layer is the OSI layer, which
is closest to the end- user. It means the OSI application layer allows
users to interact with other software application.
Transport Layer
Transport layer builds on the network layer in order to provide data
transport from a process on a source system machine to a process on a
destination system. It is hosted using single or multiple networks, and
also maintains the quality of service functions.
It determines how much data should be sent where and at what rate.
This layer builds on the message which are received from the
application layer. It helps ensure that data units are delivered error-free
and in sequence.
Transport layer helps you to control the reliability of a link through flow
control, error control, and segmentation or de-segmentation.
Internet Layer
An internet layer is a second layer of TCP/IP layes of the TCP/IP model. It
is also known as a network layer. The main work of this layer is to send
the packets from
any network, and any computer still they reach the destination
irrespective of the route they take.
The Internet layer offers the functional and procedural method for
transferring variable length data sequences from one node to another
with the help of various networks.
Message delivery at the network layer does not give any guaranteed to
be reliable network layer protocol.
1. Routing protocols
2. Multicast group management
3. Network-layer address assignment.
RESULT:
Programming of TCP/IP protocol stack are studied.